Skip to content

Commit

Permalink
[Markdown] Match code block syntax names with Linguist aliases
Browse files Browse the repository at this point in the history
Mainly because `batchfile` didn't work for batch files...

This commit adds most of Linguist (GH language detector - [source][1]) aliases
for languages for which fenced code block contexts exist in Markdown grammar.

I've omitted a few aliases because these name separate languages with their
own third-party packages (notably `cake`, `octave` and some `sh` variants).

I've left ActionScript alone as I wasn't sure whether the grammar covers as3.

[1]: https://github.com/github-linguist/linguist/blob/master/lib/linguist/languages.yml
  • Loading branch information
mataha committed Jul 12, 2024
1 parent 3c25c09 commit e1262e6
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 24 deletions.
132 changes: 124 additions & 8 deletions Markdown/Code Block Syntaxes.sublime-completions
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

// AppleScript
{
"trigger": "AppleScript",
"trigger": "applescript",
"annotation": "AppleScript",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>AppleScript</code> code highlighting"
Expand All @@ -29,6 +29,12 @@
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>AppleScript</code> code highlighting"
},
{
"trigger": "scpt",
"annotation": "AppleScript",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>AppleScript</code> code highlighting"
},

// C++
{
Expand All @@ -39,19 +45,19 @@
},
{
"trigger": "cpp",
"annotation": "C++",
"annotation": "C++ source",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>C++</code> code highlighting"
},
{
"trigger": "cxx",
"annotation": "C++",
"annotation": "C++ source",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>C++</code> code highlighting"
},
{
"trigger": "c++",
"annotation": "C++",
"annotation": "C++ source",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>C++</code> code highlighting"
},
Expand Down Expand Up @@ -129,6 +135,12 @@
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Diff</code> code highlighting"
},
{
"trigger": "udiff",
"annotation": "Unified Diff",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Diff</code> code highlighting"
},
{
"trigger": "patch",
"annotation": "Patch",
Expand All @@ -143,20 +155,44 @@
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>DOS batch</code> code highlighting"
},
{
"trigger": "batch",
"annotation": "DOS batch",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>DOS batch</code> code highlighting"
},
{
"trigger": "batchfile",
"annotation": "DOS batch",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>DOS batch</code> code highlighting"
},
{
"trigger": "cmd",
"annotation": "DOS batch",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>DOS batch</code> code highlighting"
},
{
"trigger": "dos",
"trigger": "dosbatch",
"annotation": "DOS batch",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>DOS batch</code> code highlighting"
},
{
"trigger": "winbatch",
"annotation": "DOS batch",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>DOS batch</code> code highlighting"
},

// Erlang
{
"trigger": "erl",
"annotation": "Erlang",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Erlang</code> code highlighting"
},
{
"trigger": "erlang",
"annotation": "Erlang",
Expand Down Expand Up @@ -185,12 +221,24 @@
},

// GraphViz
{
"trigger": "dot",
"annotation": "GraphViz",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>GraphViz</code> code highlighting"
},
{
"trigger": "graphviz",
"annotation": "GraphViz",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>GraphViz</code> code highlighting"
},
{
"trigger": "gv",
"annotation": "GraphViz",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>GraphViz</code> code highlighting"
},

// Haskell
{
Expand All @@ -199,6 +247,18 @@
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Haskell</code> code highlighting"
},
{
"trigger": "hs",
"annotation": "Haskell",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Haskell</code> code highlighting"
},
{
"trigger": "hsc",
"annotation": "Haskell C binding",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Haskell</code> code highlighting"
},

// HTML
{
Expand All @@ -207,6 +267,12 @@
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>HTML</code> code highlighting"
},
{
"trigger": "xhtml",
"annotation": "HTML",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>HTML</code> code highlighting"
},

// Java
{
Expand Down Expand Up @@ -242,7 +308,13 @@
"details": "Specifies <code>JavaScript</code> code highlighting"
},
{
"trigger": "JSX",
"trigger": "node",
"annotation": "JavaScript",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>JavaScript</code> code highlighting"
},
{
"trigger": "jsx",
"annotation": "JavaScript React",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>JavaScript React</code> code highlighting"
Expand All @@ -253,6 +325,12 @@
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>TypeScript</code> code highlighting"
},
{
"trigger": "tsnode",
"annotation": "TypeScript",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>TypeScript</code> code highlighting"
},
{
"trigger": "tsx",
"annotation": "TypeScript React",
Expand Down Expand Up @@ -310,6 +388,26 @@
"details": "Specifies <code>Lua</code> code highlighting"
},

