diff --git a/plugins/view.py b/plugins/view.py index 74dc097f..0b5ff18f 100644 --- a/plugins/view.py +++ b/plugins/view.py @@ -95,7 +95,7 @@ class MdeCenteredLineKeeper(MdeViewEventListener): def on_modified(self): sel = self.view.sel() - if sel and len(sel) != 1: + if not sel or len(sel) != 1: return settings = self.view.settings() diff --git a/syntaxes/Code Block Syntaxes.sublime-completions b/syntaxes/Code Block Syntaxes.sublime-completions index a5439ff7..6c78dd32 100644 --- a/syntaxes/Code Block Syntaxes.sublime-completions +++ b/syntaxes/Code Block Syntaxes.sublime-completions @@ -664,6 +664,20 @@ "details": "Specifies <code>SQL</code> code highlighting" }, + // WASM + { + "trigger": "wast", + "annotation": "WAST", + "kind": ["markup", "s", "Syntax"], + "details": "Specifies <code>WebAssembly Text</code> code highlighting" + }, + { + "trigger": "wit", + "annotation": "WIT", + "kind": ["markup", "s", "Syntax"], + "details": "Specifies <code>WabAssembly Interface Type</code> code highlighting" + }, + // XML { "trigger": "atom", diff --git a/syntaxes/Markdown.sublime-syntax b/syntaxes/Markdown.sublime-syntax index f64cb4ac..05b76d66 100644 --- a/syntaxes/Markdown.sublime-syntax +++ b/syntaxes/Markdown.sublime-syntax @@ -50,55 +50,58 @@ variables: backticks: |- (?x: - (`{4})(?![\s`])(?:[^`]+(?=`)|(?!`{4})`+(?!`))+(`{4})(?!`) # 4 backticks, followed by at least one non whitespace, non backtick character, followed by (less than 4 backticks, or at least one non backtick character) at least once, followed by exactly 4 backticks - | (`{3})(?![\s`])(?:[^`]+(?=`)|(?!`{3})`+(?!`))+(`{3})(?!`) # 3 backticks, followed by at least one non whitespace, non backtick character, followed by (less than 3 backticks, or at least one non backtick character) at least once, followed by exactly 3 backticks - | (`{2})(?![\s`])(?:[^`]+(?=`)|(?!`{2})`+(?!`))+(`{2})(?!`) # 2 backticks, followed by at least one non whitespace, non backtick character, followed by (less than 2 backticks, or at least one non backtick character) at least once, followed by exactly 2 backticks - | (`{1})(?![\s`])(?:[^`]+(?=`)|(?!`{1})`+(?!`))+(`{1})(?!`) # 1 backtick, followed by at least one non whitespace, non backtick character, followed by ( at least one non backtick character) at least once, followed by exactly 1 backtick + (`{4})[^`](?:[^`]|(?!`{4})`+[^`])*(`{4})(?!`) # 4 backticks, followed by at least one non backtick character, followed by (less than 4 backticks, or at least one non backtick character) at least once, followed by exactly 4 backticks + | (`{3})[^`](?:[^`]|(?!`{3})`+[^`])*(`{3})(?!`) # 3 backticks, followed by at least one non backtick character, followed by (less than 3 backticks, or at least one non backtick character) at least once, followed by exactly 3 backticks + | (`{2})[^`](?:[^`]|(?!`{2})`+[^`])*(`{2})(?!`) # 2 backticks, followed by at least one non backtick character, followed by (less than 2 backticks, or at least one non backtick character) at least once, followed by exactly 2 backticks + | (`{1})[^`](?:[^`]|(?!`{1})`+[^`])*(`{1})(?!`) # 1 backtick, followed by at least one non backtick character, followed by ( at least one non backtick character) at least once, followed by exactly 1 backtick ) escapes: \\[-+*/!"#$%&'(),.:;<=>?@\[\\\]^_`{|}~] balance_square_brackets: |- (?x: (?: - (?:{{escapes}})+ # escape characters - | [^\[\]`\\]+(?=[\[\]`\\]|$) # anything that isn't a square bracket or a backtick or the start of an escape character + \\. # maybe escaped character (be lazy) + | [^\[\]`] # anything that isn't a square bracket or backtick | {{backticks}} # inline code - | \[(?: # nested square brackets (one level deep) - [^\[\]`]+(?=[\[\]`]) # anything that isn't a square bracket or a backtick - {{backticks}}? # balanced backticks - )*\] # closing square bracket + | \[ (?: # nested square brackets (one level deep) + \\. # maybe escaped character (be lazy) + | [^\[\]`] # anything that isn't a square bracket or backtick + | {{backticks}} # inline code + )* \] # closing square bracket )+ ) balance_square_brackets_and_emphasis: |- (?x: (?: - (?:{{escapes}})+ # escape characters - | [^\[\]`\\_*]+(?=[\[\]`\\_*]|$) # anything that isn't a square bracket, a backtick, the start of an escape character, or an emphasis character + \\. # maybe escaped character (be lazy) + | [^\[\]`_*] # anything that isn't a square bracket, backtick or emphasis | {{backticks}} # inline code - | \[(?: # nested square brackets (one level deep) - [^\[\]`]+(?=[\[\]`]) # anything that isn't a square bracket or a backtick - {{backticks}}? # balanced backticks - )*\] # closing square bracket + | \[ (?: # nested square brackets (one level deep) + \\. # maybe escaped character (be lazy) + | [^\[\]`_*] # anything that isn't a square bracket, backtick or emphasis + | {{backticks}} # inline code + )* \] # closing square bracket )+ # at least one character ) balance_square_brackets_pipes_and_emphasis: |- (?x: (?: - (?:{{escapes}})+ # escape characters - | [^\[\]`\\_*|]+(?=[\[\]`\\_*|]|$) # anything that isn't a square bracket, a backtick, the start of an escape character, or an emphasis character + \\. # maybe escaped character (be lazy) + | [^\[\]`_*|] # anything that isn't a square bracket, backtick or emphasis or table cell separator | {{backticks}} # inline code - | \[(?: # nested square brackets (one level deep) - [^\[\]`]+(?=[\[\]`]) # anything that isn't a square bracket or a backtick - {{backticks}}? # balanced backticks - )*\] # closing square bracket + | \[ (?: # nested square brackets (one level deep) + \\. # maybe escaped character (be lazy) + | [^\[\]`_*|] # anything that isn't a square bracket, backtick or emphasis or table cell separator + | {{backticks}} # inline code + )* \] # 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}}+__ + \* (?!\*){{balance_square_brackets_and_emphasis}}\* (?!\*) + | \*\* {{balance_square_brackets_and_emphasis}}\*\* + | _ (?!_) {{balance_square_brackets_and_emphasis}}_ (?!_) + | __ {{balance_square_brackets_and_emphasis}}__ ) table_cell: |- @@ -1182,6 +1185,8 @@ contexts: - include: fenced-twee - include: fenced-twig - include: fenced-verilog + - include: fenced-wast + - include: fenced-wit - include: fenced-xonsh fenced-actionscript: @@ -2858,6 +2863,50 @@ contexts: 1: punctuation.definition.raw.code-fence.end.markdown 2: meta.fold.code-fence.end.markdown + fenced-wast: + - match: |- + (?x) + {{fenced_code_block_start}} + (?i:\s*(wast)) + {{fenced_code_block_trailing_infostring_characters}} + captures: + 0: meta.code-fence.definition.begin.wast.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 5: constant.other.language-name.markdown + 6: comment.line.infostring.markdown + 7: meta.fold.code-fence.begin.markdown + embed: scope:source.wast + embed_scope: + markup.raw.code-fence.wast.markdown-gfm + source.wast + escape: '{{fenced_code_block_escape}}' + escape_captures: + 0: meta.code-fence.definition.end.wast.markdown-gfm + 1: punctuation.definition.raw.code-fence.end.markdown + 2: meta.fold.code-fence.end.markdown + + fenced-wit: + - match: |- + (?x) + {{fenced_code_block_start}} + (?i:\s*(wit)) + {{fenced_code_block_trailing_infostring_characters}} + captures: + 0: meta.code-fence.definition.begin.wit.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 5: constant.other.language-name.markdown + 6: comment.line.infostring.markdown + 7: meta.fold.code-fence.begin.markdown + embed: scope:source.wit + embed_scope: + markup.raw.code-fence.wit.markdown-gfm + source.wit + escape: '{{fenced_code_block_escape}}' + escape_captures: + 0: meta.code-fence.definition.end.wit.markdown-gfm + 1: punctuation.definition.raw.code-fence.end.markdown + 2: meta.fold.code-fence.end.markdown + fenced-xonsh: - match: |- (?x) diff --git a/tests/syntax_test_markdown.md b/tests/syntax_test_markdown.md index 4619ae89..f7153ea8 100644 --- a/tests/syntax_test_markdown.md +++ b/tests/syntax_test_markdown.md @@ -2043,9 +2043,9 @@ unclosed_paren = ( | ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - merkup function foo () { -| <- markup.raw.code-fence.shell.markdown-gfm meta.function.shell keyword.declaration.function.shell +| <- markup.raw.code-fence.shell.markdown-gfm meta.function keyword.declaration.function.shell } -| <- markup.raw.code-fence.shell.markdown-gfm meta.function.shell punctuation.section +| <- markup.raw.code-fence.shell.markdown-gfm meta.function punctuation.section $ ls ~ | <- markup.raw.code-fence.shell.markdown-gfm source.shell.interactive comment.other.shell @@ -2394,7 +2394,7 @@ okay <style type="text/css"> -| ^^^^^^^^^^^^^^^ meta.disable-markdown meta.tag.style.begin.html meta.attribute-with-value.html +| ^^^^^^^^^^^^^^^ meta.disable-markdown meta.tag.style.begin.html meta.attribute-with-value h1 {color:red;} | ^^^^^ meta.disable-markdown source.css.embedded.html meta.property-list.css meta.property-name.css support.type.property-name.css @@ -6047,6 +6047,25 @@ blah* | ^ punctuation.definition.string.begin.markdown | ^ punctuation.definition.string.end.markdown | ^ punctuation.definition.metadata.end.markdown + + Complex ![image $\ce{H2O}$.](./img/image6.png){#fig:image6 height=12.09cm } + | ^^^^^^^^^^^^^^^^^^^^ meta.image.inline.description.markdown + | ^^ punctuation.definition.image.begin.markdown + | ^^^^^^^^^^ markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + | ^ punctuation.definition.image.end.markdown + | ^^^^^^^^^^^^^^^^^^ meta.image.inline.metadata.markdown + | ^ punctuation.definition.metadata.begin.markdown + | ^^^^^^^^^^^^^^^^ markup.underline.link.image.markdown + | ^ punctuation.definition.metadata.end.markdown + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.image.inline.attributes.markdown + | ^ punctuation.definition.attributes.begin.markdown + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.markdown + | ^^^^^^^^^^^ entity.other.attribute-name.markdown + | ^^^^^^ entity.other.attribute-name.markdown + | ^ punctuation.separator.key-value.markdown + | ^^^^^^^ string.unquoted.markdown + | ^ punctuation.definition.attributes.end.markdown + # TEST: CODE SPANS ############################################################ @@ -7379,6 +7398,27 @@ A ==![highlight](https://image-url)== A ==[![highlight](image-url)](link-url)== | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown markup.highlight.markdown +A ==![image $\ce{H2O}$.](./img/image6.png){#fig:image6 height=12.09cm }== +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.highlight.markdown +| ^^ punctuation.definition.highlight.begin.markdown +| ^^^^^^^^^^^^^^^^^^^^ meta.image.inline.description.markdown +| ^^ punctuation.definition.image.begin.markdown +| ^^^^^^^^^^ markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^ punctuation.definition.image.end.markdown +| ^^^^^^^^^^^^^^^^^^ meta.image.inline.metadata.markdown +| ^ punctuation.definition.metadata.begin.markdown +| ^^^^^^^^^^^^^^^^ markup.underline.link.image.markdown +| ^ punctuation.definition.metadata.end.markdown +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.image.inline.attributes.markdown +| ^ punctuation.definition.attributes.begin.markdown +| ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.markdown +| ^^^^^^^^^^^ entity.other.attribute-name.markdown +| ^^^^^^ entity.other.attribute-name.markdown +| ^ punctuation.separator.key-value.markdown +| ^^^^^^^ string.unquoted.markdown +| ^ punctuation.definition.attributes.end.markdown +| ^^ punctuation.definition.highlight.end.markdown + # TEST: STRIKETHROUGH ######################################################### @@ -7490,6 +7530,27 @@ A ~~![highlight](https://image-url)~~ A ~~[![highlight](image-url)](link-url)~~ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown markup.strikethrough.markdown-gfm +A ~~![image $\ce{H2O}$.](./img/image6.png){#fig:image6 height=12.09cm }~~ +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.strikethrough.markdown-gfm +| ^^ punctuation.definition.strikethrough.begin.markdown +| ^^^^^^^^^^^^^^^^^^^^ meta.image.inline.description.markdown +| ^^ punctuation.definition.image.begin.markdown +| ^^^^^^^^^^ markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^ punctuation.definition.image.end.markdown +| ^^^^^^^^^^^^^^^^^^ meta.image.inline.metadata.markdown +| ^ punctuation.definition.metadata.begin.markdown +| ^^^^^^^^^^^^^^^^ markup.underline.link.image.markdown +| ^ punctuation.definition.metadata.end.markdown +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.image.inline.attributes.markdown +| ^ punctuation.definition.attributes.begin.markdown +| ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.markdown +| ^^^^^^^^^^^ entity.other.attribute-name.markdown +| ^^^^^^ entity.other.attribute-name.markdown +| ^ punctuation.separator.key-value.markdown +| ^^^^^^^ string.unquoted.markdown +| ^ punctuation.definition.attributes.end.markdown +| ^^ punctuation.definition.strikethrough.end.markdown + # TEST: LINKS ################################################################# @@ -7870,6 +7931,90 @@ Here is a ![Image Ref Alt][1]. | ^ markup.underline.link.markdown | ^ punctuation.definition.metadata.end.markdown +A complex ![image $\ce{H2O}$.](./img/image6.png){#fig:image6 height=12.09cm } +| ^^^^^^^^^^^^^^^^^^^^ meta.image.inline.description.markdown +| ^^ punctuation.definition.image.begin.markdown +| ^^^^^^^^^^ markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^ punctuation.definition.image.end.markdown +| ^^^^^^^^^^^^^^^^^^ meta.image.inline.metadata.markdown +| ^ punctuation.definition.metadata.begin.markdown +| ^^^^^^^^^^^^^^^^ markup.underline.link.image.markdown +| ^ punctuation.definition.metadata.end.markdown +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.image.inline.attributes.markdown +| ^ punctuation.definition.attributes.begin.markdown +| ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.markdown +| ^^^^^^^^^^^ entity.other.attribute-name.markdown +| ^^^^^^ entity.other.attribute-name.markdown +| ^ punctuation.separator.key-value.markdown +| ^^^^^^^ string.unquoted.markdown +| ^ punctuation.definition.attributes.end.markdown + +With codepsan ![`a`b]() +| ^^^^^^^ meta.image.inline.description.markdown +| ^^ punctuation.definition.image.begin.markdown +| ^^^ markup.raw.inline.markdown +| ^ punctuation.definition.raw.begin.markdown +| ^ punctuation.definition.raw.end.markdown +| ^ punctuation.definition.image.end.markdown +| ^^ meta.image.inline.metadata.markdown +| ^ punctuation.definition.metadata.begin.markdown +| ^ punctuation.definition.metadata.end.markdown + +With codepsan ![``a`b``]() +| ^^^^^^^^^^ meta.image.inline.description.markdown +| ^^ punctuation.definition.image.begin.markdown +| ^^^^^^^ markup.raw.inline.markdown +| ^^ punctuation.definition.raw.begin.markdown +| ^^ punctuation.definition.raw.end.markdown +| ^ punctuation.definition.image.end.markdown +| ^^ meta.image.inline.metadata.markdown +| ^ punctuation.definition.metadata.begin.markdown +| ^ punctuation.definition.metadata.end.markdown + +With codepsan ![` `]() +| ^^^^^^ meta.image.inline.description.markdown +| ^^ punctuation.definition.image.begin.markdown +| ^^^ markup.raw.inline.markdown +| ^ punctuation.definition.raw.begin.markdown +| ^ punctuation.definition.raw.end.markdown +| ^ punctuation.definition.image.end.markdown +| ^^ meta.image.inline.metadata.markdown +| ^ punctuation.definition.metadata.begin.markdown +| ^ punctuation.definition.metadata.end.markdown + +With codepsan ![`` ` ``]() +| ^^^^^^^^^^ meta.image.inline.description.markdown +| ^^ punctuation.definition.image.begin.markdown +| ^^^^^^^ markup.raw.inline.markdown +| ^^ punctuation.definition.raw.begin.markdown +| ^^ punctuation.definition.raw.end.markdown +| ^ punctuation.definition.image.end.markdown +| ^^ meta.image.inline.metadata.markdown +| ^ punctuation.definition.metadata.begin.markdown +| ^ punctuation.definition.metadata.end.markdown + +With codepsan ![``` `` ```]() +| ^^^^^^^^^^^^^ meta.image.inline.description.markdown +| ^^ punctuation.definition.image.begin.markdown +| ^^^^^^^^^^ markup.raw.inline.markdown +| ^^^ punctuation.definition.raw.begin.markdown +| ^^^ punctuation.definition.raw.end.markdown +| ^ punctuation.definition.image.end.markdown +| ^^ meta.image.inline.metadata.markdown +| ^ punctuation.definition.metadata.begin.markdown +| ^ punctuation.definition.metadata.end.markdown + +With codepsan ![```` ``` ````]() +| ^^^^^^^^^^^^^^^^ meta.image.inline.description.markdown +| ^^ punctuation.definition.image.begin.markdown +| ^^^^^^^^^^^^^ markup.raw.inline.markdown +| ^^^^ punctuation.definition.raw.begin.markdown +| ^^^^ punctuation.definition.raw.end.markdown +| ^ punctuation.definition.image.end.markdown +| ^^ meta.image.inline.metadata.markdown +| ^ punctuation.definition.metadata.begin.markdown +| ^ punctuation.definition.metadata.end.markdown + # TEST: FOOTNOTES #############################################################