diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index 6b125e7f07..e50e0202dd 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -8,8 +8,9 @@ file_extensions: - markdown - markdn scope: text.html.markdown +comment: this definition aims to (eventually) meet CommonMark specifications http://spec.commonmark.org/ variables: - separator_line: |- + thematic_break: |- (?x: [ ]{,3} (?: @@ -20,16 +21,61 @@ variables: [ \t]*$ ) block_quote: '(?:[ ]{,3}>(?:.|$))' - block_heading: '(?:[#]{1,6}\s*)' - block_raw: '(?:[ ]{4}|\t)' + atx_heading: '(?:[#]{1,6}\s*)' + indented_code_block: '(?:[ ]{4}|\t)' + list_item: '(?:[ ]{,3}(?=\d+\.|[*+-])\d*([*+.-])\s)' + link_title: |- + (?x:[ \t]* # Optional whitespace + (?: + ((\().+?(\))) # Match title in parens… + | ((")[^"]+(")) # or in double quotes… + | ((')[^']+(')) # or in single quotes. + )? # Title is optional + ) + escape: '\\[-`*_#+.!(){}\[\]\\>]' + backticks: |- + (?x: + (`{4})(?=\S)[^`]+(?:[^`]+|(?!`{4})`*)*(`{4})(?!`) + | (`{3})(?=\S)[^`]+(?:[^`]+|(?!`{3})`*)*(`{3})(?!`) + | (`{2})(?=\S)[^`]+(?:[^`]+|(?!`{2})`*)*(`{2})(?!`) + | (`{1})(?=\S)[^`]+(?:[^`]+|(?!`{1})`*)*(`{1})(?!`) + ) + balance: |- + (?x: + (?: + {{escape}}+ # escape characters + | [^\[\]`\\]+ # anything that isn't a square bracket or a backtick or the start of an escape character + | {{backticks}} # inline code + ) + ) + balance_square_brackets: |- + (?x: + (?: + {{balance}} + | \[(?: # nested square brackets (one level deep) + [^\[\]`]+ # anything that isn't a square bracket or a backtick + {{backticks}}? # balanced backticks + )*\] # 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 + (\)) + ) + skip_html_tags: '(?:<[^>]+>)' contexts: main: - match: |- (?x)^ (?= {{block_quote}} - | {{block_raw}}(?!$) - | {{block_heading}} - | {{separator_line}} + | {{indented_code_block}}(?!$) + | {{atx_heading}} + | {{thematic_break}} ) comment: | We could also use an empty end match and set @@ -37,18 +83,12 @@ contexts: pattern will only match stuff matched by the sub-patterns. push: - meta_scope: meta.block-level.markdown - - match: |- - (?x)^ - (?! {{block_quote}} - | {{block_raw}} - | {{block_heading}} - | {{separator_line}} - ) + - include: block-quote + - include: indented-code-block + - include: atx-heading + - include: thematic-break + - match: '' pop: true - - include: block_quote - - include: block_raw - - include: heading - - include: separator - match: '^[ ]{0,3}([*+-])(?=\s)' captures: 1: punctuation.definition.list_item.markdown @@ -73,59 +113,49 @@ contexts: \s* # Leading whitespace (\[)(.+?)(\])(:) # Reference name [ \t]* # Optional whitespace - (?) # The url - [ \t]* # Optional whitespace (?: - ((\().+?(\))) # Match title in parens… - | ((")[^"]+(")) # or in double quotes - | ((')[^']+(')) # or in single quotes - )? # Title is optional - \s* # Optional whitespace - $ + (<)([^>]+)(>) # The url + | (\S+) # The url + ) ) - scope: meta.link.reference.def.markdown captures: - 1: punctuation.definition.constant.markdown + 1: punctuation.definition.constant.begin.markdown 2: constant.other.reference.link.markdown - 3: punctuation.definition.constant.markdown + 3: punctuation.definition.constant.end.markdown 4: punctuation.separator.key-value.markdown - 5: punctuation.definition.link.markdown + 5: punctuation.definition.link.begin.markdown 6: markup.underline.link.markdown - 7: punctuation.definition.link.markdown - 8: string.other.link.description.title.markdown - 9: punctuation.definition.string.begin.markdown - 10: punctuation.definition.string.end.markdown - 11: string.other.link.description.title.markdown - 12: punctuation.definition.string.begin.markdown - 13: punctuation.definition.string.end.markdown - 14: string.other.link.description.title.markdown - 15: punctuation.definition.string.begin.markdown - 16: punctuation.definition.string.end.markdown + 7: punctuation.definition.link.end.markdown + 8: markup.underline.link.markdown + push: + - meta_scope: meta.link.reference.def.markdown + - include: link-title - match: '^(?=\S)(?![=-]{3,}\s*$)' - push: + push: - meta_scope: meta.paragraph.markdown - match: |- - (?x) + (?x) # pop out of this context when ^(?: - \s*$ + \s*$ # the line is blank (or only contains whitespace) | (?= - {{block_quote}} - | ^[ ]{,3}[*+-][ ] - | ^\# + {{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 - include: inline-bold-italic-linebreak - include: scope:text.html.basic - match: '^(={3,})(?=[ \t]*$)' - scope: markup.heading.1.markdown + scope: markup.heading.1.setext.markdown captures: - 1: punctuation.definition.heading.markdown + 1: punctuation.definition.heading.setext.markdown pop: true - match: '^(-{3,})(?=[ \t]*$)' - scope: markup.heading.2.markdown + scope: markup.heading.2.setext.markdown captures: - 1: punctuation.definition.heading.markdown + 1: punctuation.definition.heading.setext.markdown pop: true ampersand: - match: "&(?!([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+);)" @@ -133,12 +163,16 @@ contexts: Markdown will convert this for us. We match it so that the HTML grammar will not mark it up as invalid. scope: meta.other.valid-ampersand.markdown - block_quote: - - match: '\G[ ]{,3}(>)[ ]?' + block-quote: + - match: '[ ]{,3}(>)[ ]?' comment: | We terminate the block quote when seeing an empty line, a - separator or a line with leading > characters. The latter is - to “reset” the quote level for quoted lines. + separator or a line with leading > characters. The latter is + to “reset” the quote level for quoted lines. + The idea here is to match block level elements first, then once + we have confirmed there are no block level elements left, move to + matching inline markdown. This prevents block level elements being + detected when they shouldn't be. captures: 1: punctuation.definition.blockquote.markdown push: @@ -146,102 +180,90 @@ contexts: - match: |- (?x)^ (?= \s*$ - | {{separator_line}} + | {{thematic_break}} | {{block_quote}} ) pop: true - match: |- - (?x)\G + (?x) (?= {{block_quote}} ) push: - match: ^ pop: true - - include: block_quote + - include: block-quote - match: |- - (?x)\G - (?= {{block_raw}} - | {{block_heading}} - | {{separator_line}} + (?x) + (?= {{indented_code_block}} + | {{atx_heading}} + | {{thematic_break}} + | {{list_item}} ) push: - - include: block_raw - - include: heading - - include: separator + - include: indented-code-block + - include: atx-heading + - include: thematic-break + - match: '{{list_item}}' + captures: + 1: punctuation.definition.list_item.markdown - match: ^ pop: true - - match: |- - (?x)\G - (?! $ - | {{block_quote}} - | {{block_raw}} - | {{block_heading}} - | {{separator_line}} - ) + - include: list-paragraph + - match: '' push: - match: $|^ pop: true - include: inline-bold-italic-linebreak - block_raw: - - match: '\G{{block_raw}}.*$\n?' + indented-code-block: + - match: '{{indented_code_block}}.*$\n?' scope: markup.raw.block.markdown bold: - - match: |- - (?x) - (\*\*|\b__)(?=\S) # Open - (?= - ( - <[^>]*+> # HTML tags - | (?`+)([^`]|(?!(?(?!`))`)*+\k - # Raw - | \\[\\`*_{}\[\]()#.!+\->]?+ # Escapes - | \[ - ( - (? # Named group - [^\[\]\\] # Match most chars - | \\. # Escaped chars - | \[ \g*+ \] # Nested brackets - )*+ - \] - ( - ( # Reference Link - [ ]? # Optional space - \[[^\]]*+\] # Ref name - ) - | ( # Inline Link - \( # Opening paren - [ \t]*+ # Optional whitespace - ? # URL - [ \t]*+ # Optional whitespace - ( # Optional Title - (?['"]) - (.*?) - \k<title> - )? - \) - ) - ) - ) - | (?!(?<=\S)\1). # Everything besides - # style closer - )++ - (?<=\S)\1 # Close - ) + - match: '(\*\*)(?=\S)(?!\*)(?:_)?' captures: - 1: punctuation.definition.bold.markdown + 1: punctuation.definition.bold.begin.markdown push: - meta_scope: markup.bold.markdown - - match: (?<=\S)(\1) + - match: |- + (?x) + [ \t]*\*{3,} # if there are more than 3 its not applicable to be bold or italic + | [ \t]+\*\*+ # whitespace followed by 2 or more is also not applicable + | ^\*\* # emphasis can't be closed at the start of the line + - match: (\*\*) captures: - 1: punctuation.definition.bold.markdown + 1: punctuation.definition.bold.end.markdown pop: true - - match: "(?=<[^>]*?>)" - push: - - include: scope:text.html.basic - - match: (?<=>) - pop: true + - include: scope:text.html.basic - include: inline - include: italic + - match: ^\s*$\n? + scope: invalid.illegal.non-terminated.bold.markdown + pop: true + - match: '^(?={{list_item}})' + pop: true + - include: hard-line-break + - match: '(\b__)(?=\S)(?!_)(?:\*)?' + captures: + 1: punctuation.definition.bold.begin.markdown + push: + - meta_scope: markup.bold.markdown + - match: |- + (?x) + [ \t]*_{3,} # if there are more than 3 its not applicable to be bold or italic + | [ \t]+__+ # whitespace followed by 2 or more is also not applicable + | ^__ # emphasis can't be closed at the start of the line + - match: (__\b) + captures: + 1: punctuation.definition.bold.end.markdown + pop: true + - include: scope:text.html.basic + - include: inline + - include: italic + - match: ^\s*$\n? + scope: invalid.illegal.non-terminated.bold.markdown + pop: true + - match: '^(?={{list_item}})' + pop: true + - include: hard-line-break bracket: - match: '<(?![a-z/?\$!])' comment: | @@ -249,64 +271,92 @@ contexts: HTML grammar will not mark it up as invalid. scope: meta.other.valid-bracket.markdown escape: - - match: '\\[-`*_#+.!(){}\[\]\\>]' + - match: '{{escape}}' scope: constant.character.escape.markdown - heading: - - match: '\G(#{1,6})(?!#)\s*(?=\S)' + atx-heading: + - match: '(#{1,6})(?!#)\s*(?=\S)' captures: - 1: punctuation.definition.heading.markdown + 1: punctuation.definition.heading.begin.markdown push: - meta_scope: markup.heading.markdown - meta_content_scope: entity.name.section.markdown - match: \s*(#*)$\n? captures: - 1: punctuation.definition.heading.markdown + 1: punctuation.definition.heading.end.markdown pop: true - - include: inline-bold-italic-linebreak + - include: inline-bold-italic image-inline: - match: |- (?x: - \! # Images start with ! - (\[)((?<square>[^\[\]\\]+|\\.|\[\g<square>*+\])*+)(\]) - # Match the link text. - ([ ])? # Space not allowed - (\() # Opening paren for url - (<?)(\S+?)(>?) # The url - [ \t]* # Optional whitespace - (?: - ((\().+?(\))) # Match title in parens… - | ((").+?(")) # or in quotes. - )? # Title is optional - \s* # Optional whitespace - (\)) - ) - scope: meta.image.inline.markdown + (\!)(\[) # 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: - 1: punctuation.definition.string.begin.markdown - 2: string.other.link.description.markdown - 4: punctuation.definition.string.end.markdown - 5: invalid.illegal.whitespace.markdown - 6: punctuation.definition.metadata.markdown - 7: punctuation.definition.link.markdown - 8: markup.underline.link.image.markdown - 9: punctuation.definition.link.markdown - 10: string.other.link.description.title.markdown - 11: punctuation.definition.string.markdown - 12: punctuation.definition.string.markdown - 13: string.other.link.description.title.markdown - 14: punctuation.definition.string.markdown - 15: punctuation.definition.string.markdown - 16: punctuation.definition.metadata.markdown + 1: punctuation.definition.image.begin.markdown + 2: punctuation.definition.string.begin.markdown + push: [image-inline-after-text, image-link-text] + image-link-text: + - meta_scope: meta.image.inline.markdown + - meta_content_scope: string.other.link.description.markdown + - include: link-text + - match: \] + scope: punctuation.definition.string.end.markdown + pop: true + image-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.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: '\!(\[)((?<square>[^\[\]\\]|\\.|\[\g<square>*+\])*+)(\])[ ]?(\[)(.*?)(\])' - scope: meta.image.reference.markdown + - match: |- + (?x: + (\!)(\[) # Images start with ![ + (?= {{balance_square_brackets}} # balanced square brackets, backticks, taking into account escapes etc. + \] # Closing square bracket + [ ]? # Space + \[ # [ + [^\]]+ # anything other than ] + \] # ] + ) + ) captures: - 1: punctuation.definition.string.begin.markdown - 2: string.other.link.description.markdown - 4: punctuation.definition.string.end.markdown - 5: punctuation.definition.constant.markdown - 6: constant.other.reference.link.markdown - 7: punctuation.definition.constant.markdown + 1: punctuation.definition.image.begin.markdown + 2: punctuation.definition.string.begin.markdown + push: [image-ref-after-text, image-ref-text] + image-ref-text: + - meta_scope: meta.image.reference.markdown + - meta_content_scope: string.other.link.description.markdown + - include: link-text + - match: \] + scope: punctuation.definition.string.end.markdown + pop: true + image-ref-after-text: + - match: '[ ]?(\[)([^\]]+)(\])' + captures: + 1: punctuation.definition.constant.begin.markdown + 2: constant.other.reference.link.markdown + 3: punctuation.definition.constant.end.markdown + scope: meta.image.reference.markdown + pop: true inline: - include: escape - include: ampersand @@ -314,165 +364,271 @@ contexts: - include: raw - include: image-inline - include: link-inline - - include: link-inet - - include: link-email + - include: autolink-inet + - include: autolink-email - include: image-ref - include: link-ref-literal - include: link-ref - inline-bold-italic-linebreak: + inline-bold-italic: - include: inline - include: bold - include: italic - - include: line-break + inline-bold-italic-linebreak: + - include: inline-bold-italic + - include: hard-line-break italic: - - match: |- - (?x) - (\*|\b_)(?=\S) # Open - (?= - ( - <[^>]*+> # HTML tags - | (?<raw>`+)([^`]|(?!(?<!`)\k<raw>(?!`))`)*+\k<raw> - # Raw - | \\[\\`*_{}\[\]()#.!+\->]?+ # Escapes - | \[ - ( - (?<square> # Named group - [^\[\]\\] # Match most chars - | \\. # Escaped chars - | \[ \g<square>*+ \] # Nested brackets - )*+ - \] - ( - ( # Reference Link - [ ]? # Optional space - \[[^\]]*+\] # Ref name - ) - | ( # Inline Link - \( # Opening paren - [ \t]*+ # Optional whitespace - <?(.*?)>? # URL - [ \t]*+ # Optional whitespace - ( # Optional Title - (?<title>['"]) - (.*?) - \k<title> - )? - \) - ) - ) - ) - | \1\1 # Must be bold closer - | (?!(?<=\S)\1). # Everything besides - # style closer - )++ - (?<=\S)\1 # Close - ) + - match: '(\*)(?=\S)(?!\*)' captures: - 1: punctuation.definition.italic.markdown + 1: punctuation.definition.italic.begin.markdown push: - meta_scope: markup.italic.markdown - - match: (?<=\S)(\1)((?!\1)|(?=\1\1)) + - match: |- + (?x) + [ \t]*\*{3,} # if there are more than 3 its not applicable to be bold or italic + | [ \t]+\*(?!\*) # whitespace followed by 1 is also not applicable (but whitespace followed by 2 could be bold punctuation) + | ^\*(?!\*) # emphasis can't be closed at the start of the line + - match: (\*)(?!\*) captures: - 1: punctuation.definition.italic.markdown + 1: punctuation.definition.italic.end.markdown pop: true - - match: "(?=<[^>]*?>)" - push: - - include: scope:text.html.basic - - match: (?<=>) - pop: true + - include: scope:text.html.basic - include: inline - include: bold - line-break: - - match: " {2,}$" - scope: meta.dummy.line-break - link-email: + - match: '\*+' + - match: ^\s*$\n? + scope: invalid.illegal.non-terminated.italic.markdown + pop: true + - match: '^(?={{list_item}})' + pop: true + - include: hard-line-break + - match: '(\b_)(?=\S)(?!_)' + captures: + 1: punctuation.definition.italic.begin.markdown + push: + - meta_scope: markup.italic.markdown + - match: |- + (?x) + [ \t]*_{3,} # if there are more than 3 its not applicable to be bold or italic + | [ \t]+_(?!_) # whitespace followed by 1 is also not applicable (but whitespace followed by 2 could be bold punctuation) + | ^_(?!_) # emphasis can't be closed at the start of the line + - match: (_\b) + captures: + 1: punctuation.definition.italic.end.markdown + pop: true + - include: scope:text.html.basic + - include: inline + - include: bold + - match: ^\s*$\n? + scope: invalid.illegal.non-terminated.italic.markdown + pop: true + - match: '^(?={{list_item}})' + pop: true + - include: hard-line-break + - match: '[*_]+' + hard-line-break: + - match: '[ ]{2,}$' + scope: meta.hard-line-break.markdown punctuation.definition.hard-line-break.markdown + - match: '(\\)$\n' + scope: meta.hard-line-break.markdown + captures: + 1: constant.character.escape.markdown + autolink-email: - match: '(<)((?:mailto:)?[-+.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(>)' scope: meta.link.email.lt-gt.markdown captures: - 1: punctuation.definition.link.markdown + 1: punctuation.definition.link.begin.markdown 2: markup.underline.link.markdown - 4: punctuation.definition.link.markdown - link-inet: + 4: punctuation.definition.link.end.markdown + autolink-inet: - match: (<)((?:https?|ftp)://.*?)(>) scope: meta.link.inet.markdown captures: - 1: punctuation.definition.link.markdown + 1: punctuation.definition.link.begin.markdown 2: markup.underline.link.markdown - 3: punctuation.definition.link.markdown + 3: punctuation.definition.link.end.markdown link-inline: - match: |- (?x: - (\[)((?<square>[^\[\]\\]+|\\.|\[\g<square>*+\])*+)(\]) - # Match the link text. - ([ ])? # Space not allowed - (\() # Opening paren for url - (<?)(.*?)(>?) # The url - [ \t]* # Optional whitespace - (?: - ((\().+?(\))) # Match title in parens… - | ((").+?(")) # or in quotes. - )? # Title is optional - \s* # Optional whitespace - (\)) - ) - scope: meta.link.inline.markdown + (\[) + (?= + {{balance_square_brackets}} + \] + {{url_and_title}} + ) + ) captures: 1: punctuation.definition.string.begin.markdown - 2: string.other.link.title.markdown - 4: punctuation.definition.string.end.markdown - 5: invalid.illegal.whitespace.markdown - 6: punctuation.definition.metadata.markdown - 7: punctuation.definition.link.markdown - 8: markup.underline.link.markdown - 9: punctuation.definition.link.markdown - 10: string.other.link.description.title.markdown - 11: punctuation.definition.string.begin.markdown - 12: punctuation.definition.string.end.markdown - 13: string.other.link.description.title.markdown - 14: punctuation.definition.string.begin.markdown - 15: punctuation.definition.string.end.markdown - 16: punctuation.definition.metadata.markdown + push: [link-inline-after-text, link-inline-link-text] + link-inline-link-text: + - meta_scope: meta.link.inline.markdown + - meta_content_scope: string.other.link.title.markdown + - include: link-text-allow-image + - match: \] + scope: punctuation.definition.string.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: '(\[)((?<square>[^\[\]\\]+|\\.|\[\g<square>*+\])*+)(\])[ ]?(\[)([^\]]*+)(\])' - scope: meta.link.reference.markdown + - match: |- + (?x: + (\[) + (?= {{balance_square_brackets}} # balanced square brackets, backticks, taking into account escapes etc. + \] # Closing square bracket + [ ]? # Space + \[ # [ + [^\]]+ # anything other than ] + \] # ] + ) + ) captures: 1: punctuation.definition.string.begin.markdown - 2: string.other.link.title.markdown - 4: punctuation.definition.string.end.markdown - 5: punctuation.definition.constant.begin.markdown - 6: constant.other.reference.link.markdown - 7: punctuation.definition.constant.end.markdown + push: [link-ref-after-text, link-ref-link-text] + link-ref-link-text: + - meta_scope: meta.link.reference.markdown + - meta_content_scope: string.other.link.title.markdown + - include: link-text-allow-image + - match: \] + scope: punctuation.definition.string.end.markdown + pop: true + link-ref-after-text: + - match: '[ ]?(\[)([^\]]+)(\])' + captures: + 1: punctuation.definition.constant.begin.markdown + 2: constant.other.reference.link.markdown + 3: punctuation.definition.constant.end.markdown + scope: meta.link.reference.markdown + pop: true link-ref-literal: - - match: '(\[)((?<square>[^\[\]\\]+|\\.|\[\g<square>*+\])*+)(\])[ ]?(\[)(\])' - scope: meta.link.reference.literal.markdown + - match: |- + (?x: + (\[) + (?= + {{balance_square_brackets}} # balanced square brackets, backticks, taking into account escapes etc. + \] # Closing square bracket + [ ]? # Space + \[ # [ + \] # ] + ) + ) captures: 1: punctuation.definition.string.begin.markdown - 2: string.other.link.title.markdown - 4: punctuation.definition.string.end.markdown - 5: punctuation.definition.constant.begin.markdown - 6: punctuation.definition.constant.end.markdown + push: [link-ref-literal-after-text, link-ref-literal-link-text] + link-ref-literal-link-text: + - meta_scope: meta.link.reference.literal.markdown + - meta_content_scope: string.other.link.title.markdown + - include: link-text-allow-image + - match: \] + scope: punctuation.definition.string.end.markdown + pop: true + link-ref-literal-after-text: + - match: '[ ]?(\[)(\])' + scope: meta.link.reference.literal.markdown + captures: + 1: punctuation.definition.constant.begin.markdown + 2: punctuation.definition.constant.end.markdown + pop: true list-paragraph: - - match: \G\s+(?=\S) + - match: '^(?=\s+(?![>+*\s-]))(?={{indented_code_block}})' + push: + - include: indented-code-block + - match: $ + pop: true + - match: '^(?=\s+{{block_quote}})' + push: + - include: block-quote + - match: $ + pop: true + - match: \s+(?=\S) push: - meta_scope: meta.paragraph.list.markdown - match: ^\s*$ pop: true - - match: '^[ ]*([*+-])(?=\s)' + - match: '[ ]*([*+-])(?=\s)' captures: 1: punctuation.definition.list_item.markdown - - match: '^[ ]*\d+(\.)(?=\s)' + push: list-content + - match: '[ ]*\d+(\.)(?=\s)' captures: 1: punctuation.definition.list_item.markdown - - include: inline-bold-italic-linebreak - raw: - - match: '(`+)([^`]|(?!(?<!`)\1(?!`))`)*+(\1)' - scope: markup.raw.inline.markdown + push: list-content + - match: '(?=\S)' + push: + - include: list-content + - match: '(?=\S)' + pop: true + list-content: + - meta_content_scope: meta.paragraph.list.markdown + - match: ^ + pop: true + - include: thematic-break + - include: inline-bold-italic-linebreak + - include: scope:text.html.basic + fenced-code-block: + - match: |- + (?x) + ^[ ]{0,3} # up to 3 spaces + ( + `{3,} # 3 or more backticks + (?![^`]+`) # not followed by any more backticks on the same line + (?!`) # makes the {3,} possessive + | # or + ~{3,} # 3 or more tildas + (?![^~]+~) # not followed by any more tildas on the same line + (?!~) # makes the {3,} possessive + ) + ([\w-]*) # any number of word characters or dashes + .*$ # all characters until eol captures: - 1: punctuation.definition.raw.markdown - 3: punctuation.definition.raw.markdown - separator: - - match: '\G{{separator_line}}\n?' - scope: meta.separator.markdown + 1: punctuation.definition.raw.code-fence.begin.markdown + 2: constant.other.language-name.markdown + push: + - meta_scope: markup.raw.code-fence.markdown + - match: '[ ]{,3}\1\s*$' + scope: punctuation.definition.raw.code-fence.end.markdown + pop: true + code-span: + - match: (`+)(?=\S)(?!`) + scope: punctuation.definition.raw.begin.markdown + push: + - meta_scope: markup.raw.inline.markdown + - match: \1(?!`) + scope: punctuation.definition.raw.end.markdown + pop: true + - match: '`+' + - match: ^\s*$\n? + scope: invalid.illegal.non-terminated.raw.markdown + pop: true + raw: + - include: fenced-code-block + - include: code-span + - match: '`+' + scope: invalid.deprecated.unescaped-backticks.markdown + thematic-break: + - match: '(?={{thematic_break}}$)' + push: + - meta_scope: meta.separator.thematic-break.markdown + - match: '[-_*]+' + scope: punctuation.definition.thematic-break.markdown + - match: '$\n?' + pop: true disable-markdown: - match: (</)(\1)(>) captures: @@ -487,3 +643,61 @@ contexts: scope: meta.disable-markdown pop: true - include: scope:text.html.basic + link-text: + - include: escape + - include: ampersand + - include: raw + - match: \[ # nested square brackets are allowed + push: + - include: link-text + - match: \] + pop: true + - include: bold + - include: italic + - include: hard-line-break + - include: scope:text.html.basic + link-text-allow-image: + - include: link-text + - include: image-inline + - include: image-ref + link-title: + - match: \s*(') + captures: + 1: punctuation.definition.string.begin.markdown + push: + - meta_scope: string.other.link.description.title.markdown + - match: \' + scope: punctuation.definition.string.end.markdown + set: after-link-title + - match: ^\s*$\n? + scope: invalid.illegal.non-terminated.link-title.markdown + pop: true + - match: \s*(") + captures: + 1: punctuation.definition.string.begin.markdown + push: + - meta_scope: string.other.link.description.title.markdown + - match: \" + scope: punctuation.definition.string.end.markdown + set: after-link-title + - match: ^\s*$\n? + scope: invalid.illegal.non-terminated.link-title.markdown + pop: true + - match: \s*(\() + captures: + 1: punctuation.definition.string.begin.markdown + push: + - meta_scope: string.other.link.description.title.markdown + - match: \) + scope: punctuation.definition.string.end.markdown + set: after-link-title + - match: ^\s*$\n? + scope: invalid.illegal.non-terminated.link-title.markdown + pop: true + - match: \s* + set: after-link-title + after-link-title: + - match: '(.*)$\n?' + captures: + 1: invalid.illegal.expected-eol.markdown + pop: true diff --git a/Markdown/syntax_test_markdown.md b/Markdown/syntax_test_markdown.md index ced5efc3a1..995a319a35 100644 --- a/Markdown/syntax_test_markdown.md +++ b/Markdown/syntax_test_markdown.md @@ -44,16 +44,17 @@ Here is a [blank reference link][]. | ^ punctuation.definition.constant.begin | ^ punctuation.definition.constant.end -Here is a ![Image Alt Text](htts://example.com/cat.git). +Here is a ![Image Alt Text](https://example.com/cat.gif). | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.image.inline | ^ punctuation.definition.string.begin -| ^ punctuation.definition.string.end +| ^ punctuation.definition.string.end - string | ^ punctuation.definition.metadata -| ^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.image -| ^ punctuation.definition.metadata +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.image +| ^ punctuation.definition.metadata Here is a ![Image Ref Alt][1]. | ^^^^^^^^^^^^^^^^^^^ meta.image.reference +| ^ punctuation.definition.image.begin | ^ punctuation.definition.string.begin | ^ punctuation.definition.string.end | ^ punctuation.definition.constant @@ -74,19 +75,19 @@ Here is a ![Image Ref Alt][1]. Paragraph break. - - Ordered list item + - Unordered list item | ^ punctuation.definition.list_item | ^^^^^^^^^^^^^^^^^^^^ markup.list.unnumbered - - Ordered list item #2 + - Unordered list item #2 | ^^^^^^^^^^^^^^^^^^^^^^^ markup.list.unnumbered | ^ punctuation.definition.list_item Paragraph break. - * Ordered list item + * Unordered list item | ^ punctuation.definition.list_item | ^^^^^^^^^^^^^^^^^^^^ markup.list.unnumbered - + Ordered list item #2 + + Unordered list item #2 | ^^^^^^^^^^^^^^^^^^^^^^ markup.list.unnumbered | ^ punctuation.definition.list_item + Subitem 1 @@ -95,6 +96,11 @@ Paragraph break. + Subitem + Another subitem | ^ meta.paragraph.list punctuation.definition.list_item + + Nested Subitem +| ^ punctuation.definition.list_item + + Nested + Subitem +| ^ punctuation.definition.list_item +| ^ - punctuation.definition.list_item Paragraph break. @@ -106,7 +112,8 @@ Paragraph break. Paragraph break. -------- -|^^^^^^^ meta.separator +|^^^^^^^^ meta.block-level meta.separator.thematic-break +|^^^^^^^ punctuation.definition.thematic-break [1]: https://google.com | <- meta.link.reference.def @@ -172,9 +179,19 @@ non-disabled markdown > Followed by more quoted text that is not nested | <- meta.block-level markup.quote punctuation.definition.blockquote - markup.quote markup.quote +> Here is a quote block +This quote continues on. Line breaking is OK in markdown +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block-level markup.quote +> Here it is again +| <- punctuation.definition.blockquote + paragraph | <- meta.paragraph - meta.block-level +> > this is code in a quote block, not a nested quote +| <- punctuation.definition.blockquote +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.raw.block - markup.quote markup.quote + Code block below: this is code! @@ -189,12 +206,24 @@ paragraph - - - - | ^^^^^^ meta.block-level meta.separator - +| ^ punctuation.definition.thematic-break +| ^ punctuation.definition.thematic-break +| ^ punctuation.definition.thematic-break +| ^ - punctuation * * * * * | ^^^^^^^^ meta.block-level meta.separator _ _ _ _ _ _ _ | ^^^^^^^^^^^^ meta.block-level meta.separator +| ^ punctuation.definition.thematic-break +| ^ punctuation.definition.thematic-break +| ^ - punctuation + +- - - - +| <- meta.block-level meta.separator.thematic-break punctuation.definition.thematic-break +|^^ - punctuation +| ^ punctuation +| ^ punctuation <mailto:test+test@test.com> | ^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.email.lt-gt markup.underline.link @@ -242,23 +271,851 @@ underlined heading followed by another one that should be treated as a normal pa ===== | <- - markup.heading +Paragraph followed immediately by a list, no blank line in between +- list item 1 +| <- markup.list.unnumbered punctuation.definition.list_item + +Paragraph followed immediately by a numbered list, no blank line in between + 1. list item 1 +| ^ markup.list.numbered punctuation.definition.list_item + more text - this punctuation should be ignored 2. +| ^ - punctuation.definition.list_item +| ^ - punctuation.definition.list_item + +Paragraph not followed immediately by a numbered list, +because it doesn't begin with the number one: + 2. text +| ^ - markup.list.numbered - punctuation.definition.list_item + + +> Block quote with list items +> - list item 1 +| ^ meta.block-level markup.quote punctuation.definition.list_item +> - list item 2 +| ^ meta.block-level markup.quote punctuation.definition.list_item +> 1. sub list item +| ^ meta.block-level markup.quote punctuation.definition.list_item + +* this is a list + + > This is a blockquote. +| ^ markup.list.unnumbered markup.quote punctuation.definition.blockquote + + This is a paragraph still part of the + list item +| ^^^^^^^^^ markup.list.unnumbered meta.paragraph.list + +* Lorem ipsum + + This is a code block +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.list.unnumbered markup.raw.block +* list continues +| <- markup.list.unnumbered punctuation.definition.list_item - markup.raw.block +* list continues + +- `code` - <a name="demo"></a> +| ^ markup.list.unnumbered meta.paragraph.list markup.raw.inline punctuation.definition.raw +| ^^^^^^^^^^^^^^^^^^^ meta.tag.inline.a.html + 3. [see `demo`](#demo "demo") +| ^ punctuation.definition.list_item +| ^^^^^^^^^^ string.other.link.title +| ^ punctuation.definition.metadata.begin +| ^ punctuation.definition.string.begin +| ^ punctuation.definition.string.end +| ^ punctuation.definition.metadata.end + [see `demo`](#demo (demo)) +| ^^^^^^^^^^ string.other.link.title +| ^ punctuation.definition.metadata.begin +| ^ punctuation.definition.string.begin +| ^ punctuation.definition.string.end +| ^ punctuation.definition.metadata.end + [see `demo`](#demo 'demo') +| ^^^^^^^^^^ string.other.link.title +| ^ punctuation.definition.metadata.begin +| ^ punctuation.definition.string.begin +| ^ punctuation.definition.string.end +| ^ punctuation.definition.metadata.end + Here is a ![example image](https://test.com/sublime.png "A demonstration"). +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.list.unnumbered meta.paragraph.list meta.image.inline +| ^ punctuation.definition.image.begin +| ^ punctuation.definition.string.begin +| ^ punctuation.definition.string.end +| ^ punctuation.definition.metadata +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.image +| ^^^^^^^^^^^^^^^^^ string.other.link.description.title +| ^ punctuation.definition.string.begin +| ^ punctuation.definition.string.end +| ^ punctuation.definition.metadata + Here is a ![example image](https://test.com/sublime.png 'A demonstration'). +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.list.unnumbered meta.paragraph.list meta.image.inline +| ^ punctuation.definition.image.begin +| ^ punctuation.definition.string.begin +| ^ punctuation.definition.string.end +| ^ punctuation.definition.metadata +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.image +| ^^^^^^^^^^^^^^^^^ string.other.link.description.title +| ^ punctuation.definition.string.begin +| ^ punctuation.definition.string.end +| ^ punctuation.definition.metadata + Here is a ![example image](https://test.com/sublime.png (A demonstration)). +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.list.unnumbered meta.paragraph.list meta.image.inline +| ^ punctuation.definition.image.begin +| ^ punctuation.definition.string.begin +| ^ punctuation.definition.string.end +| ^ punctuation.definition.metadata +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.image +| ^^^^^^^^^^^^^^^^^ string.other.link.description.title +| ^ punctuation.definition.string.begin +| ^ punctuation.definition.string.end +| ^ punctuation.definition.metadata + + <!-- HTML comment --> +| ^^^^^^^^^^^^^^^^^^^^^ comment.block.html + +## Heading with ending hashes ## +| <- punctuation.definition.heading +| ^^^^^^^^^^^^^^^^^^^^^^^^^^ entity.name.section +| ^ - entity.name.section +| ^^ punctuation.definition.heading + +*italic text <span>HTML element</span> end of italic text* +| <- punctuation.definition.italic +| ^ punctuation.definition.italic +| ^^^^^^ meta.tag.inline.any.html +| ^^^^^^^ meta.tag.inline.any.html + +_italic text <span>HTML element</span> end of italic text_ +| <- punctuation.definition.italic +| ^ punctuation.definition.italic +| ^^^^^^ meta.tag.inline.any.html +| ^^^^^^^ meta.tag.inline.any.html + +**bold text <span>HTML element</span> end of bold text** +| <- punctuation.definition.bold +| ^^ punctuation.definition.bold +| ^^^^^^ meta.tag.inline.any.html +| ^^^^^^^ meta.tag.inline.any.html + +__bold text <span>HTML element</span> end of bold text__ +| <- punctuation.definition.bold +| ^^ punctuation.definition.bold +| ^^^^^^ meta.tag.inline.any.html +| ^^^^^^^ meta.tag.inline.any.html + +*italic text <span>HTML element</span> end of italic text* +| <- punctuation.definition.italic +| ^ punctuation.definition.italic +| ^^^^^^ meta.tag.inline.any.html +| ^^^^^^^ meta.tag.inline.any.html + +_italic text <span>HTML element</span> end of italic text_ +| <- punctuation.definition.italic +| ^ punctuation.definition.italic +| ^^^^^^ meta.tag.inline.any.html +| ^^^^^^^ meta.tag.inline.any.html + +[link [containing] [square] brackets](#backticks) +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.other.link.title +| ^ punctuation.definition.string.end +[link `containing square] brackets] in backticks`[]](#wow) +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.other.link.title +| ^ punctuation.definition.raw.begin +| ^ punctuation.definition.raw.end +| ^ punctuation.definition.string.end +[link ``containing square]` brackets[[][] in backticks``](#wow) +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.other.link.title +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.raw.inline +| ^^ punctuation.definition.raw.begin +| ^^ punctuation.definition.raw.end +| ^ punctuation.definition.string.end +`inline markup <span></span>` +| ^^^^^^^^^^^^^ markup.raw.inline - meta.tag.inline.any.html +escaped backtick \`this is not code\` +| ^^ constant.character.escape +| ^^ constant.character.escape +| ^^^^^^^^^^^^^^^^ - markup.raw.inline + +Example 328: +*foo bar* +| <- punctuation.definition.italic.begin +| ^ punctuation.definition.italic.end + +Example 329: +This is not emphasis, because the opening `*` is followed by whitespace, and hence not part of a left-flanking delimiter run: +a * foo bar* +| ^^^^^^^^^^^ - punctuation + +Example 332: +Intraword emphasis with `*` is permitted: +foo*bar* +| ^ punctuation.definition.italic.begin +| ^ punctuation.definition.italic.end +Example 333: +5*6*78 +|^ punctuation.definition.italic.begin +| ^ punctuation.definition.italic.end + +Example 334: +_foo bar_ +| <- punctuation.definition.italic.begin +| ^ punctuation.definition.italic.end + +Example 335: +This is not emphasis, because the opening `_` is followed by whitespace: +_ foo bar_ +| <- - punctuation +| ^^^^^^^^^ - punctuation + +Example 336: +This is not emphasis, because the opening `_` is preceded by an alphanumeric and followed by punctuation: +a_"foo"_ +|^^^^^^^^ - punctuation + +Example 337: +Emphasis with `_` is not allowed inside words: +foo_bar_ +| ^^^^^ - punctuation + +Example 338: +5_6_78 +|^^^^^ - punctuation + +Example 339: +пристаням_стремятся_ +| ^^^^^^^^^^^ - punctuation + +aa_"bb"_cc_ +| ^ - punctuation +| ^ punctuation.definition.italic.begin +| ^ punctuation.definition.italic.end + +Example 341: +foo-_(bar)_ +| ^ punctuation.definition.italic.begin +| ^ punctuation.definition.italic.end + +*foo bar * +| <- punctuation.definition.italic.begin +| ^ - punctuation +* +| <- - punctuation +abc* +| ^ punctuation.definition.italic.end + +Example 347: +*foo*bar +| <- punctuation.definition.italic.begin +| ^ punctuation.definition.italic.end + +Example 348: +_foo bar _ +| <- punctuation.definition.italic.begin +| ^ - punctuation +_ +| <- - punctuation +abc_ +| ^ punctuation.definition.italic.end + +Intraword emphasis is disallowed for `_`: +_foo_bar +| <- punctuation.definition.italic.begin +| ^ - punctuation +abc_ +| ^ punctuation.definition.italic.end + +Example 353: +_foo_bar_baz_ +| <- punctuation.definition.italic.begin +| ^^^^^ - punctuation +| ^ punctuation.definition.italic.end + +Example 354: +_(bar)_. +| <- punctuation.definition.italic.begin +| ^ punctuation.definition.italic.end + +Example 355: + **foo bar** +|^^ punctuation.definition.bold.begin +| ^^ punctuation.definition.bold.end + +Example 356: +** foo bar** +| <- - punctuation +| ^^ - punctuation + +Example 358: +foo**bar** +| ^^ punctuation.definition.bold.begin +| ^^ punctuation.definition.bold.end + +Example 359: + __foo bar__ +|^^ punctuation.definition.bold.begin +| ^^ punctuation.definition.bold.end + +Example 360: +This is not strong emphasis, because the opening delimiter is followed by whitespace: +__ foo bar__ +| <- - punctuation +| ^^ - punctuation + +Example 361: +__ +| <- - punctuation + +Example 362: +a__"foo"__ +|^^^^^^^^^ - punctuation + +Example 363: +Intraword strong emphasis is forbidden with `__`: +foo__bar__ +| ^^^^^^^ - punctuation + +Example 364: +5__6__78 +|^^^^^^^ - punctuation + +Example 367: +foo-__(bar)__ +| ^^ punctuation.definition.bold.begin +| ^^ punctuation.definition.bold.end + +Example 368: +**foo bar ** +| <- punctuation.definition.bold.begin +| ^^ - punctuation +abc** +| ^^ punctuation.definition.bold.end + +Example 373: +Intraword emphasis: + **foo**bar +|^^ punctuation.definition.bold.begin +| ^^ punctuation.definition.bold.end + +Example 374: + __foo bar __ +|^^ punctuation.definition.bold.begin +| ^^ - punctuation +abc__ +| ^^ punctuation.definition.bold.end + +Example 376: +_(__foo__)_ +| <- punctuation.definition.italic.begin +| ^^ punctuation.definition.bold.begin +| ^^ punctuation.definition.bold.end +| ^ punctuation.definition.italic.end + +Example 377: +Intraword strong emphasis is forbidden with `__`: +__foo__bar +| <- punctuation.definition.bold.begin +| ^^ - punctuation +abc__ +| ^^ punctuation.definition.bold.end + +Example 379: +__foo__bar__baz__ +| <- punctuation.definition.bold.begin +| ^^ punctuation.definition.bold.end +| ^^^^^^^^^^ - punctuation + +Example 380: +This is strong emphasis, even though the closing delimiter is both left- and right-flanking, because it is followed by punctuation: +__(bar)__. +| <- punctuation.definition.bold.begin +| ^^ punctuation.definition.bold.end + +Example 381: +*foo [bar](/url)* +| <- punctuation.definition.italic.begin +| ^ punctuation.definition.italic.end +| ^^^^^^^^^^^ meta.link.inline + +Example 382: +*foo +| <- punctuation.definition.italic.begin +bar* +| ^ punctuation.definition.italic.end + +Example 383: +_foo __bar__ baz_ +| <- punctuation.definition.italic.begin +| ^^ punctuation.definition.bold.begin +| ^^ punctuation.definition.bold.end +| ^ punctuation.definition.italic.end + +Example 394: +** is not an empty emphasis +| <- - punctuation +|^ - punctuation + +Example 395: +**** is not an empty strong emphasis +| <- - punctuation +|^^^ - punctuation + +Example 396: +**foo [bar](/url)** +| <- punctuation.definition.bold.begin +| ^^^^^^^^^^^ meta.link.inline +| ^^ punctuation.definition.bold.end + +Example 397: +**foo +| <- punctuation.definition.bold.begin +bar** +| ^^ punctuation.definition.bold.end + +Example 398: +__foo _bar_ baz__ +| <- punctuation.definition.bold.begin +| ^ punctuation.definition.italic.begin +| ^ punctuation.definition.italic.end +| ^^ punctuation.definition.bold.end + +Example 408: +__ is not an empty emphasis +| <- - punctuation +|^ - punctuation + +Example 409: +____ is not an empty strong emphasis +| <- - punctuation +|^^^ - punctuation + + +Example 410: +foo *** +| ^^^ - punctuation + +Example 411: +foo *\** +| ^ punctuation.definition.italic.begin +| ^^ constant.character.escape +| ^ punctuation.definition.italic.end + +Example 412: +foo *_* +| ^ punctuation.definition.italic.begin +| ^ - punctuation +| ^ punctuation.definition.italic.end + +Example 414: +foo **\*** +| ^^ punctuation.definition.bold.begin +| ^^ constant.character.escape +| ^^ punctuation.definition.bold.end + +Example 415: +foo **_** +| ^^ punctuation.definition.bold.begin +| ^ - punctuation +| ^^ punctuation.definition.bold.end + +Example 422: +foo ___ +| ^^^^ - punctuation + +Example 423: +foo _\__ +| ^ punctuation.definition.italic.begin +| ^^ constant.character.escape +| ^ punctuation.definition.italic.end + +Example 424: +foo _*_ +| ^ punctuation.definition.italic.begin +| ^ - punctuation +| ^ punctuation.definition.italic.end + +Example 426: +foo __\___ +| ^^ punctuation.definition.bold.begin +| ^^ constant.character.escape +| ^^ punctuation.definition.bold.end + +Example 427: + +foo __*__ +| ^^ punctuation.definition.bold.begin +| ^ - punctuation +| ^^ punctuation.definition.bold.end + This text is _bold_, but this__text__is neither bold_nor_italic | ^ punctuation.definition.italic | ^^^^ markup.italic | ^ punctuation.definition.italic | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - markup.bold - markup.italic -_perform_complicated_task -| <- punctuation.definition.italic -| ^ punctuation.definition.italic -|^^^^^^^ markup.italic -| ^^^^^^^^^^^^^^^^^ - markup.italic -__perform__complicated__task -| <- punctuation.definition.bold -|^ punctuation.definition.bold -| ^^ punctuation.definition.bold -|^^^^^^^^ markup.bold -| ^^^^^^^^^^^^^^^^^^ - markup.bold -Paragraph followed immediately by a list, no blank line in between -- list item 1 -| <- markup.list.unnumbered punctuation.definition.list_item +the following is italic *and doesn't end here * but does end here* +| ^ punctuation.definition.italic.begin +| ^ - punctuation.definition.italic +| ^ punctuation.definition.italic.end +the following is bold **and doesn't end here ** but does end here** +| ^^ punctuation.definition.bold.begin +| ^^ - punctuation.definition.bold +| ^^ punctuation.definition.bold.end +the following is not bold ** test **** +| ^^ - punctuation.definition.bold.begin +| ^^^^ - punctuation.definition.bold +the following is not italic _ test ____ +| ^ - punctuation.definition.italic.begin +| ^^^^ - punctuation.definition.italic + +more **tests *** ** here** +| ^^ punctuation.definition.bold.begin +| ^^^^^^ - punctuation.definition +| ^^ punctuation.definition.bold.end +more __tests *** ** example __ here__ +| ^^ punctuation.definition.bold.begin +| ^^^^^^^^^^^^^^^^^^^^^^ - punctuation.definition +| ^^ punctuation.definition.bold.end +more _tests <span class="test_">here</span>_ +| ^ punctuation.definition.italic.begin +| ^ - punctuation.definition +| ^ punctuation.definition.italic.end +more _tests <span class="test_">_here</span>_ +| ^ punctuation.definition.italic.begin +| ^ - punctuation.definition +| ^ - punctuation +| ^ punctuation.definition.italic.end +_more `tests_` here_ +| <- punctuation.definition.italic.begin +| ^^^^^^^^ markup.raw.inline +| ^ punctuation.definition.italic.end +__more `tests__` here__ +| <- punctuation.definition.bold.begin +| ^^^^^^^^^ markup.raw.inline +| ^^ punctuation.definition.bold.end +**more `tests__` here** +| <- punctuation.definition.bold.begin +| ^^^^^^^^^ markup.raw.inline +| ^^ punctuation.definition.bold.end +**more `tests**` here** +| <- punctuation.definition.bold.begin +| ^^^^^^^^^ markup.raw.inline +| ^^ punctuation.definition.bold.end +*more `tests__` here** +| <- punctuation.definition.italic.begin +| ^^ - punctuation +abc* +| ^ punctuation.definition.italic.end + +_test <span>text_ foobar</span> +| <- punctuation +| ^ punctuation.definition.italic.end +__test <span>text__ not formatted</span> +| <- punctuation +| ^^ punctuation.definition.bold.end +*test <span>text* not formatted</span> +| <- punctuation +| ^ punctuation.definition.italic.end +**test <span>text** not formatted</span> +| <- punctuation +| ^^ punctuation.definition.bold.end +_test <span>text **formatted**</span>_ +| <- punctuation +| ^^ punctuation +| ^^ punctuation +| ^ punctuation +*test <span>text __formatted__</span>* +| <- punctuation +| ^^ punctuation +| ^^ punctuation +| ^ punctuation +*test <span>text __formatted__</span>* **more** _text_ +| <- punctuation +| ^^ punctuation +| ^^ punctuation +| ^ punctuation +| ^^ punctuation +| ^^ punctuation +| ^ punctuation +| ^ punctuation +*test <span>text* __formatted</span>__ +| <- punctuation +| ^ punctuation +| ^^ punctuation +| ^^ punctuation + +__test <span>text__ *formatted</span>* +| <- punctuation +| ^^ punctuation +| ^ punctuation +| ^ punctuation + +```js +| <- punctuation.definition.raw.code-fence.begin +| ^^ constant.other.language-name +for (var i = 0; i < 10; i++) { + console.log(i); +} +``` +| <- punctuation.definition.raw.code-fence.end + +```testing``123``` +| <- punctuation.definition.raw.begin +| ^^ - punctuation +| ^^^ punctuation.definition.raw.end +```testing``123```` +| <- punctuation.definition.raw.begin +| ^ - punctuation +| ^^^^ - punctuation +``` +| <- punctuation.definition.raw.end +``testing`123```` +| <- punctuation.definition.raw.begin +| ^ - punctuation +| ^^^^ - punctuation +more text`` +| ^^ punctuation.definition.raw.end +``text + +| <- invalid.illegal.non-terminated.raw +text +| <- - markup.raw + +inline backticks must be followed by non-whitespace `` characters`` +| ^^ invalid.deprecated.unescaped-backticks +| ^^ invalid.deprecated.unescaped-backticks + +~~~~ +| <- punctuation.definition.raw.code-fence.begin + ~~~~ +| ^^^ punctuation.definition.raw.code-fence.end + +~~~~~test~ +| ^^^^^^^^^ meta.paragraph - punctuation - constant - markup.raw + +~~~~~~test +| ^^^^ punctuation.definition.raw.code-fence.begin +| ^^^^ constant.other.language-name +~~~~~~ +| ^^^^^ punctuation.definition.raw.code-fence.end + +```test +| ^^^^ constant.other.language-name + ``` +| ^^^ punctuation.definition.raw.code-fence.end + +hello world ````test```` +| ^^^^^^^^^^^^ markup.raw.inline +| ^ - markup.raw + +`foo `` bar` +| ^^^^^^ markup.raw.inline - punctuation +| ^ punctuation.definition.raw.end + +hard line break +| ^^ meta.hard-line-break punctuation.definition.hard-line-break +hard line break\ +| ^ meta.hard-line-break constant.character.escape +hard line break +| ^^^^^ meta.hard-line-break punctuation.definition.hard-line-break +soft line break +| ^^ - meta.hard-line-break +soft line break +| ^^ - meta.hard-line-break + +### foo +| ^^^ - meta.hard-line-break +### foo\ +| ^ - meta.hard-line-break + +`inline code with trailing spaces +| ^^^ - meta.hard-line-break +not a hard line break` + +*test + +| <- invalid.illegal.non-terminated.italic +abc* +| ^ - punctuation + +_test + +| <- invalid.illegal.non-terminated.italic +abc_ +| ^ - punctuation + +**test + +| <- invalid.illegal.non-terminated.bold +abc** +| ^^ - punctuation + +__test + +| <- invalid.illegal.non-terminated.bold +abc__ +| ^^ - punctuation + +__test\ +| ^ meta.hard-line-break constant.character.escape +testing__ + +- test *testing +blah* +| ^ markup.list.unnumbered meta.paragraph.list markup.italic punctuation.definition.italic.end +- fgh +- *ghgh +| ^ markup.list.unnumbered meta.paragraph.list meta.paragraph.list markup.italic punctuation.definition.italic.begin +- fgfg +| <- markup.list.unnumbered meta.paragraph.list punctuation.definition.list_item +- _test + +| <- markup.list.unnumbered meta.paragraph.list markup.italic invalid.illegal.non-terminated.italic + still a list item +| ^^^^^^^^^^^^^^^^^^ markup.list.unnumbered meta.paragraph.list +- * * * * * * * +| <- punctuation.definition.list_item +| ^^^^^^^^ markup.list.unnumbered meta.paragraph.list meta.paragraph.list meta.separator.thematic-break +| ^ punctuation.definition.thematic-break +| ^ punctuation.definition.thematic-break +| ^ punctuation.definition.thematic-break +| ^ punctuation.definition.thematic-break +| ^ punctuation.definition.thematic-break +| ^ punctuation.definition.thematic-break +| ^ punctuation.definition.thematic-break +| ^ - punctuation.definition.thematic-break +| ^ - punctuation.definition.thematic-break +| ^ - punctuation.definition.thematic-break +| ^ - punctuation.definition.thematic-break +| ^ - punctuation.definition.thematic-break +| ^ - punctuation.definition.thematic-break + still a list item +| ^^^^^^^^^^^^^^^^^^ markup.list.unnumbered meta.paragraph.list + +Example 407: +**foo [*bar*](/url)** +| <- punctuation.definition.bold.begin +| ^^^^^^^^^^^^^ markup.bold meta.link.inline +| ^^ punctuation.definition.bold.end +| ^ punctuation.definition.italic.begin +| ^ punctuation.definition.italic.end +**foo [_bar_](/url)** +| <- punctuation.definition.bold.begin +| ^^^^^^^^^^^^^ markup.bold meta.link.inline +| ^^ punctuation.definition.bold.end +| ^ punctuation.definition.italic.begin +| ^ punctuation.definition.italic.end +_foo [**bar**](/url)_ +| <- punctuation.definition.italic.begin +| ^^^^^^^^^^^^^^^ markup.italic meta.link.inline +| ^ punctuation.definition.italic.end +| ^^ punctuation.definition.bold.begin +| ^^ punctuation.definition.bold.end + + +1. Open `Command Palette` using menu item `Tools → Command Palette...` +|^ markup.list.numbered punctuation.definition.list_item +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.list.numbered meta.paragraph.list markup.raw.inline +2. Choose `Package Control: Install Package` + +[**Read more →**][details] +|^^ punctuation.definition.bold.begin +| ^^^^^^^ constant.character.entity.html +| ^^ punctuation.definition.bold.end +| ^^^^^^^ constant.other.reference.link + +[Read more →][details] +| ^^^^^^^ constant.character.entity.html +| ^^^^^^^ constant.other.reference.link + +[Read more <span style="font-weight: bold;">→</span>][details] +|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.other.link.title +| ^^^^^^^^^^^^^^^^^^ source.css +| ^^^^^^^ constant.character.entity.html +| ^^^^^^^ constant.other.reference.link + +[![Cool ★ Image - Click to Enlarge][img-example]][img-example] +|^ punctuation.definition.image.begin +| ^^^^^^^^^^^ constant.other.reference.link +| ^ punctuation.definition.string.end +| ^^^^^^^^^^^ constant.other.reference.link + +[![Cool ★ Image - Click to Enlarge](http://www.sublimetext.com/anim/rename2_packed.png)](http://www.sublimetext.com/anim/rename2_packed.png) +|^ punctuation.definition.image.begin +| ^ punctuation.definition.metadata.begin +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.image +| ^ punctuation.definition.metadata.end +| ^ punctuation.definition.metadata.begin +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link +| ^ punctuation.definition.metadata.end + +[img-example]: http://www.sublimetext.com/anim/rename2_packed.png +|^^^^^^^^^^^ meta.link.reference.def constant.other.reference.link +| ^ punctuation.separator.key-value +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link + +[//]: # (This is a comment without a line-break.) +| ^ meta.link.reference.def markup.underline.link +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.other.link.description.title + +[//]: # (This is a comment with a +| ^ meta.link.reference.def markup.underline.link +| ^ punctuation.definition.string.begin + line-break.) +| ^ punctuation.definition.string.end + +[//]: # (testing)blah +| ^ punctuation.definition.string.begin +|^^^^^^^^^^^^^^^^ meta.link.reference.def +| ^ punctuation.definition.string.end +| ^^^^ invalid.illegal.expected-eol + +[//]: # (testing +blah +| <- meta.link.reference.def string.other.link.description.title + +| <- invalid.illegal.non-terminated.link-title +text +| <- meta.paragraph - meta.link.reference.def + +[foo]: <bar> "test" +| ^ punctuation.definition.link.begin +| ^^^ markup.underline.link +| ^ punctuation.definition.link.end +| ^^^^^^ string.other.link.description.title + +[foo]: <bar>> "test" +| ^ punctuation.definition.link.begin +| ^^^ markup.underline.link +| ^ punctuation.definition.link.end +| ^^^^^^^^ invalid.illegal.expected-eol + +- a + - b + - c + - d +| ^ punctuation.definition.list_item + text here +| ^^^^^^^^^^ markup.list.unnumbered meta.paragraph.list - markup.raw.block + + code here + | ^^^^^^^^ markup.raw.block + + - e +| ^ punctuation.definition.list_item + + code here + + > block quote code here +| ^ markup.list.unnumbered markup.quote punctuation.definition.blockquote +| ^^^^^^^^^^^^^^^^^^^^^^ markup.list.unnumbered markup.quote markup.raw.block + + > > test +| ^ markup.list.unnumbered markup.quote punctuation.definition.blockquote +| ^ markup.list.unnumbered markup.quote markup.quote punctuation.definition.blockquote - markup.raw.block + + - f +| ^ markup.list.unnumbered punctuation.definition.list_item + 1. test +| ^ punctuation.definition.list_item + +abc +| <- meta.paragraph - markup.list