Skip to content

Commit

Permalink
Merge branch 'st3-develop' into st3176
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe committed Oct 22, 2024
2 parents d16b9aa + a02d683 commit 182a5a5
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 27 deletions.
2 changes: 1 addition & 1 deletion plugins/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
55 changes: 29 additions & 26 deletions syntaxes/Markdown.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -38,55 +38,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: |-
Expand Down
145 changes: 145 additions & 0 deletions tests/syntax_test_markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -5718,6 +5718,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 ############################################################
Expand Down Expand Up @@ -7057,6 +7076,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 #########################################################
Expand Down Expand Up @@ -7168,6 +7208,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 #################################################################
Expand Down Expand Up @@ -7548,6 +7609,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 #############################################################
Expand Down

0 comments on commit 182a5a5

Please sign in to comment.