diff --git a/R Markdown.sublime-syntax b/R Markdown.sublime-syntax index 4acfd2b..873b4c1 100644 --- a/R Markdown.sublime-syntax +++ b/R Markdown.sublime-syntax @@ -8,11 +8,7 @@ file_extensions: - rmarkdown - rmarkdn scope: text.html.markdown.rmarkdown -comment: |- - this definition aims to meet CommonMark specifications http://spec.commonmark.org/ - with GitHub Formatted Markdown extensions https://github.github.com/gfm/ - and has a few extras like Markdown Extra's footnotes https://michelf.ca/projects/php-markdown/extra/#footnotes - the scope suffix should indicate which flavor of Markdown the feature came from, to help make this syntax definition easier to maintain +comment: this definition aims to (eventually) meet CommonMark specifications http://spec.commonmark.org/ with GitHub Formatted Markdown extensions https://github.github.com/gfm/ variables: thematic_break: |- (?x: @@ -28,6 +24,14 @@ variables: atx_heading: (?:[#]{1,6}\s*) # between 1 and 6 hashes, followed by any amount of whitespace indented_code_block: (?:[ ]{4}|\t) # 4 spaces or a tab list_item: (?:[ ]{,3}(?=\d+\.|[*+-])\d*([*+.-])\s) # between 0 and 3 spaces, followed by either: at least one integer and a full stop, or (a star, plus or dash), followed by whitespace + link_title: |- + (?x:[ \t]* # Optional whitespace + (?: + ((\().+?(\))) # Match title in parens… + | ((")[^"]+(")) # or in double quotes… + | ((')[^']+(')) # or in single quotes. + )? # Title is optional + ) escape: '\\[-`*_#+.!(){}\[\]\\>|]' backticks: |- (?x: @@ -48,6 +52,15 @@ variables: )*\] # closing square bracket )+ # at least one character ) + url_and_title: |- + (?x: + ([ ])? # Space not allowed, but we check for it anyway to mark it as invalid + (\() # Opening paren for url + (?) # The url + {{link_title}} # Optional title + \s* # Optional whitespace + (\)) + ) html_entity: '&([a-zA-Z0-9]+|#\d+|#x\h+);' skip_html_tags: (?:<[^>]+>) balance_square_brackets_and_emphasis: |- @@ -62,11 +75,11 @@ variables: )*\] # closing square bracket )+ # at least one character ) - balance_square_brackets_pipes_and_emphasis: |- + balance_square_brackets_and_pipes: |- (?x: (?: {{escape}}+ # escape characters - | [^\[\]`\\_*|]+(?=[\[\]`\\_*|]|$) # anything that isn't a square bracket, a backtick, the start of an escape character, or an emphasis character + | [^\[\]`\\|]+(?=[\[\]`\\|]|$) # anything that isn't a square bracket, a backtick, the start of an escape character, or a pipe | {{backticks}} # inline code | \[(?: # nested square brackets (one level deep) [^\[\]`]+(?=[\[\]`]) # anything that isn't a square bracket or a backtick @@ -74,29 +87,14 @@ variables: )*\] # closing square bracket )+ # at least one character ) - balanced_emphasis: |- - (?x: - \* (?!\*){{balance_square_brackets_and_emphasis}}+\* (?!\*) - | \*\* {{balance_square_brackets_and_emphasis}}+\*\* - | _ (?!_) {{balance_square_brackets_and_emphasis}}+_ (?!_) - | __ {{balance_square_brackets_and_emphasis}}+__ - ) - balanced_table_cell: |- # Pipes inside other inline spans (such as emphasis, code, etc.) will not break a cell, emphasis in table cells can't span multiple lines - (?x: - (?: - {{balance_square_brackets_pipes_and_emphasis}} - | {{balanced_emphasis}} - )+ # at least one character - ) table_first_row: |- (?x: - (?:{{balanced_table_cell}}?\|){2} # at least 2 non-escaped pipe chars on the line - | (?!\s+\|){{balanced_table_cell}}\|(?!\s+$) # something other than whitespace followed by a pipe char, followed by something other than whitespace and the end of the line + (?:{{balance_square_brackets_and_pipes}}?\|){2} # at least 2 non-escaped pipe chars on the line + | (?!\s+\|){{balance_square_brackets_and_pipes}}\|(?!\s+$) # something other than whitespace followed by a pipe char, followed by something other than whitespace and the end of the line ) 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 @@ -105,67 +103,9 @@ 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: - < - [a-z] # A tag name consists of an ASCII letter - [a-z0-9-]* # followed by zero or more ASCII letters, digits, or hyphens (-) - (?: # An attribute consists of whitespace, an attribute name, and an optional attribute value specification - \s+ - [a-z_:] # An attribute name consists of an ASCII letter, _, or : - [a-z0-9_.:-]* # followed by zero or more ASCII letters, digits, _, ., :, or - - (?: # An attribute value specification consists of optional whitespace, a = character, optional whitespace, and an attribute value - \s* - = - \s* - (?: - [^ @'=<>`]+ # An unquoted attribute value is a nonempty string of characters not including spaces, ", ', =, <, >, or ` - | '[^']*' # A single-quoted attribute value consists of ', zero or more characters not including ', and a final ' - | "[^"]*" # A double-quoted attribute value consists of ", zero or more characters not including ", and a final " - ) - )? - )* - \s* - /? - > - ) - html_tag_close_commonmark: |- - (?xi: - - ) - html_tag_block_end_at_close_tag: |- - (?xi: - (script|style|pre)\b - ) - html_tag_block_end_at_blank_line: |- - (?x: - /? - (?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: (?=^\s*(?:---|\+\+\+)\s*$) + - match: (?=^\s*---\s*$) push: front-matter - match: "" set: body @@ -173,19 +113,16 @@ contexts: - match: ^\s*(---)\s*$ captures: 1: punctuation.definition.frontmatter - embed: scope:source.yaml - embed_scope: markup.raw.yaml.front-matter - escape: ^\s*(---)\s*$ - escape_captures: - 1: punctuation.definition.frontmatter - - match: ^\s*(\+\+\+)\s*$ - captures: - 1: punctuation.definition.frontmatter - embed: scope:source.toml - embed_scope: markup.raw.toml.front-matter - escape: ^\s*(\+\+\+)\s*$ - escape_captures: - 1: punctuation.definition.frontmatter + with_prototype: + - include: scope:source.yaml#prototype + push: + - meta_scope: markup.raw.yaml.front-matter + - meta_content_scope: source.yaml + - match: ^\s*(---)\s*$ + captures: + 1: punctuation.definition.frontmatter + pop: true + - include: scope:source.yaml - match: "" pop: true set: body @@ -230,44 +167,13 @@ contexts: - match: ^(?=\S) pop: true - include: list-paragraph - - match: '^[ ]{0,3}(?=<((?i:pre))\b)' + - match: '^(?=<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b)' comment: Markdown formatting is disabled inside block-level tags. - push: [disabled-markdown-pop-at-eol, disable-markdown-pop-at-tag] - - match: '^[ ]{0,3}(?=<{{html_tag_block_end_at_close_tag}})' - comment: Markdown formatting is disabled inside block-level tags. - push: [disabled-markdown-pop-at-eol, disable-markdown-pop-after-tag] - - match: '^[ ]{0,3}(?=<\?)' - comment: Markdown formatting is disabled inside preprocessor instructions. - push: [disabled-markdown-pop-at-eol, disable-markdown-pop-at-php] - - match: '^[ ]{0,3}(?=]+)(>) # The url @@ -276,34 +182,28 @@ contexts: ) captures: 1: punctuation.definition.constant.begin.markdown - 2: entity.name.reference.link.markdown + 2: constant.other.reference.link.markdown 3: punctuation.definition.constant.end.markdown 4: punctuation.separator.key-value.markdown 5: punctuation.definition.link.begin.markdown 6: markup.underline.link.markdown 7: punctuation.definition.link.end.markdown 8: markup.underline.link.markdown - push: [link-ref-def, after-link-title, link-title] + push: + - meta_scope: meta.link.reference.def.markdown + - include: link-title - match: '^(?=\S)(?![=-]{3,}\s*$)' push: - meta_scope: meta.paragraph.markdown - match: |- - (?x) # pop out of this context when one of the following conditions are met: + (?x) # pop out of this context when ^(?: - \s*$ # the line is blank (or only contains whitespace) + \s*$ # the line is blank (or only contains whitespace) | (?= - {{block_quote}} # a block quote begins the line - | [ ]{,3}[*+-][ ] # an unordered list item begins the line - | [ ]{,3}1[.][ ] # an ordered list item with number "1" begins the line - | \# # an ATX heading begins the line - | [ ]{,3}<( # all types of HTML blocks except type 7 may interrupt a paragraph - {{html_tag_block_end_at_close_tag}} # 1 - | !-- # 2 - | \? # 3 - | ![A-Z] # 4 - | !\[CDATA\[ # 5 - | {{html_tag_block_end_at_blank_line}} # 6 - ) + {{block_quote}} # a block quote begins the line + | [ ]{,3}[*+-][ ] # an unordered list item begins the line + | [ ]{,3}1[.][ ] # an ordered list item with number "1" begins the line + | \# # an ATX heading begins the line ) ) pop: true @@ -319,10 +219,6 @@ contexts: captures: 1: punctuation.definition.heading.setext.markdown pop: true - link-ref-def: - - meta_scope: meta.link.reference.def.markdown - - match: '' - pop: true ampersand: - match: (?!{{html_entity}})& comment: | @@ -463,8 +359,6 @@ contexts: 1: punctuation.definition.bold.end.markdown pop: true - include: inline - - match: \b_(?=[^\s_])(?=[^*_]*\*\*) - comment: eat the underscore that has no corresponding underscore before the closing bold punctuation on the same line, as it won't be treated as italic by CommonMark - include: italic - include: supersubscript - include: bold-italic-trailing @@ -519,7 +413,7 @@ contexts: - include: bold-italic-trailing - include: inline - include: bold-italic-trailing - - match: '\b__(?=\S)(?!_[_\s])' + - match: '\b__(?=\S)(?!__|_\s)' scope: punctuation.definition.bold.begin.markdown push: - meta_scope: markup.bold.markdown @@ -533,8 +427,6 @@ contexts: 1: punctuation.definition.bold.end.markdown pop: true - include: inline - - match: \*(?=[^\s*])(?=[^*_]*__\b) - comment: eat the asterisk that has no corresponding asterisk before the closing bold punctuation on the same line, as it won't be treated as italic by CommonMark - include: italic - include: supersubscript - include: bold-italic-trailing @@ -547,12 +439,6 @@ contexts: escape: - match: '{{escape}}' scope: constant.character.escape.markdown - atx-heading-terminator: - - match: '[ ]*(#*)[ ]*($\n?)' # \n is optional so ## is matched as end punctuation in new document (at eof) - captures: - 1: punctuation.definition.heading.end.markdown - 2: meta.whitespace.newline.markdown - pop: true atx-heading: - match: '(#)(?!#)\s*(?=\S)' captures: @@ -560,7 +446,10 @@ contexts: push: - meta_scope: markup.heading.1.markdown - meta_content_scope: entity.name.section.markdown - - include: atx-heading-terminator + - match: \s*(#*)$\n? + captures: + 1: punctuation.definition.heading.end.markdown + pop: true - include: inline-bold-italic - match: '(##)(?!#)\s*(?=\S)' captures: @@ -568,7 +457,10 @@ contexts: push: - meta_scope: markup.heading.2.markdown - meta_content_scope: entity.name.section.markdown - - include: atx-heading-terminator + - match: \s*(#*)$\n? + captures: + 1: punctuation.definition.heading.end.markdown + pop: true - include: inline-bold-italic - match: '(#{3,6})(?!#)\s*(?=\S)' captures: @@ -576,16 +468,19 @@ contexts: push: - meta_scope: markup.heading.markdown - meta_content_scope: entity.name.section.markdown - - include: atx-heading-terminator + - match: \s*(#*)$\n? + captures: + 1: punctuation.definition.heading.end.markdown + pop: true - include: inline-bold-italic image-inline: - match: |- (?x: - (\!\[) # Images start with ![ - (?= {{balance_square_brackets}}? # balanced square brackets, backticks, taking into account escapes etc. - \] # Closing square bracket - [ ]? # Space not allowed, but we check for it anyway to mark it as invalid - \( # Open paren + (\!\[) # Images start with ![ + (?= {{balance_square_brackets}} # balanced square brackets, backticks, taking into account escapes etc. + \] # Closing square bracket + [ ]? # Space not allowed, but we check for it anyway to mark it as invalid + \( # Open paren ) ) captures: @@ -598,46 +493,35 @@ contexts: scope: meta.image.inline.markdown punctuation.definition.image.end.markdown pop: true image-inline-after-text: - - match: '([ ]*)(\()' # spaces not allowed before the open paren, but we check for it anyway to mark it as invalid + - match: '{{url_and_title}}' captures: 1: invalid.illegal.whitespace.markdown 2: punctuation.definition.metadata.begin.markdown - set: - - meta_scope: meta.image.inline.markdown - - match: \) - scope: punctuation.definition.metadata.end.markdown - pop: true - - match: <(?=[^>)]*>) - scope: punctuation.definition.link.begin.markdown - push: - - meta_content_scope: markup.underline.link.image.markdown - - match: \> - scope: punctuation.definition.link.end.markdown - set: link-title - - match: \s+ - scope: invalid.illegal.unexpected-whitespace.markdown - - match: (?=\S) - set: - - meta_scope: meta.image.inline.markdown - - match: '[^\s)]+' - scope: markup.underline.link.image.markdown - - match: \) - scope: punctuation.definition.metadata.end.markdown - pop: true - - match: (?!\n)\s+(?!\s*(?:[)('"]|$)) - scope: invalid.illegal.unexpected-whitespace.markdown - - match: (?=\s*(?!\))) - push: link-title + 3: punctuation.definition.link.begin.markdown + 4: markup.underline.link.image.markdown + 5: punctuation.definition.link.end.markdown + 6: string.other.link.description.title.markdown + 7: punctuation.definition.string.begin.markdown + 8: punctuation.definition.string.end.markdown + 9: string.other.link.description.title.markdown + 10: punctuation.definition.string.begin.markdown + 11: punctuation.definition.string.end.markdown + 12: string.other.link.description.title.markdown + 13: punctuation.definition.string.begin.markdown + 14: punctuation.definition.string.end.markdown + 15: punctuation.definition.metadata.end.markdown + scope: meta.image.inline.markdown + pop: true image-ref: - match: |- (?x: - (\!\[) # Images start with ![ - (?= {{balance_square_brackets}}? # balanced square brackets, backticks, taking into account escapes etc. - \] # Closing square bracket - [ ]? # Space - \[ # [ - [^\]]+ # anything other than ] - \] # ] + (\!\[) # Images start with ![ + (?= {{balance_square_brackets}} # balanced square brackets, backticks, taking into account escapes etc. + \] # Closing square bracket + [ ]? # Space + \[ # [ + [^\]]+ # anything other than ] + \] # ] ) ) captures: @@ -784,7 +668,7 @@ contexts: 2: markup.underline.link.markdown 3: punctuation.definition.link.end.markdown - match: (((https|http|ftp)://)|www\.)[\w-]+(\.[\w-]+)+ - scope: markup.underline.link.markdown-gfm + scope: markup.underline.link.markdown push: # After a valid domain, zero or more non-space non-< characters may follow - match: (?=[?!.,:*_~]*[\s<]) # Trailing punctuation (specifically, ?, !, ., ,, :, *, _, and ~) will not be considered part of the autolink, though they may be included in the interior of the link pop: true @@ -792,7 +676,7 @@ contexts: pop: true - match: \( # When an autolink ends in ), we scan the entire autolink for the total number of parentheses. If there is a greater number of closing parentheses than opening ones, we don’t consider the last character part of the autolink, in order to facilitate including an autolink inside a parenthesis push: - - meta_scope: markup.underline.link.markdown-gfm + - meta_scope: markup.underline.link.markdown - match: (?=[?!.,:*_~]*[\s<]) pop: true - match: \) @@ -800,66 +684,56 @@ contexts: - match: (?=\)[?!.,:*_~]*[\s<]) pop: true - match: '[^?!.,:*_~\s<&()]+|\S' - scope: markup.underline.link.markdown-gfm + scope: markup.underline.link.markdown link-inline: - match: |- (?x: (\[) (?= - {{balance_square_brackets}}? + {{balance_square_brackets}} \] - [ ]?\( + {{url_and_title}} ) ) captures: 1: meta.link.inline.markdown punctuation.definition.link.begin.markdown push: [link-inline-after-text, link-inline-link-text] - link-inline-after-text: - - match: '([ ]*)(\()' # spaces not allowed before the open paren, but we check for it anyway to mark it as invalid - captures: - 1: invalid.illegal.whitespace.markdown - 2: punctuation.definition.metadata.begin.markdown - set: - - meta_scope: meta.link.inline.markdown - - match: \) - scope: punctuation.definition.metadata.end.markdown - pop: true - - match: <(?=[^>)]*>) - scope: punctuation.definition.link.begin.markdown - push: - - match: \> - scope: punctuation.definition.link.end.markdown - set: link-title - - match: \s+ - scope: invalid.illegal.unexpected-whitespace.markdown - - match: (?=\S) - set: - - meta_scope: meta.link.inline.markdown - - match: '[^\s)]+' - scope: markup.underline.link.markdown - - match: \) - scope: punctuation.definition.metadata.end.markdown - pop: true - - match: (?!\n)\s+(?!\s*(?:[)('"]|$)) - scope: invalid.illegal.unexpected-whitespace.markdown - - match: (?=\s*(?!\))) - push: link-title link-inline-link-text: - meta_content_scope: meta.link.inline.description.markdown - include: link-text-allow-image - match: \] scope: meta.link.inline.markdown punctuation.definition.link.end.markdown pop: true + link-inline-after-text: + - match: '{{url_and_title}}' + captures: + 1: invalid.illegal.whitespace.markdown + 2: punctuation.definition.metadata.begin.markdown + 3: punctuation.definition.link.begin.markdown + 4: markup.underline.link.markdown + 5: punctuation.definition.link.end.markdown + 6: string.other.link.description.title.markdown + 7: punctuation.definition.string.begin.markdown + 8: punctuation.definition.string.end.markdown + 9: string.other.link.description.title.markdown + 10: punctuation.definition.string.begin.markdown + 11: punctuation.definition.string.end.markdown + 12: string.other.link.description.title.markdown + 13: punctuation.definition.string.begin.markdown + 14: punctuation.definition.string.end.markdown + 15: punctuation.definition.metadata.end.markdown + scope: meta.link.inline.markdown + pop: true link-ref: - match: |- (?x: (\[) - (?= {{balance_square_brackets}}? # balanced square brackets, backticks, taking into account escapes etc. - \] # Closing square bracket - [ ]? # Space - \[ # [ - [^\]]+ # anything other than ] - \] # ] + (?= {{balance_square_brackets}} # balanced square brackets, backticks, taking into account escapes etc. + \] # Closing square bracket + [ ]? # Space + \[ # [ + [^\]]+ # anything other than ] + \] # ] ) ) captures: @@ -884,11 +758,11 @@ contexts: (?x: (\[) (?= - {{balance_square_brackets}}? # balanced square brackets, backticks, taking into account escapes etc. - \] # Closing square bracket - [ ]? # Space - \[ # [ - \] # ] + {{balance_square_brackets}} # balanced square brackets, backticks, taking into account escapes etc. + \] # Closing square bracket + [ ]? # Space + \[ # [ + \] # ] ) ) captures: @@ -920,7 +794,7 @@ contexts: 2: meta.link.reference.literal.footnote-id.markdown 3: punctuation.definition.link.end.markdown list-paragraph: - - match: '^(?=(?:[ ]{4}|\t){2,}(?![>+*\s-]))(?={{indented_code_block}})' + - match: '^(?=\s+(?![>+*\s-]))(?={{indented_code_block}})' push: - include: indented-code-block - match: $ @@ -930,11 +804,6 @@ contexts: - include: block-quote - match: $ pop: true - - match: '^(?={{fenced_code_block_start}})' - push: - - include: fenced-code-block - - match: '' - pop: true - match: \s+(?=\S) push: - match: ^\s*$ @@ -964,11 +833,6 @@ contexts: pop: true list-content: - meta_content_scope: meta.paragraph.list.markdown - - match: ^(?={{fenced_code_block_start}}) - push: - - match: $ - pop: true - - include: fenced-code-block - match: ^ pop: true - include: thematic-break @@ -981,324 +845,21 @@ contexts: - match: $ pop: true fenced-code-block: - - match: |- - (?x) - {{fenced_code_block_start}} - ((?i:xml)) - \s*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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}} - ((?i:java)) - \s*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: 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*$\n? # any whitespace until EOL - captures: - 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: '{{code_fence_escape}}' - escape_captures: - 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 - .*$\n? # all characters until EOL + .*$ # 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 + 1: punctuation.definition.raw.code-fence.begin.markdown + 2: constant.other.language-name.markdown push: - - 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 + - meta_scope: markup.raw.code-fence.markdown + - match: '[ ]{,3}\1\s*$' + scope: punctuation.definition.raw.code-fence.end.markdown pop: true code-span: - - match: (`+)(?!`) + - match: (`+)(?=\S)(?!`) scope: punctuation.definition.raw.begin.markdown push: - meta_scope: markup.raw.inline.markdown @@ -1310,14 +871,12 @@ contexts: scope: invalid.illegal.non-terminated.raw.markdown pop: true raw: - - match: ^(?={{fenced_code_block_start}}) - push: - - match: $ - pop: true - - include: fenced-rcode-block - - include: fenced-code-block + - include: fenced-rcode-block + - include: fenced-code-block - include: rcode-span - include: code-span + - match: '`+' + scope: invalid.deprecated.unescaped-backticks.markdown thematic-break: - match: '(?={{thematic_break}})' push: @@ -1327,41 +886,19 @@ contexts: - match: '$\n?' pop: true disable-markdown: - - include: scope:text.html.basic - disable-markdown-pop-at-tag: - match: () captures: 1: meta.tag.block.any.html punctuation.definition.tag.begin.html 2: meta.tag.block.any.html entity.name.tag.block.any.html 3: meta.tag.block.any.html punctuation.definition.tag.end.html pop: true - - include: disable-markdown - disable-markdown-pop-after-tag: - - match: (?! - pop: true - - include: disable-markdown - disable-markdown-pop-after-html-doctype: - - match: (?!