// Makefile
{
"trigger": "make",
"annotation": "Makefile",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Makefile</code> code highlighting"
},
{
"trigger": "makefile",
"annotation": "Makefile",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Makefile</code> code highlighting"
},
{
"trigger": "mf",
"annotation": "Makefile",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Makefile</code> code highlighting"
},

// Matlab
{
"trigger": "matlab",
Expand Down Expand Up @@ -383,6 +481,12 @@
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Perl 5</code> code highlighting"
},
{
"trigger": "perl5",
"annotation": "Perl 5",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Perl 5</code> code highlighting"
},

// PHP
{
Expand All @@ -391,6 +495,12 @@
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>HTML+PHP</code> code highlighting"
},
{
"trigger": "phtml",
"annotation": "PHP",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>HTML+PHP</code> code highlighting"
},
{
"trigger": "inc",
"annotation": "PHP",
Expand All @@ -404,13 +514,19 @@
"details": "Specifies <code>PHP</code> code highlighting"
},

// Phyton
// Python
{
"trigger": "python",
"annotation": "Python",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Python</code> code highlighting"
},
{
"trigger": "python3",
"annotation": "Python",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Python</code> code highlighting"
},
{
"trigger": "py",
"annotation": "Python",
Expand Down Expand Up @@ -598,4 +714,4 @@
"details": "Specifies <code>YAML</code> code highlighting"
},
],
}
}
26 changes: 13 additions & 13 deletions Markdown/Markdown.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ contexts:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(applescript|osascript))
(?i:\s*(applescript|osascript|scpt))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.applescript.markdown-gfm
Expand Down Expand Up @@ -1293,7 +1293,7 @@ contexts:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(diff|patch))
(?i:\s*(u?diff|patch))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.diff.markdown-gfm
Expand All @@ -1315,7 +1315,7 @@ contexts:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(bat|cmd|dos))
(?i:\s*(bat(?:ch(?:file)?)?|cmd|(?:dos|win)batch))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.dosbatch.markdown-gfm
Expand All @@ -1337,7 +1337,7 @@ contexts:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(erlang|escript))
(?i:\s*(erl(?:ang)?|escript))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.erlang.markdown-gfm
Expand All @@ -1359,7 +1359,7 @@ contexts:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(graphviz))
(?i:\s*(dot|graphviz|gv))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.graphviz.markdown-gfm
Expand Down Expand Up @@ -1403,7 +1403,7 @@ contexts:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(haskell))
(?i:\s*(haskell|hsc?))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.haskell.markdown-gfm
Expand All @@ -1425,7 +1425,7 @@ contexts:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(html\+php))
(?i:\s*(html\+php|phtml))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.html-php.markdown-gfm
Expand All @@ -1447,7 +1447,7 @@ contexts:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(html))
(?i:\s*(x?html))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.html.markdown-gfm
Expand Down Expand Up @@ -1491,7 +1491,7 @@ contexts:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(javascript|js))
(?i:\s*(javascript|js|node))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.javascript.markdown-gfm
Expand Down Expand Up @@ -1645,7 +1645,7 @@ contexts:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(makefile))
(?i:\s*(make(?:file)?|mf))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.makefile.markdown-gfm
Expand Down Expand Up @@ -1755,7 +1755,7 @@ contexts:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(perl))
(?i:\s*(perl5?))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.perl.markdown-gfm
Expand Down Expand Up @@ -1799,7 +1799,7 @@ contexts:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(python|py))
(?i:\s*(python3?|py))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.python.markdown-gfm
Expand Down Expand Up @@ -2019,7 +2019,7 @@ contexts:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(typescript|ts))
(?i:\s*(typescript|ts(?:node)?))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.typescript.markdown-gfm
Expand Down
6 changes: 3 additions & 3 deletions Markdown/tests/syntax_test_markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -1842,9 +1842,9 @@ echo This is a smiley :-\) \(I have to escape the parentheses, though!\)
|^^ meta.code-fence.definition.end.diff.markdown-gfm punctuation.definition.raw.code-fence.end.markdown
| ^ meta.code-fence.definition.end.diff.markdown-gfm meta.fold.code-fence.end - punctuation

```Graphviz
|^^^^^^^^^^ meta.code-fence.definition.begin - meta.fold
| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin
```dot
|^^^^^ meta.code-fence.definition.begin - meta.fold
| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin

graph n {}
| ^^^ storage.type.dot
Expand Down

0 comments on commit e1262e6

Please sign in to comment.