Skip to content

Commit

Permalink
[Markdown] Refactor fenced code blocks (sublimehq#2925)
Browse files Browse the repository at this point in the history
* [Markdown] Sort fenced codeblock contexts alphabetically

This commit just sorts embedded syntaxes by alphabetically language tag.

* [Markdown] Add Diff/Patch syntax to fenced code blocks

* [Markdown] Add Haskell syntax to fenced code blocks

* [Markdown] Add JSX syntax to fenced code blocks

* [Markdown] Add Lisp syntax to fenced code blocks

* [Markdown] Add Lua syntax to fenced code blocks

* [Markdown] Add Matlab syntax to fenced code blocks

* [Markdown] Add OCaml syntax to fenced code blocks

* [Markdown] Add Scala syntax to fenced code blocks

* [Markdown] Add TSX syntax to fenced code blocks

* [Markdown] Add HTML syntax to fenced code blocks

* [Markdown] Fix HTML+PHP completion details

* [Markdown] Reorganize fenced codeblock syntaxes

Create a dedicated context for each syntax in case someone wants to address them in an inherited Markdown syntax.

* [Markdown] Reorganize fenced codeblocks

This commit splits `raw` context into `code-span` and `code-block`.
The ladder is called `fenced-code-blocks`, finally.

The reasons are:

1. `raw` is used in `inline` context, which is also used within link
   texts and other inline-only places which never contain code-blocks.
   By only matching fenced codeblocks when they are likely to appear
   parsing duration of syntax test file is reduced by about 10%.

2. Several duplicated explicit matches are replaced by including the new
   `fenced-code-blocks` context.

The dedicated `fenced-syntaxes` context excludes `fenced-raw` in order
to make it easier for inherited syntaxes to append further contexts.

* [Markdown] Add dedicated fenced-raw-content context

To reduce number of anonymous contexts and improve inherit-ability

* [Markdown] Fix thematic break after fenced codeblocks

Fixes sublimehq#2947

Fenced codeblocks are a separate type of block, which must not be part
of ordinary paragraphs.

see: https://spec.commonmark.org/0.30/#leaf-blocks

* [Markdown] Simplify regexp language pattern

* [Markdown] Add support for fenced `shell` language tag
  • Loading branch information
deathaxe authored and mitranim committed Mar 20, 2022
1 parent 88bad5b commit 78952b9
Show file tree
Hide file tree
Showing 3 changed files with 537 additions and 129 deletions.
74 changes: 73 additions & 1 deletion Markdown/Code Block Syntaxes.sublime-completions
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>C#</code> code highlighting"
},
{
"trigger": "diff",
"annotation": "Diff",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Diff</code> code highlighting"
},
{
"trigger": "erlang",
"annotation": "Erlang",
Expand All @@ -79,11 +85,23 @@
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>GraphViz</code> code highlighting"
},
{
"trigger": "haskell",
"annotation": "Haskell",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Haskell</code> code highlighting"
},
{
"trigger": "html",
"annotation": "HTML",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>HTML</code> code highlighting"
},
{
"trigger": "html+php",
"annotation": "PHP",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>PHP</code> code highlighting"
"details": "Specifies <code>HTML+PHP</code> code highlighting"
},
{
"trigger": "inc",
Expand Down Expand Up @@ -133,6 +151,30 @@
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Java Server Pages</code> code highlighting"
},
{
"trigger": "JSX",
"annotation": "JavaScript React",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>JavaScript React</code> code highlighting"
},
{
"trigger": "lisp",
"annotation": "Lisp",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Lisp</code> code highlighting"
},
{
"trigger": "lua",
"annotation": "Lua",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Lua</code> code highlighting"
},
{
"trigger": "matlab",
"annotation": "MatLab",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>MatLab</code> code highlighting"
},
{
"trigger": "obj-c",
"annotation": "Objective-C",
Expand Down Expand Up @@ -181,6 +223,18 @@
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Objective-C++</code> code highlighting"
},
{
"trigger": "ocaml",
"annotation": "OCaml",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>OCaml</code> code highlighting"
},
{
"trigger": "patch",
"annotation": "Patch",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Patch</code> code highlighting"
},
{
"trigger": "perl",
"annotation": "Perl 5",
Expand Down Expand Up @@ -259,12 +313,24 @@
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Rust</code> code highlighting"
},
{
"trigger": "scala",
"annotation": "Scala",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>Scala</code> code highlighting"
},
{
"trigger": "sh",
"annotation": "ShellScript",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>ShellScript</code> code highlighting"
},
{
"trigger": "shell",
"annotation": "ShellScript",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>ShellScript</code> code highlighting"
},
{
"trigger": "shell-script",
"annotation": "ShellScript",
Expand All @@ -289,6 +355,12 @@
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>TypeScript</code> code highlighting"
},
{
"trigger": "tsx",
"annotation": "TypeScript React",
"kind": ["markup", "s", "Syntax"],
"details": "Specifies <code>TypeScript React</code> code highlighting"
},
{
"trigger": "typescript",
"annotation": "TypeScript",
Expand Down
Loading

0 comments on commit 78952b9

Please sign in to comment.