From e8c48489aaae39a574178bd18180920e7fe24495 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Thu, 2 Nov 2017 11:09:27 +0200 Subject: [PATCH 01/12] [Markdown] add syntax highlighting in code fences for a few languages --- Markdown/Markdown.sublime-syntax | 52 ++++++++++++++++++++++++++++++++ Markdown/syntax_test_markdown.md | 41 +++++++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index 6f49acf1d9..7a9ff0ad6d 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -898,6 +898,58 @@ contexts: - match: $ pop: true fenced-code-block: + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:xml)) + \s*$ # any whitespace until eol + captures: + 1: markup.raw.code-fence.xml.markdown punctuation.definition.raw.code-fence.begin.markdown + 2: markup.raw.code-fence.xml.markdown constant.other.language-name.markdown + embed: scope:text.xml + embed_scope: markup.raw.code-fence.xml.markdown + escape: '^[ ]{,3}\1\s*$' + escape_captures: + 0: markup.raw.code-fence.xml.markdown punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:sql)) + \s*$ # any whitespace until eol + captures: + 1: markup.raw.code-fence.sql.markdown punctuation.definition.raw.code-fence.begin.markdown + 2: markup.raw.code-fence.sql.markdown constant.other.language-name.markdown + embed: scope:source.sql + embed_scope: markup.raw.code-fence.sql.markdown + escape: '^[ ]{,3}\1\s*$' + escape_captures: + 0: markup.raw.code-fence.sql.markdown punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:python)) + \s*$ # any whitespace until eol + captures: + 1: markup.raw.code-fence.python.markdown punctuation.definition.raw.code-fence.begin.markdown + 2: markup.raw.code-fence.python.markdown constant.other.language-name.markdown + embed: scope:source.python + embed_scope: markup.raw.code-fence.python.markdown + escape: '^[ ]{,3}\1\s*$' + escape_captures: + 0: markup.raw.code-fence.python.markdown punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:graphviz)) + \s*$ # any whitespace until eol + captures: + 1: markup.raw.code-fence.graphviz.markdown punctuation.definition.raw.code-fence.begin.markdown + 2: markup.raw.code-fence.graphviz.markdown constant.other.language-name.markdown + embed: scope:source.dot + embed_scope: markup.raw.code-fence.graphviz.markdown + escape: '^[ ]{,3}\1\s*$' + escape_captures: + 0: markup.raw.code-fence.graphviz.markdown punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} diff --git a/Markdown/syntax_test_markdown.md b/Markdown/syntax_test_markdown.md index 7b97d39842..1aeb7acaeb 100644 --- a/Markdown/syntax_test_markdown.md +++ b/Markdown/syntax_test_markdown.md @@ -1765,3 +1765,44 @@ okay 1. Test 2 |^ markup.list.numbered.bullet punctuation.definition.list_item + +```xml +|^^^^^ markup.raw.code-fence.xml +| ^^^ constant.other.language-name + +|^^^^^^^^^^^^^^^^^^^^^^ markup.raw.code-fence.xml +| ^^^^^^^ meta.tag.preprocessor.xml entity.other.attribute-name.localname.xml + + + +``` +|^^^ punctuation.definition.raw.code-fence.end + +```sql +|^^^^^ markup.raw.code-fence.sql +| ^^^ constant.other.language-name +SELECT TOP 10 * +|^^^^^^^^^^^^^^^ markup.raw.code-fence.sql +|^^^^^^^^^ keyword.other.DML.sql +FROM TableName +``` +|^^^ markup.raw.code-fence.sql punctuation.definition.raw.code-fence.end + +```python +|^^ punctuation.definition.raw.code-fence.begin +|^^^^^^^^ markup.raw.code-fence.python +| ^^^^^^ constant.other.language-name +def function(): + pass +| ^^^^ keyword.control.flow.python +unclosed_paren = ( +| ^ meta.group.python punctuation.section.group.begin.python +``` +|^^^ markup.raw.code-fence.python punctuation.definition.raw.code-fence.end + +```Graphviz +graph n {} +| ^^^ storage.type.dot +``` + +| <- - markup.raw From c82a6143a6bdbd68d4375c337a0cb3bada8eda52 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Fri, 3 Nov 2017 12:44:27 +0200 Subject: [PATCH 02/12] [Markdown] tweaks to code fence support --- Markdown/Markdown.sublime-syntax | 88 ++++++++++++++++++++++++++------ Markdown/syntax_test_markdown.md | 8 +-- 2 files changed, 75 insertions(+), 21 deletions(-) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index 7a9ff0ad6d..41ea3785a9 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -163,6 +163,13 @@ variables: (?i:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul) (?:\s|$|/?>) ) + # code_fence_escape: |- + # (?x: + # ^ # the beginning of the line + # [ ]{0,3} # up to 3 spaces + # (\1) # the backtick/tilde combination that opened the code fence + # \s*$ # any amount of whitespace until EOL + # ) contexts: main: - match: |- @@ -902,66 +909,113 @@ contexts: (?x) {{fenced_code_block_start}} ((?i:xml)) - \s*$ # any whitespace until eol + \s*$ # any whitespace until EOL captures: 1: markup.raw.code-fence.xml.markdown punctuation.definition.raw.code-fence.begin.markdown 2: markup.raw.code-fence.xml.markdown constant.other.language-name.markdown embed: scope:text.xml embed_scope: markup.raw.code-fence.xml.markdown - escape: '^[ ]{,3}\1\s*$' + escape: '^[ ]{,3}(\1)\s*$' escape_captures: - 0: markup.raw.code-fence.xml.markdown punctuation.definition.raw.code-fence.end.markdown + 0: markup.raw.code-fence.xml.markdown + 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:sql)) - \s*$ # any whitespace until eol + \s*$ # any whitespace until EOL captures: 1: markup.raw.code-fence.sql.markdown punctuation.definition.raw.code-fence.begin.markdown 2: markup.raw.code-fence.sql.markdown constant.other.language-name.markdown embed: scope:source.sql embed_scope: markup.raw.code-fence.sql.markdown - escape: '^[ ]{,3}\1\s*$' + escape: '^[ ]{,3}(\1)\s*$' escape_captures: - 0: markup.raw.code-fence.sql.markdown punctuation.definition.raw.code-fence.end.markdown + 0: markup.raw.code-fence.sql.markdown + 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} - ((?i:python)) - \s*$ # any whitespace until eol + ((?i:python|py)) + \s*$ # any whitespace until EOL captures: 1: markup.raw.code-fence.python.markdown punctuation.definition.raw.code-fence.begin.markdown 2: markup.raw.code-fence.python.markdown constant.other.language-name.markdown embed: scope:source.python embed_scope: markup.raw.code-fence.python.markdown - escape: '^[ ]{,3}\1\s*$' + escape: '^[ ]{,3}(\1)\s*$' escape_captures: - 0: markup.raw.code-fence.python.markdown punctuation.definition.raw.code-fence.end.markdown + 0: markup.raw.code-fence.python.markdown + 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:graphviz)) - \s*$ # any whitespace until eol + \s*$ # any whitespace until EOL captures: 1: markup.raw.code-fence.graphviz.markdown punctuation.definition.raw.code-fence.begin.markdown 2: markup.raw.code-fence.graphviz.markdown constant.other.language-name.markdown embed: scope:source.dot embed_scope: markup.raw.code-fence.graphviz.markdown - escape: '^[ ]{,3}\1\s*$' + escape: '^[ ]{,3}(\1)\s*$' escape_captures: - 0: markup.raw.code-fence.graphviz.markdown punctuation.definition.raw.code-fence.end.markdown + 0: markup.raw.code-fence.graphviz.markdown + 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:javascript)) + \s*$ # any whitespace until EOL + captures: + 1: markup.raw.code-fence.javascript.markdown punctuation.definition.raw.code-fence.begin.markdown + 2: markup.raw.code-fence.javascript.markdown constant.other.language-name.markdown + embed: scope:source.javascript + embed_scope: markup.raw.code-fence.javascript.markdown + escape: '^[ ]{,3}(\1)\s*$' + escape_captures: + 0: markup.raw.code-fence.javascript.markdown + 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:java)) + \s*$ # any whitespace until EOL + captures: + 1: markup.raw.code-fence.java.markdown punctuation.definition.raw.code-fence.begin.markdown + 2: markup.raw.code-fence.java.markdown constant.other.language-name.markdown + embed: scope:source.java + embed_scope: markup.raw.code-fence.java.markdown + escape: '^[ ]{,3}(\1)\s*$' + escape_captures: + 0: markup.raw.code-fence.java.markdown + 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:csharp|c\#|cs)) + \s*$ # any whitespace until EOL + captures: + 1: markup.raw.code-fence.csharp.markdown punctuation.definition.raw.code-fence.begin.markdown + 2: markup.raw.code-fence.csharp.markdown constant.other.language-name.markdown + embed: scope:source.cs + embed_scope: markup.raw.code-fence.csharp.markdown + escape: '^[ ]{,3}(\1)\s*$' + escape_captures: + 0: markup.raw.code-fence.csharp.markdown + 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ([\w-]*) # any number of word characters or dashes - .*$ # all characters until eol + .*$ # all characters until EOL captures: 1: punctuation.definition.raw.code-fence.begin.markdown 2: constant.other.language-name.markdown push: - - meta_scope: markup.raw.code-fence.markdown-gfm - - match: '[ ]{,3}\1\s*$' - scope: punctuation.definition.raw.code-fence.end.markdown + - meta_scope: markup.raw.code-fence.markdown + - match: '[ ]{,3}(\1)\s*$' + captures: + 1: punctuation.definition.raw.code-fence.end.markdown pop: true code-span: - match: (`+)(?!`) diff --git a/Markdown/syntax_test_markdown.md b/Markdown/syntax_test_markdown.md index 1aeb7acaeb..e6bc214674 100644 --- a/Markdown/syntax_test_markdown.md +++ b/Markdown/syntax_test_markdown.md @@ -1144,7 +1144,7 @@ http://spec.commonmark.org/0.28/#example-318 | ^^^^ punctuation.definition.raw.code-fence.begin | ^^^^ constant.other.language-name ~~~~~~ -| ^^^^^ punctuation.definition.raw.code-fence.end +| ^^^^ punctuation.definition.raw.code-fence.end ```test | ^^^^ constant.other.language-name @@ -1776,7 +1776,7 @@ okay ``` -|^^^ punctuation.definition.raw.code-fence.end +|^^ punctuation.definition.raw.code-fence.end ```sql |^^^^^ markup.raw.code-fence.sql @@ -1786,7 +1786,7 @@ SELECT TOP 10 * |^^^^^^^^^ keyword.other.DML.sql FROM TableName ``` -|^^^ markup.raw.code-fence.sql punctuation.definition.raw.code-fence.end +|^^ markup.raw.code-fence.sql punctuation.definition.raw.code-fence.end ```python |^^ punctuation.definition.raw.code-fence.begin @@ -1798,7 +1798,7 @@ def function(): unclosed_paren = ( | ^ meta.group.python punctuation.section.group.begin.python ``` -|^^^ markup.raw.code-fence.python punctuation.definition.raw.code-fence.end +|^^ markup.raw.code-fence.python punctuation.definition.raw.code-fence.end ```Graphviz graph n {} From 48201e54581119f91a753d8d8f0494f055dca576 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Fri, 3 Nov 2017 12:47:55 +0200 Subject: [PATCH 03/12] [Markdown] allow highlighting "js" code fences as JavaScript --- Markdown/Markdown.sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index 41ea3785a9..1a3e18bb6d 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -964,7 +964,7 @@ contexts: - match: |- (?x) {{fenced_code_block_start}} - ((?i:javascript)) + ((?i:javascript|js)) \s*$ # any whitespace until EOL captures: 1: markup.raw.code-fence.javascript.markdown punctuation.definition.raw.code-fence.begin.markdown From 3eef4c1f4c3b9146069b5cbec76545bac1a6a3eb Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Sat, 4 Nov 2017 08:50:10 +0200 Subject: [PATCH 04/12] [Markdown] add Rust code fence --- Markdown/Markdown.sublime-syntax | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index 1a3e18bb6d..b059c3961d 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -1003,6 +1003,20 @@ contexts: escape_captures: 0: markup.raw.code-fence.csharp.markdown 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:rust)) + \s*$ # any whitespace until EOL + captures: + 1: markup.raw.code-fence.rust.markdown punctuation.definition.raw.code-fence.begin.markdown + 2: markup.raw.code-fence.rust.markdown constant.other.language-name.markdown + embed: scope:source.rust + embed_scope: markup.raw.code-fence.rust.markdown + escape: '^[ ]{,3}(\1)\s*$' + escape_captures: + 0: markup.raw.code-fence.rust.markdown + 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} From a86b8bc80736418f289f5a3528d7d3b070e11c38 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Tue, 7 Nov 2017 22:59:45 +0200 Subject: [PATCH 05/12] [Markdown] add code fence highlighting for bash shell --- Markdown/Markdown.sublime-syntax | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index b059c3961d..d93f7a69d3 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -1017,6 +1017,20 @@ contexts: escape_captures: 0: markup.raw.code-fence.rust.markdown 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:shell-script|sh|bash|zsh)) + \s*$ # any whitespace until EOL + captures: + 1: markup.raw.code-fence.shell-script.markdown punctuation.definition.raw.code-fence.begin.markdown + 2: markup.raw.code-fence.shell-script.markdown constant.other.language-name.markdown + embed: scope:source.shell.bash + embed_scope: markup.raw.code-fence.shell-script.markdown + escape: '^[ ]{,3}(\1)\s*$' + escape_captures: + 0: markup.raw.code-fence.shell-script.markdown + 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} From 2d08edaeaf7ff3973f7e2ab89f493a36abd554a2 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Tue, 7 Nov 2017 23:05:29 +0200 Subject: [PATCH 06/12] [Markdown] add code fence highlighting for PHP --- Markdown/Markdown.sublime-syntax | 28 ++++++++++++++++++++++++++++ Markdown/syntax_test_markdown.md | 15 +++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index d93f7a69d3..ab107a8029 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -1031,6 +1031,34 @@ contexts: escape_captures: 0: markup.raw.code-fence.shell-script.markdown 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:php|inc)) + \s*$ # any whitespace until EOL + captures: + 1: markup.raw.code-fence.php.markdown punctuation.definition.raw.code-fence.begin.markdown + 2: markup.raw.code-fence.php.markdown constant.other.language-name.markdown + embed: scope:source.php + embed_scope: markup.raw.code-fence.php.markdown + escape: '^[ ]{,3}(\1)\s*$' + escape_captures: + 0: markup.raw.code-fence.php.markdown + 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:html\+php)) + \s*$ # any whitespace until EOL + captures: + 1: markup.raw.code-fence.html-php.markdown punctuation.definition.raw.code-fence.begin.markdown + 2: markup.raw.code-fence.html-php.markdown constant.other.language-name.markdown + embed: scope:embedding.php + embed_scope: markup.raw.code-fence.html-php.markdown + escape: '^[ ]{,3}(\1)\s*$' + escape_captures: + 0: markup.raw.code-fence.html-php.markdown + 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} diff --git a/Markdown/syntax_test_markdown.md b/Markdown/syntax_test_markdown.md index e6bc214674..7171ad83eb 100644 --- a/Markdown/syntax_test_markdown.md +++ b/Markdown/syntax_test_markdown.md @@ -1806,3 +1806,18 @@ graph n {} ``` | <- - markup.raw + +```php +var_dump(expression); +| ^^^^^^ support.function.var.php +``` + +```html+php +
+|^^^ entity.name.tag.block.any.html + Date: Sat, 2 Dec 2017 22:46:17 +0200 Subject: [PATCH 07/12] [Markdown] add codefence support for more languages --- Markdown/Markdown.sublime-syntax | 186 ++++++++++++++++++++++++------- 1 file changed, 147 insertions(+), 39 deletions(-) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index ab107a8029..53079d595b 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -112,7 +112,8 @@ variables: ) fenced_code_block_start: |- (?x: - [ ]{0,3} # up to 3 spaces + [ ]* + ([ ]{0,3}) # up to 3 spaces ( `{3,} # 3 or more backticks (?![^`]*`) # not followed by any more backticks on the same line @@ -121,6 +122,15 @@ variables: (?![^~]*~) # not followed by any more tildas on the same line ) ) + code_fence_escape: |- + (?x: + ^ # the beginning of the line + #\1 # whitespace previously captured + #[ ]{0,3} # up to 3 spaces - doesn't have to be the same as the opening fence, but within 3 spaces + [ ]* + (\2) # the backtick/tilde combination that opened the code fence + \s*$ # any amount of whitespace until EOL + ) html_tag_open_commonmark: |- (?xi: < @@ -854,7 +864,7 @@ contexts: - include: block-quote - match: $ pop: true - - match: '^(?=\s+{{fenced_code_block_start}})' + - match: '^(?={{fenced_code_block_start}})' push: - include: fenced-code-block - match: '' @@ -888,7 +898,7 @@ contexts: pop: true list-content: - meta_content_scope: meta.paragraph.list.markdown - - match: ^\s*(?={{fenced_code_block_start}}) + - match: ^(?={{fenced_code_block_start}}) push: - match: $ pop: true @@ -911,11 +921,11 @@ contexts: ((?i:xml)) \s*$ # any whitespace until EOL captures: - 1: markup.raw.code-fence.xml.markdown punctuation.definition.raw.code-fence.begin.markdown - 2: markup.raw.code-fence.xml.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.xml.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.xml.markdown constant.other.language-name.markdown embed: scope:text.xml embed_scope: markup.raw.code-fence.xml.markdown - escape: '^[ ]{,3}(\1)\s*$' + escape: '{{code_fence_escape}}' escape_captures: 0: markup.raw.code-fence.xml.markdown 1: punctuation.definition.raw.code-fence.end.markdown @@ -925,11 +935,11 @@ contexts: ((?i:sql)) \s*$ # any whitespace until EOL captures: - 1: markup.raw.code-fence.sql.markdown punctuation.definition.raw.code-fence.begin.markdown - 2: markup.raw.code-fence.sql.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.sql.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.sql.markdown constant.other.language-name.markdown embed: scope:source.sql embed_scope: markup.raw.code-fence.sql.markdown - escape: '^[ ]{,3}(\1)\s*$' + escape: '{{code_fence_escape}}' escape_captures: 0: markup.raw.code-fence.sql.markdown 1: punctuation.definition.raw.code-fence.end.markdown @@ -939,11 +949,11 @@ contexts: ((?i:python|py)) \s*$ # any whitespace until EOL captures: - 1: markup.raw.code-fence.python.markdown punctuation.definition.raw.code-fence.begin.markdown - 2: markup.raw.code-fence.python.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.python.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.python.markdown constant.other.language-name.markdown embed: scope:source.python embed_scope: markup.raw.code-fence.python.markdown - escape: '^[ ]{,3}(\1)\s*$' + escape: '{{code_fence_escape}}' escape_captures: 0: markup.raw.code-fence.python.markdown 1: punctuation.definition.raw.code-fence.end.markdown @@ -953,11 +963,11 @@ contexts: ((?i:graphviz)) \s*$ # any whitespace until EOL captures: - 1: markup.raw.code-fence.graphviz.markdown punctuation.definition.raw.code-fence.begin.markdown - 2: markup.raw.code-fence.graphviz.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.graphviz.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.graphviz.markdown constant.other.language-name.markdown embed: scope:source.dot embed_scope: markup.raw.code-fence.graphviz.markdown - escape: '^[ ]{,3}(\1)\s*$' + escape: '{{code_fence_escape}}' escape_captures: 0: markup.raw.code-fence.graphviz.markdown 1: punctuation.definition.raw.code-fence.end.markdown @@ -967,11 +977,11 @@ contexts: ((?i:javascript|js)) \s*$ # any whitespace until EOL captures: - 1: markup.raw.code-fence.javascript.markdown punctuation.definition.raw.code-fence.begin.markdown - 2: markup.raw.code-fence.javascript.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.javascript.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.javascript.markdown constant.other.language-name.markdown embed: scope:source.javascript embed_scope: markup.raw.code-fence.javascript.markdown - escape: '^[ ]{,3}(\1)\s*$' + escape: '{{code_fence_escape}}' escape_captures: 0: markup.raw.code-fence.javascript.markdown 1: punctuation.definition.raw.code-fence.end.markdown @@ -981,11 +991,11 @@ contexts: ((?i:java)) \s*$ # any whitespace until EOL captures: - 1: markup.raw.code-fence.java.markdown punctuation.definition.raw.code-fence.begin.markdown - 2: markup.raw.code-fence.java.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.java.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.java.markdown constant.other.language-name.markdown embed: scope:source.java embed_scope: markup.raw.code-fence.java.markdown - escape: '^[ ]{,3}(\1)\s*$' + escape: '{{code_fence_escape}}' escape_captures: 0: markup.raw.code-fence.java.markdown 1: punctuation.definition.raw.code-fence.end.markdown @@ -995,11 +1005,11 @@ contexts: ((?i:csharp|c\#|cs)) \s*$ # any whitespace until EOL captures: - 1: markup.raw.code-fence.csharp.markdown punctuation.definition.raw.code-fence.begin.markdown - 2: markup.raw.code-fence.csharp.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.csharp.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.csharp.markdown constant.other.language-name.markdown embed: scope:source.cs embed_scope: markup.raw.code-fence.csharp.markdown - escape: '^[ ]{,3}(\1)\s*$' + escape: '{{code_fence_escape}}' escape_captures: 0: markup.raw.code-fence.csharp.markdown 1: punctuation.definition.raw.code-fence.end.markdown @@ -1009,11 +1019,11 @@ contexts: ((?i:rust)) \s*$ # any whitespace until EOL captures: - 1: markup.raw.code-fence.rust.markdown punctuation.definition.raw.code-fence.begin.markdown - 2: markup.raw.code-fence.rust.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.rust.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.rust.markdown constant.other.language-name.markdown embed: scope:source.rust embed_scope: markup.raw.code-fence.rust.markdown - escape: '^[ ]{,3}(\1)\s*$' + escape: '{{code_fence_escape}}' escape_captures: 0: markup.raw.code-fence.rust.markdown 1: punctuation.definition.raw.code-fence.end.markdown @@ -1023,11 +1033,11 @@ contexts: ((?i:shell-script|sh|bash|zsh)) \s*$ # any whitespace until EOL captures: - 1: markup.raw.code-fence.shell-script.markdown punctuation.definition.raw.code-fence.begin.markdown - 2: markup.raw.code-fence.shell-script.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.shell-script.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.shell-script.markdown constant.other.language-name.markdown embed: scope:source.shell.bash embed_scope: markup.raw.code-fence.shell-script.markdown - escape: '^[ ]{,3}(\1)\s*$' + escape: '{{code_fence_escape}}' escape_captures: 0: markup.raw.code-fence.shell-script.markdown 1: punctuation.definition.raw.code-fence.end.markdown @@ -1037,11 +1047,11 @@ contexts: ((?i:php|inc)) \s*$ # any whitespace until EOL captures: - 1: markup.raw.code-fence.php.markdown punctuation.definition.raw.code-fence.begin.markdown - 2: markup.raw.code-fence.php.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.php.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.php.markdown constant.other.language-name.markdown embed: scope:source.php embed_scope: markup.raw.code-fence.php.markdown - escape: '^[ ]{,3}(\1)\s*$' + escape: '{{code_fence_escape}}' escape_captures: 0: markup.raw.code-fence.php.markdown 1: punctuation.definition.raw.code-fence.end.markdown @@ -1051,25 +1061,123 @@ contexts: ((?i:html\+php)) \s*$ # any whitespace until EOL captures: - 1: markup.raw.code-fence.html-php.markdown punctuation.definition.raw.code-fence.begin.markdown - 2: markup.raw.code-fence.html-php.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.html-php.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.html-php.markdown constant.other.language-name.markdown embed: scope:embedding.php embed_scope: markup.raw.code-fence.html-php.markdown - escape: '^[ ]{,3}(\1)\s*$' + escape: '{{code_fence_escape}}' escape_captures: 0: markup.raw.code-fence.html-php.markdown 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:rscript|r|splus)) + \s*$ # any whitespace until EOL + captures: + 2: markup.raw.code-fence.r.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.r.markdown constant.other.language-name.markdown + embed: scope:source.r + embed_scope: markup.raw.code-fence.r.markdown + escape: '{{code_fence_escape}}' + escape_captures: + 0: markup.raw.code-fence.r.markdown + 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:golang)) + \s*$ # any whitespace until EOL + captures: + 2: markup.raw.code-fence.go.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.go.markdown constant.other.language-name.markdown + embed: scope:source.go + embed_scope: markup.raw.code-fence.go.markdown + escape: '{{code_fence_escape}}' + escape_captures: + 0: markup.raw.code-fence.go.markdown + 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:ruby|rb|rbx)) + \s*$ # any whitespace until EOL + captures: + 2: markup.raw.code-fence.ruby.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.ruby.markdown constant.other.language-name.markdown + embed: scope:source.ruby + embed_scope: markup.raw.code-fence.ruby.markdown + escape: '{{code_fence_escape}}' + escape_captures: + 0: markup.raw.code-fence.ruby.markdown + 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:objc|obj-c|objectivec|objective-c)) + \s*$ # any whitespace until EOL + captures: + 2: markup.raw.code-fence.objc.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.objc.markdown constant.other.language-name.markdown + embed: scope:source.objc + embed_scope: markup.raw.code-fence.objc.markdown + escape: '{{code_fence_escape}}' + escape_captures: + 0: markup.raw.code-fence.objc.markdown + 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:objc\+\+|obj-c\+\+|objectivec\+\+|objective-c\+\+)) + \s*$ # any whitespace until EOL + captures: + 2: markup.raw.code-fence.objc++.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.objc++.markdown constant.other.language-name.markdown + embed: scope:source.objc++ + embed_scope: markup.raw.code-fence.objc++.markdown + escape: '{{code_fence_escape}}' + escape_captures: + 0: markup.raw.code-fence.objc++.markdown + 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:c)) + \s*$ # any whitespace until EOL + captures: + 2: markup.raw.code-fence.c.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.c.markdown constant.other.language-name.markdown + embed: scope:source.c + embed_scope: markup.raw.code-fence.c.markdown + escape: '{{code_fence_escape}}' + escape_captures: + 0: markup.raw.code-fence.c.markdown + 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:c\+\+|cpp)) + \s*$ # any whitespace until EOL + captures: + 2: markup.raw.code-fence.c++.markdown punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.c++.markdown constant.other.language-name.markdown + embed: scope:source.c++ + embed_scope: markup.raw.code-fence.c++.markdown + escape: '{{code_fence_escape}}' + escape_captures: + 0: markup.raw.code-fence.c++.markdown + 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ([\w-]*) # any number of word characters or dashes .*$ # all characters until EOL captures: - 1: punctuation.definition.raw.code-fence.begin.markdown - 2: constant.other.language-name.markdown + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown push: - meta_scope: markup.raw.code-fence.markdown - - match: '[ ]{,3}(\1)\s*$' + - match: '{{code_fence_escape}}' captures: 1: punctuation.definition.raw.code-fence.end.markdown pop: true From 6eb9494c4199f63873d9977dd3f10f47771a3786 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Thu, 1 Feb 2018 15:29:13 +0200 Subject: [PATCH 08/12] [Markdown] add regexp code block highlighting --- Markdown/Markdown.sublime-syntax | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index 53079d595b..b4d8999073 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -1167,6 +1167,20 @@ contexts: escape_captures: 0: markup.raw.code-fence.c++.markdown 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:regexp|regex)) + \s*$ # any whitespace until EOL + captures: + 1: markup.raw.code-fence.regexp.markdown punctuation.definition.raw.code-fence.begin.markdown + 2: markup.raw.code-fence.regexp.markdown constant.other.language-name.markdown + embed: scope:source.regexp + embed_scope: markup.raw.code-fence.regexp.markdown + escape: '^[ ]{,3}(\1)\s*$' + escape_captures: + 0: markup.raw.code-fence.regexp.markdown + 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} From 1382bc4ae46334a8b36429d481732843c3de4d1f Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Sat, 10 Feb 2018 14:50:22 +0200 Subject: [PATCH 09/12] [Markdown] scope code fences with GFM suffix --- Markdown/Markdown.sublime-syntax | 154 +++++++++++++++---------------- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index b4d8999073..6becdd3dad 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -921,13 +921,13 @@ contexts: ((?i:xml)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.xml.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.xml.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.xml.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.xml.markdown-gfm constant.other.language-name.markdown embed: scope:text.xml - embed_scope: markup.raw.code-fence.xml.markdown + embed_scope: markup.raw.code-fence.xml.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.xml.markdown + 0: markup.raw.code-fence.xml.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -935,13 +935,13 @@ contexts: ((?i:sql)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.sql.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.sql.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.sql.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.sql.markdown-gfm constant.other.language-name.markdown embed: scope:source.sql - embed_scope: markup.raw.code-fence.sql.markdown + embed_scope: markup.raw.code-fence.sql.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.sql.markdown + 0: markup.raw.code-fence.sql.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -949,13 +949,13 @@ contexts: ((?i:python|py)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.python.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.python.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.python.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.python.markdown-gfm constant.other.language-name.markdown embed: scope:source.python - embed_scope: markup.raw.code-fence.python.markdown + embed_scope: markup.raw.code-fence.python.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.python.markdown + 0: markup.raw.code-fence.python.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -963,13 +963,13 @@ contexts: ((?i:graphviz)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.graphviz.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.graphviz.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.graphviz.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.graphviz.markdown-gfm constant.other.language-name.markdown embed: scope:source.dot - embed_scope: markup.raw.code-fence.graphviz.markdown + embed_scope: markup.raw.code-fence.graphviz.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.graphviz.markdown + 0: markup.raw.code-fence.graphviz.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -977,13 +977,13 @@ contexts: ((?i:javascript|js)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.javascript.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.javascript.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.javascript.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.javascript.markdown-gfm constant.other.language-name.markdown embed: scope:source.javascript - embed_scope: markup.raw.code-fence.javascript.markdown + embed_scope: markup.raw.code-fence.javascript.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.javascript.markdown + 0: markup.raw.code-fence.javascript.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -991,13 +991,13 @@ contexts: ((?i:java)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.java.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.java.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.java.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.java.markdown-gfm constant.other.language-name.markdown embed: scope:source.java - embed_scope: markup.raw.code-fence.java.markdown + embed_scope: markup.raw.code-fence.java.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.java.markdown + 0: markup.raw.code-fence.java.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -1005,13 +1005,13 @@ contexts: ((?i:csharp|c\#|cs)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.csharp.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.csharp.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.csharp.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.csharp.markdown-gfm constant.other.language-name.markdown embed: scope:source.cs - embed_scope: markup.raw.code-fence.csharp.markdown + embed_scope: markup.raw.code-fence.csharp.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.csharp.markdown + 0: markup.raw.code-fence.csharp.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -1019,13 +1019,13 @@ contexts: ((?i:rust)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.rust.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.rust.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.rust.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.rust.markdown-gfm constant.other.language-name.markdown embed: scope:source.rust - embed_scope: markup.raw.code-fence.rust.markdown + embed_scope: markup.raw.code-fence.rust.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.rust.markdown + 0: markup.raw.code-fence.rust.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -1033,13 +1033,13 @@ contexts: ((?i:shell-script|sh|bash|zsh)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.shell-script.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.shell-script.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.shell-script.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.shell-script.markdown-gfm constant.other.language-name.markdown embed: scope:source.shell.bash - embed_scope: markup.raw.code-fence.shell-script.markdown + embed_scope: markup.raw.code-fence.shell-script.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.shell-script.markdown + 0: markup.raw.code-fence.shell-script.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -1047,13 +1047,13 @@ contexts: ((?i:php|inc)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.php.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.php.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.php.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.php.markdown-gfm constant.other.language-name.markdown embed: scope:source.php - embed_scope: markup.raw.code-fence.php.markdown + embed_scope: markup.raw.code-fence.php.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.php.markdown + 0: markup.raw.code-fence.php.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -1061,13 +1061,13 @@ contexts: ((?i:html\+php)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.html-php.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.html-php.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.html-php.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.html-php.markdown-gfm constant.other.language-name.markdown embed: scope:embedding.php - embed_scope: markup.raw.code-fence.html-php.markdown + embed_scope: markup.raw.code-fence.html-php.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.html-php.markdown + 0: markup.raw.code-fence.html-php.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -1075,13 +1075,13 @@ contexts: ((?i:rscript|r|splus)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.r.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.r.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.r.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.r.markdown-gfm constant.other.language-name.markdown embed: scope:source.r - embed_scope: markup.raw.code-fence.r.markdown + embed_scope: markup.raw.code-fence.r.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.r.markdown + 0: markup.raw.code-fence.r.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -1089,13 +1089,13 @@ contexts: ((?i:golang)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.go.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.go.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.go.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.go.markdown-gfm constant.other.language-name.markdown embed: scope:source.go - embed_scope: markup.raw.code-fence.go.markdown + embed_scope: markup.raw.code-fence.go.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.go.markdown + 0: markup.raw.code-fence.go.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -1103,13 +1103,13 @@ contexts: ((?i:ruby|rb|rbx)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.ruby.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.ruby.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.ruby.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.ruby.markdown-gfm constant.other.language-name.markdown embed: scope:source.ruby - embed_scope: markup.raw.code-fence.ruby.markdown + embed_scope: markup.raw.code-fence.ruby.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.ruby.markdown + 0: markup.raw.code-fence.ruby.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -1117,13 +1117,13 @@ contexts: ((?i:objc|obj-c|objectivec|objective-c)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.objc.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.objc.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.objc.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.objc.markdown-gfm constant.other.language-name.markdown embed: scope:source.objc - embed_scope: markup.raw.code-fence.objc.markdown + embed_scope: markup.raw.code-fence.objc.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.objc.markdown + 0: markup.raw.code-fence.objc.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -1131,13 +1131,13 @@ contexts: ((?i:objc\+\+|obj-c\+\+|objectivec\+\+|objective-c\+\+)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.objc++.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.objc++.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.objc++.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.objc++.markdown-gfm constant.other.language-name.markdown embed: scope:source.objc++ - embed_scope: markup.raw.code-fence.objc++.markdown + embed_scope: markup.raw.code-fence.objc++.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.objc++.markdown + 0: markup.raw.code-fence.objc++.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -1145,13 +1145,13 @@ contexts: ((?i:c)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.c.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.c.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.c.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.c.markdown-gfm constant.other.language-name.markdown embed: scope:source.c - embed_scope: markup.raw.code-fence.c.markdown + embed_scope: markup.raw.code-fence.c.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.c.markdown + 0: markup.raw.code-fence.c.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -1159,13 +1159,13 @@ contexts: ((?i:c\+\+|cpp)) \s*$ # any whitespace until EOL captures: - 2: markup.raw.code-fence.c++.markdown punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.c++.markdown constant.other.language-name.markdown + 2: markup.raw.code-fence.c++.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 3: markup.raw.code-fence.c++.markdown-gfm constant.other.language-name.markdown embed: scope:source.c++ - embed_scope: markup.raw.code-fence.c++.markdown + embed_scope: markup.raw.code-fence.c++.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.c++.markdown + 0: markup.raw.code-fence.c++.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -1173,13 +1173,13 @@ contexts: ((?i:regexp|regex)) \s*$ # any whitespace until EOL captures: - 1: markup.raw.code-fence.regexp.markdown punctuation.definition.raw.code-fence.begin.markdown - 2: markup.raw.code-fence.regexp.markdown constant.other.language-name.markdown + 1: markup.raw.code-fence.regexp.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown + 2: markup.raw.code-fence.regexp.markdown-gfm constant.other.language-name.markdown embed: scope:source.regexp - embed_scope: markup.raw.code-fence.regexp.markdown + embed_scope: markup.raw.code-fence.regexp.markdown-gfm escape: '^[ ]{,3}(\1)\s*$' escape_captures: - 0: markup.raw.code-fence.regexp.markdown + 0: markup.raw.code-fence.regexp.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) @@ -1190,7 +1190,7 @@ contexts: 2: punctuation.definition.raw.code-fence.begin.markdown 3: constant.other.language-name.markdown push: - - meta_scope: markup.raw.code-fence.markdown + - meta_scope: markup.raw.code-fence.markdown-gfm - match: '{{code_fence_escape}}' captures: 1: punctuation.definition.raw.code-fence.end.markdown From b75bdd76fe2525da27225564331d82fac158535d Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Thu, 22 Mar 2018 13:32:55 +0200 Subject: [PATCH 10/12] [Markdown] don't scope the code fence punctuation as markup.raw --- Markdown/Markdown.sublime-syntax | 179 +++++++++++++++++-------------- Markdown/syntax_test_markdown.md | 21 ++-- 2 files changed, 114 insertions(+), 86 deletions(-) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index 8bcf457c15..ad9c01223c 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -919,280 +919,301 @@ contexts: (?x) {{fenced_code_block_start}} ((?i:xml)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.xml.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.xml.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.xml.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:text.xml embed_scope: markup.raw.code-fence.xml.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.xml.markdown-gfm + 0: meta.code-fence.definition.end.xml.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:sql)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.sql.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.sql.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.sql.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.sql embed_scope: markup.raw.code-fence.sql.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.sql.markdown-gfm + 0: meta.code-fence.definition.end.sql.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:python|py)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.python.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.python.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.python.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.python embed_scope: markup.raw.code-fence.python.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.python.markdown-gfm + 0: meta.code-fence.definition.end.python.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:graphviz)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.graphviz.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.graphviz.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.graphviz.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.dot embed_scope: markup.raw.code-fence.graphviz.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.graphviz.markdown-gfm + 0: meta.code-fence.definition.end.graphviz.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:javascript|js)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.javascript.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.javascript.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.javascript.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.javascript embed_scope: markup.raw.code-fence.javascript.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.javascript.markdown-gfm + 0: meta.code-fence.definition.end.javascript.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:java)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.java.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.java.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.java.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.java embed_scope: markup.raw.code-fence.java.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.java.markdown-gfm + 0: meta.code-fence.definition.end.java.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:csharp|c\#|cs)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.csharp.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.csharp.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.csharp.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.cs embed_scope: markup.raw.code-fence.csharp.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.csharp.markdown-gfm + 0: meta.code-fence.definition.end.csharp.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:rust)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.rust.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.rust.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.rust.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.rust embed_scope: markup.raw.code-fence.rust.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.rust.markdown-gfm + 0: meta.code-fence.definition.end.rust.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:shell-script|sh|bash|zsh)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.shell-script.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.shell-script.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.shell-script.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.shell.bash embed_scope: markup.raw.code-fence.shell-script.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.shell-script.markdown-gfm + 0: meta.code-fence.definition.end.shell-script.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:php|inc)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.php.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.php.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.php.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.php embed_scope: markup.raw.code-fence.php.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.php.markdown-gfm + 0: meta.code-fence.definition.end.php.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:html\+php)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.html-php.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.html-php.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.html-php.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:embedding.php embed_scope: markup.raw.code-fence.html-php.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.html-php.markdown-gfm + 0: meta.code-fence.definition.end.html-php.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:rscript|r|splus)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.r.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.r.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.r.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.r embed_scope: markup.raw.code-fence.r.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.r.markdown-gfm + 0: meta.code-fence.definition.end.r.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:golang)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.go.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.go.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.go.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.go embed_scope: markup.raw.code-fence.go.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.go.markdown-gfm + 0: meta.code-fence.definition.end.go.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:ruby|rb|rbx)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.ruby.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.ruby.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.ruby.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.ruby embed_scope: markup.raw.code-fence.ruby.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.ruby.markdown-gfm + 0: meta.code-fence.definition.end.ruby.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:objc|obj-c|objectivec|objective-c)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.objc.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.objc.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.objc.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.objc embed_scope: markup.raw.code-fence.objc.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.objc.markdown-gfm + 0: meta.code-fence.definition.end.objc.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:objc\+\+|obj-c\+\+|objectivec\+\+|objective-c\+\+)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.objc++.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.objc++.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.objc++.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.objc++ embed_scope: markup.raw.code-fence.objc++.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.objc++.markdown-gfm + 0: meta.code-fence.definition.end.objc++.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:c)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.c.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.c.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.c.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.c embed_scope: markup.raw.code-fence.c.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.c.markdown-gfm + 0: meta.code-fence.definition.end.c.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:c\+\+|cpp)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 2: markup.raw.code-fence.c++.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 3: markup.raw.code-fence.c++.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.c++.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.c++ embed_scope: markup.raw.code-fence.c++.markdown-gfm escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.c++.markdown-gfm + 0: meta.code-fence.definition.end.c++.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ((?i:regexp|regex)) - \s*$ # any whitespace until EOL + \s*$\n? # any whitespace until EOL captures: - 1: markup.raw.code-fence.regexp.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - 2: markup.raw.code-fence.regexp.markdown-gfm constant.other.language-name.markdown + 0: meta.code-fence.definition.begin.regexp.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown embed: scope:source.regexp embed_scope: markup.raw.code-fence.regexp.markdown-gfm - escape: '^[ ]{,3}(\1)\s*$' + escape: '{{code_fence_escape}}' escape_captures: - 0: markup.raw.code-fence.regexp.markdown-gfm + 0: meta.code-fence.definition.end.regexp.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} ([\w-]*) # any number of word characters or dashes - .*$ # all characters until EOL + .*$\n? # all characters until EOL captures: + 0: meta.code-fence.definition.begin.text.markdown-gfm 2: punctuation.definition.raw.code-fence.begin.markdown 3: constant.other.language-name.markdown push: - - meta_scope: markup.raw.code-fence.markdown-gfm + - meta_content_scope: markup.raw.code-fence.markdown-gfm - match: '{{code_fence_escape}}' captures: + 0: meta.code-fence.definition.end.text.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown pop: true code-span: diff --git a/Markdown/syntax_test_markdown.md b/Markdown/syntax_test_markdown.md index ac98565ca9..5be0035001 100644 --- a/Markdown/syntax_test_markdown.md +++ b/Markdown/syntax_test_markdown.md @@ -1562,7 +1562,7 @@ paragraph |^^^^^^^^^^^^^^^ meta.paragraph.list | ^^^ punctuation.definition.raw.code-fence.begin | ^^^^^^^^ constant.other.language-name -| ^^^^^^^^^^^ markup.raw.code-fence +| ^^^^^^^^^^^ meta.code-fence |^^^^ meta.paragraph.list markup.raw.code-fence ``` @@ -1771,7 +1771,7 @@ okay 1. Test ```python -| ^^^ markup.list.numbered markup.raw.code-fence punctuation.definition.raw.code-fence.begin +| ^^^ markup.list.numbered meta.code-fence punctuation.definition.raw.code-fence.begin Test | <- - invalid @@ -1783,7 +1783,7 @@ okay |^ markup.list.numbered.bullet punctuation.definition.list_item ```xml -|^^^^^ markup.raw.code-fence.xml +|^^^^^ meta.code-fence.definition.begin.xml | ^^^ constant.other.language-name |^^^^^^^^^^^^^^^^^^^^^^ markup.raw.code-fence.xml @@ -1795,18 +1795,18 @@ okay |^^ punctuation.definition.raw.code-fence.end ```sql -|^^^^^ markup.raw.code-fence.sql +|^^^^^ meta.code-fence.definition.begin.sql | ^^^ constant.other.language-name SELECT TOP 10 * |^^^^^^^^^^^^^^^ markup.raw.code-fence.sql |^^^^^^^^^ keyword.other.DML.sql FROM TableName ``` -|^^ markup.raw.code-fence.sql punctuation.definition.raw.code-fence.end +|^^ meta.code-fence.definition.end.sql punctuation.definition.raw.code-fence.end - markup ```python |^^ punctuation.definition.raw.code-fence.begin -|^^^^^^^^ markup.raw.code-fence.python +|^^^^^^^^^ meta.code-fence.definition.begin.python - markup | ^^^^^^ constant.other.language-name def function(): pass @@ -1814,7 +1814,7 @@ def function(): unclosed_paren = ( | ^ meta.group.python punctuation.section.group.begin.python ``` -|^^ markup.raw.code-fence.python punctuation.definition.raw.code-fence.end +|^^ meta.code-fence.definition.end.python punctuation.definition.raw.code-fence.end ```Graphviz graph n {} @@ -1837,3 +1837,10 @@ var_dump(expression); | ^^^^^^ support.function.var.php ``` |^^ punctuation.definition.raw.code-fence.end.markdown + +```regex +(?x) +\s+ +``` +|^^^ meta.paragraph meta.code-fence.definition.end.regexp - markup +|^^ punctuation.definition.raw.code-fence.end From a1771a4771041013bf05d418f48b67fb8d95cc1f Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Sun, 1 Apr 2018 08:03:55 +0300 Subject: [PATCH 11/12] [Markdown] add json to syntax highlighted code fence support --- Markdown/Markdown.sublime-syntax | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index ad9c01223c..bb495fa675 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -990,6 +990,21 @@ contexts: escape_captures: 0: meta.code-fence.definition.end.javascript.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + ((?i:json)) + \s*$\n? # any whitespace until EOL + captures: + 0: meta.code-fence.definition.begin.json.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 3: constant.other.language-name.markdown + embed: scope:source.json + embed_scope: markup.raw.code-fence.json.markdown-gfm + escape: '{{code_fence_escape}}' + escape_captures: + 0: meta.code-fence.definition.end.json.markdown-gfm + 1: punctuation.definition.raw.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} From 2816db2ddea350ff3ec887b9f069ba7920e592d0 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Tue, 10 Apr 2018 12:11:19 +0300 Subject: [PATCH 12/12] [Markdown] add syntax tests for bash (prototype context in) code fences --- Markdown/syntax_test_markdown.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Markdown/syntax_test_markdown.md b/Markdown/syntax_test_markdown.md index ac89d13ed9..49f4a1255f 100644 --- a/Markdown/syntax_test_markdown.md +++ b/Markdown/syntax_test_markdown.md @@ -1926,3 +1926,13 @@ var_dump(expression); ``` |^^^ meta.paragraph meta.code-fence.definition.end.regexp - markup |^^ punctuation.definition.raw.code-fence.end + +```bash +# test +| ^^^^^ source.shell comment.line.number-sign +echo hello, \ +| ^^ punctuation.separator.continuation.line +echo This is a smiley :-\) \(I have to escape the parentheses, though!\) +| ^^ constant.character.escape +``` +| <- meta.code-fence.definition.end.shell-script punctuation.definition.raw.code-fence.end