Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Markdown] Add support for LaTeX in fenced code blocks #3916

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Markdown/Code Block Syntaxes.sublime-completions
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,20 @@
"details": "Specifies <code>JSON with Comments</code> code highlighting"
},

// LaTeX
{
"trigger": "tex",
"annotation": "TeX",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>TeX</code> code highlighting"
},
{
"trigger": "latex",
"annotation": "LaTeX",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>LaTeX</code> code highlighting"
},

// Lisp
{
"trigger": "lisp",
Expand Down
23 changes: 23 additions & 0 deletions Markdown/Markdown.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,7 @@ contexts:
- include: fenced-jsonc
- include: fenced-jspx
- include: fenced-jsx
- include: fenced-latex
- include: fenced-lisp
- include: fenced-lua
- include: fenced-makefile
Expand Down Expand Up @@ -1568,6 +1569,28 @@ contexts:
1: punctuation.definition.raw.code-fence.end.markdown
2: meta.fold.code-fence.end.markdown

fenced-latex:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(latex|tex))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.latex.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
6: comment.line.infostring.markdown
7: meta.fold.code-fence.begin.markdown
embed: scope:text.tex.latex
embed_scope:
markup.raw.code-fence.latex.markdown-gfm
text.tex.latex
escape: '{{fenced_code_block_escape}}'
escape_captures:
0: meta.code-fence.definition.end.latex.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
2: meta.fold.code-fence.end.markdown

fenced-lisp:
- match: |-
(?x)
Expand Down
12 changes: 12 additions & 0 deletions Markdown/tests/syntax_test_markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,18 @@ for (var i = 0; i < 10; i++) {
|^^ meta.code-fence.definition.end.jsx.markdown-gfm punctuation.definition.raw.code-fence.end.markdown
| ^ meta.code-fence.definition.end.jsx.markdown-gfm meta.fold.code-fence.end - punctuation

```latex
| <- meta.code-fence.definition.begin.latex.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown
|^^ meta.code-fence.definition.begin.latex.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown
| ^^^^^ meta.code-fence.definition.begin.latex.markdown-gfm constant.other.language-name.markdown
| ^ meta.code-fence.definition.begin.latex.markdown-gfm meta.fold.code-fence.begin.markdown - punctuation

| <- markup.raw.code-fence.latex.markdown-gfm text.tex.latex
```
| <- meta.code-fence.definition.end.latex.markdown-gfm punctuation.definition.raw.code-fence.end.markdown
|^^ meta.code-fence.definition.end.latex.markdown-gfm punctuation.definition.raw.code-fence.end.markdown
| ^ meta.code-fence.definition.end.latex.markdown-gfm meta.fold.code-fence.end.markdown - punctuation

```lisp
|^^^^^^ meta.code-fence.definition.begin - meta.fold
| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin
Expand Down
Loading