From 7282e8330ce72c3a3c457f1e9decad5a648f99a3 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 30 Oct 2022 17:23:48 +0100 Subject: [PATCH 01/11] Plugins: Modify heading style only before saving Fixes #710 --- plugins/headings/style.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/headings/style.py b/plugins/headings/style.py index 72b94761..32eb0fb2 100644 --- a/plugins/headings/style.py +++ b/plugins/headings/style.py @@ -66,6 +66,8 @@ def on_load(self): def on_pre_save(self): self.auto_detect_heading_style() + if self.view.settings().get("mde.auto_match_heading_hashes", False): + self.view.run_command("mde_match_heading_hashes") def auto_detect_heading_style(self): view = self.view @@ -86,6 +88,3 @@ def auto_detect_heading_style(self): view.settings().set("mde.match_heading_hashes", num_trailing / num_leading > 0.5) else: view.settings().erase("mde.match_heading_hashes") - - if view.settings().get("mde.auto_match_heading_hashes", False): - view.run_command("mde_match_heading_hashes") From c968ddcf5088f40476d913c638e0a8a3f4810489 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 30 Oct 2022 17:45:17 +0100 Subject: [PATCH 02/11] Plugins: Don't disable default Markdown as of ST4132+ Ruby on Rails depends on default Markdown package as of ST 4132, so disabling it would cause errors. --- plugins/bootstrap.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/bootstrap.py b/plugins/bootstrap.py index 0fba5ee2..9f863fac 100644 --- a/plugins/bootstrap.py +++ b/plugins/bootstrap.py @@ -102,7 +102,8 @@ def on_after_install(): def async_worker(): bootstrap_syntax_assignments() - disable_native_markdown_package() + if int(sublime.version()) < 4132: + disable_native_markdown_package() clear_invalid_color_schemes() # Update bootstrap cookie. open(bootstrapped, "w").write(BOOTSTRAP_VERSION) From 2fc0a841912fecf5244b2a028216927152f862a8 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 5 Nov 2022 17:24:03 +0100 Subject: [PATCH 03/11] Syntax: Fix inline raw code spans This commit uses branching to render inline code spans only if they are properly closed. --- syntaxes/Markdown.sublime-syntax | 21 +++++++++++----- tests/syntax_test_markdown.md | 41 +++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/syntaxes/Markdown.sublime-syntax b/syntaxes/Markdown.sublime-syntax index c89d792f..4e6d7327 100644 --- a/syntaxes/Markdown.sublime-syntax +++ b/syntaxes/Markdown.sublime-syntax @@ -2821,20 +2821,29 @@ contexts: code-spans: # https://spec.commonmark.org/0.30/#code-spans - - match: (`+)(?!`) + - match: (?=`+) + branch_point: code-spans + branch: + - code-span + - no-code-span + + code-span: + - match: (`+) scope: punctuation.definition.raw.begin.markdown - push: code-span-body + set: code-span-body code-span-body: - meta_scope: markup.raw.inline.markdown - match: \1(?!`) scope: punctuation.definition.raw.end.markdown pop: 1 - - match: '`+' - - match: ^\s*$\n? - scope: invalid.illegal.non-terminated.raw.markdown + - match: \`+ + - match: '{{list_paragraph_end}}' + fail: code-spans + + no-code-span: + - match: \`+ pop: 1 - - include: paragraph-end ###[ INLINE: EMPHASIS ]####################################################### diff --git a/tests/syntax_test_markdown.md b/tests/syntax_test_markdown.md index 92ad4d91..97bea0b4 100644 --- a/tests/syntax_test_markdown.md +++ b/tests/syntax_test_markdown.md @@ -5665,6 +5665,16 @@ paragraph | ^ punctuation.definition.heading.begin.markdown | ^^^^^^^ entity.name.section.markdown + > - list item ```math equation + > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.quote.markdown markup.list.unnumbered.markdown meta.paragraph.list.markdown - markup.raw + > + > - list item ```math equation + > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.quote.markdown markup.list.unnumbered.markdown meta.paragraph.list.markdown - markup.raw + > - list item ```math``` equation + > | ^^^^^^^^^^^^^^ markup.quote.markdown markup.list.unnumbered.markdown meta.paragraph.list.markdown - markup.raw + > | ^^^^^^^^^^^^^^^^^ markup.quote.markdown markup.list.unnumbered.markdown meta.paragraph.list.markdown markup.raw.inline.markdown + > | ^^^^^^^^^^ markup.quote.markdown markup.list.unnumbered.markdown meta.paragraph.list.markdown - markup.raw + ## https://custom-tests/list-blocks/items-with-code-spans - `` | `` (foo/bar.baz) @@ -5723,6 +5733,16 @@ blah* |^^^^^^^^^^^^^^^^^^^^^^^^^ markup.list.unnumbered.markdown meta.paragraph.list.markdown | ^^^^^^^ meta.tag +- list item ```math equation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.list.unnumbered.markdown meta.paragraph.list.markdown - markup.raw + + - list item ```math equation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.list.unnumbered.markdown meta.paragraph.list.markdown - markup.raw + - list item ```math``` equation + | ^^^^^^^^^^^^^^ markup.list.unnumbered.markdown meta.paragraph.list.markdown - markup.raw + | ^^^^^^^^^^^^^^^^^ markup.list.unnumbered.markdown meta.paragraph.list.markdown markup.raw.inline.markdown + | ^^^^^^^^^^ markup.list.unnumbered.markdown meta.paragraph.list.markdown - markup.raw + ## https://custom-tests/list-blocks/items-with-links-and-references 1. [see `demo`](#demo "demo") @@ -5814,8 +5834,9 @@ more text`` | ^^ punctuation.definition.raw.end ``text +| <- meta.paragraph.markdown - markup.raw +|^^^^^^ meta.paragraph.markdown - markup.raw -| <- invalid.illegal.non-terminated.raw text | <- - markup.raw @@ -5957,33 +5978,25 @@ foo `` |^^^^^^^^^^ markup.raw.inline.markdown -| ^^ - markup.raw - -| <- invalid.illegal.non-terminated.raw +| ^^^^ - markup.raw - punctuation ## https://spec.commonmark.org/0.30/#example-344 ` -| ^^^^^^^^^ meta.tag.inline -| ^ punctuation.definition.raw.begin - -| <- invalid.illegal.non-terminated.raw +| ^^^^^^^^^^ meta.tag.inline.a +| ^^ - meta.tag - markup.raw - punctuation ## https://spec.commonmark.org/0.30/#example-345 `` |^^^^^^^^^^^^^^^^^ markup.raw.inline -| ^ punctuation.definition.raw.begin - -| <- invalid.illegal.non-terminated.raw +| ^^^^^^ - meta.tag - markup.raw - punctuation ## https://spec.commonmark.org/0.30/#example-346 ` |^^^^^^^^^^^^^^^^^^^ markup.underline.link -| ^ punctuation.definition.raw.begin - -| <- invalid.illegal.non-terminated.raw +| ^ - markup.raw - punctuation # TEST: EMPHASIS ############################################################## From 855274f8325bd114969e5774848aafd548f11cc2 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 19 Nov 2022 12:47:32 +0100 Subject: [PATCH 04/11] [Markdown] Fix GFM auto-link termination This commit adds some undocumented punctuation to the set of terminating autolink characters. --- syntaxes/Markdown.sublime-syntax | 8 +-- tests/syntax_test_markdown.md | 86 ++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 3 deletions(-) diff --git a/syntaxes/Markdown.sublime-syntax b/syntaxes/Markdown.sublime-syntax index 99a1cd2d..682d5844 100644 --- a/syntaxes/Markdown.sublime-syntax +++ b/syntaxes/Markdown.sublime-syntax @@ -3283,6 +3283,7 @@ contexts: - link-url-scheme-separator # Github Flavoured Markdown # After a valid domain, zero or more non-space non-< characters may follow + # https://github.github.com/gfm/#autolinks-extension- - match: (?:(?:https|http|ftp)(://)|www\.)[\w-]+ captures: 1: punctuation.separator.path.markdown @@ -3311,14 +3312,15 @@ contexts: # 3. Trailing punctuation (specifically, ?, !, ., ,, :, *, _, and ~) will not # be considered part of the autolink, though they may be included in the # interior # of the link - - match: (?=(?:\)|(?:{{html_entity}})*)[?!.,:*_~]*[\s<]) + # Note: contains some empirical (undocumented) punctuation such as ;, ', " + - match: (?=(?:\)|(?:{{html_entity}})*)[?!.,:;*_~'"]*[\s<]) pop: true - include: autolink-inet-common autolink-inet-group: - match: \) - pop: true - - match: (?=(?:{{html_entity}})*[?!.,:*_~]*[\s<]) + pop: 1 + - match: (?=(?:{{html_entity}})*[?!.,:;*_~'"]*[\s<]) pop: true - include: autolink-inet-common diff --git a/tests/syntax_test_markdown.md b/tests/syntax_test_markdown.md index 6e466e92..6d393ad1 100644 --- a/tests/syntax_test_markdown.md +++ b/tests/syntax_test_markdown.md @@ -7358,6 +7358,92 @@ Visit www.commonmark.org/a.b. | ^ - markup.underline.link | ^ punctuation.separator.path.markdown +Visit www.commonmark.org? +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link + +Visit www.commonmark.org! +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link + +Visit www.commonmark.org: +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link + +Visit www.commonmark.org; +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link + +Visit www.commonmark.org* +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link + +Visit www.commonmark.org_ +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link + +Visit www.commonmark.org~ +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link + +Visit 'www.commonmark.org' +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link + +Visit "www.commonmark.org" +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link + +Visit "www.commonmark.org/q'uo"te" +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link +Visit www.commonmark.org= +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link + +Visit www.commonmark.org& +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link + +Visit www.commonmark.org% +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link + +Visit www.commonmark.org$ +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link + +Visit www.commonmark.org# +| ^ - markup.underline.link +| ^^^^^^^^^^^^^^^^^^^ meta.paragraph meta.link.inet.markdown markup.underline.link +| ^ - markup.underline.link + +www.google.com/search?q=(business' +|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.link.inet.markdown markup.underline.link +| ^ punctuation.separator.path.markdown +| ^ punctuation.separator.path.markdown +| ^ - markup.underline.link + +www.google.com/search?q=(business" +|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.link.inet.markdown markup.underline.link +| ^ punctuation.separator.path.markdown +| ^ punctuation.separator.path.markdown +| ^ - markup.underline.link + www.google.com/search?q=(business))+ok |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.link.inet.markdown markup.underline.link | ^ punctuation.separator.path.markdown From 99e476dd65629383d96e36b7050ba33117a9f72b Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 22 Nov 2022 19:51:19 +0100 Subject: [PATCH 05/11] Syntax: Relax math related syntax tests This commit intents to avoid failing syntax tests caused by ST's LaTeX syntax being changed. --- tests/syntax_test_markdown.md | 182 +++++++++++++++++----------------- 1 file changed, 91 insertions(+), 91 deletions(-) diff --git a/tests/syntax_test_markdown.md b/tests/syntax_test_markdown.md index b2cd51a1..ff75f7d0 100644 --- a/tests/syntax_test_markdown.md +++ b/tests/syntax_test_markdown.md @@ -8037,40 +8037,40 @@ This is a [[wiki link]]. $$ 1+1 $$ -| ^^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex +| ^^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar punctuation.definition.math.end $$ 1+1 $$ |^ meta.paragraph.markdown markup.math.block.markdown - text.tex -| ^^^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar | ^ meta.paragraph.markdown markup.math.block.markdown - text.tex -| ^^ punctuation.definition.math.begin.latex -| ^^ punctuation.definition.math.end.latex +| ^^ punctuation.definition.math.begin +| ^^ punctuation.definition.math.end $$ 1+1 $$ followed by text |^ meta.paragraph.markdown - markup.math -| ^^^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar | ^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup.math -| ^^ punctuation.definition.math.begin.latex -| ^^ punctuation.definition.math.end.latex +| ^^ punctuation.definition.math.begin +| ^^ punctuation.definition.math.end $$ 1+1 |^ meta.paragraph.markdown - markup.math -| ^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex -| ^^ punctuation.definition.math.begin.latex +| ^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar +| ^^ punctuation.definition.math.begin $$ followed by text -| ^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex +| ^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar punctuation.definition.math.end | ^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup.math Paragraph $$ 1+1 $$ | ^^^^^^^^^^ meta.paragraph.markdown - markup.math -| ^^^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar | ^ meta.paragraph.markdown - markup.math Paragraph $$ 1+1 | ^^^^^^^^^^ meta.paragraph.markdown - markup.math -| ^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar $$ -|^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +|^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar | ^ meta.paragraph.markdown - markup.math $$ @@ -8100,49 +8100,49 @@ Math blocks don't terminate paragraphs, but MathJax renders them as such $$ 1+1 $$ -| <- meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex -|^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex +| <- meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar +|^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar punctuation.definition.math.end | ^ meta.paragraph.markdown markup.math.block.markdown - text.tex $$ | <- meta.paragraph.markdown markup.math.block.markdown - text.tex |^^ meta.paragraph.markdown markup.math.block.markdown - text.tex -| ^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex -| ^^ punctuation.definition.math.begin.latex +| ^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar +| ^^ punctuation.definition.math.begin 1+1 $$ -| <- meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex -|^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex -| ^^ punctuation.definition.math.end.latex +| <- meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar +|^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar +| ^^ punctuation.definition.math.end | ^ meta.paragraph.markdown markup.math.block.markdown - text.tex $$ -| <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.begin.latex -|^^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex -|^ punctuation.definition.math.begin.latex +| <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar punctuation.definition.math.begin +|^^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar +|^ punctuation.definition.math.begin | ^ - punctuation foo = 1 + 2 * \sqrt{a^2+b^2} -| <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex variable.other.math.tex -|^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex -| ^ keyword.operator.math.tex -| ^ constant.numeric.math.tex -| ^ keyword.operator.math.tex -| ^ constant.numeric.math.tex -| ^ keyword.operator.math.tex -| ^^^^^ support.function.math.tex -| ^^^^^^^^^ meta.group.brace.latex -| ^ punctuation.definition.group.brace.begin.latex -| ^ variable.other.math.tex -| ^ keyword.operator.math.tex -| ^ constant.numeric.math.tex -| ^ keyword.operator.math.tex -| ^ variable.other.math.tex -| ^ keyword.operator.math.tex -| ^ constant.numeric.math.tex -| ^ punctuation.definition.group.brace.end.latex +| <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar variable.other.math +|^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar +| ^ keyword.operator.math +| ^ constant.numeric.math +| ^ keyword.operator.math +| ^ constant.numeric.math +| ^ keyword.operator.math +| ^^^^^ support.function.math +| ^^^^^^^^^ meta.group.brace +| ^ punctuation.definition.group.brace.begin +| ^ variable.other.math +| ^ keyword.operator.math +| ^ constant.numeric.math +| ^ keyword.operator.math +| ^ variable.other.math +| ^ keyword.operator.math +| ^ constant.numeric.math +| ^ punctuation.definition.group.brace.end $$ -| <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex -|^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex +| <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar punctuation.definition.math.end +|^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar punctuation.definition.math.end | ^ markup.math.block.markdown - text.tex $$ @@ -8160,17 +8160,17 @@ $$ |^^^^^^ markup.list.numbered.markdown - markup.math $$ 1+1 $$ - | <- markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.begin.latex - |^^^^^^^^ markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex - |^ punctuation.definition.math.begin.latex - | ^^ punctuation.definition.math.end.latex + | <- markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar punctuation.definition.math.begin + |^^^^^^^^ markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar + |^ punctuation.definition.math.begin + | ^^ punctuation.definition.math.end $$ 1+1 $$ followed by text | <- markup.list.numbered.markdown meta.paragraph.list.markdown - meta.math - |^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + |^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar | ^^^^^^^^^^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math - |^^ punctuation.definition.math.begin.latex - | ^^ punctuation.definition.math.end.latex + |^^ punctuation.definition.math.begin + | ^^ punctuation.definition.math.end $$ 1+1 @@ -8197,87 +8197,87 @@ $$ $$ 1+1 | <- markup.list.numbered.markdown meta.paragraph.list.markdown - meta.math - |^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex - |^^ punctuation.definition.math.begin.latex + |^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar + |^^ punctuation.definition.math.begin $$ followed by text - |^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + |^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar | ^^^^^^^^^^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math Paragraph $$ 1+1 $$ |^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math - | ^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + | ^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar | ^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math Paragraph $$ 1+1 |^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math - | ^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + | ^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar $$ - |^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + |^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar | ^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math Math blocks don't terminate paragraphs, but MathJax renders them as such $$ 1+1 $$ - | <- markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex - |^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex + | <- markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar punctuation.definition.math.end + |^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar punctuation.definition.math.end | ^ markup.list.numbered.markdown meta.paragraph.list.markdown - text.tex $$ - | <- markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.begin.latex - |^ markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.begin.latex + | <- markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar punctuation.definition.math.begin + |^ markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar punctuation.definition.math.begin foo = 1 + 2 - | <- markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex variable.other.math.tex + | <- markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar variable.other.math $$ - | <- markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex - |^ markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex + | <- markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar punctuation.definition.math.end + |^ markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar punctuation.definition.math.end # TEST: MATHJAX INLINE MARKUP ################################################# # Math $1+1$ atx heading | <- markup.heading.1.markdown punctuation.definition.heading.begin.markdown |^^^^^^^^^^^^^^^^^^^^^^^^ markup.heading.1.markdown -| ^^^^^ markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^^^^ markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar Math $1+1$ setext heading | <- markup.heading.1.markdown |^^^^^^^^^^^^^^^^^^^^^^^^^ markup.heading.1.markdown -| ^^^^^ markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^^^^ markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar === | <- markup.heading.1.markdown punctuation.definition.heading.setext.markdown Math $1+1$ setext heading | <- markup.heading.2.markdown |^^^^^^^^^^^^^^^^^^^^^^^^^ markup.heading.2.markdown -| ^^^^^ markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^^^^ markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar --- | <- markup.heading.2.markdown punctuation.definition.heading.setext.markdown This is math $1+1$ expression, but $ 1+1 $ ,$ 1+1$, $1+1 $ and 1+1$ or $1+1 are not. -| ^^^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex -| ^ punctuation.definition.math.begin.latex -| ^ constant.numeric.math.tex -| ^ keyword.operator.math.tex -| ^ constant.numeric.math.tex -| ^ punctuation.definition.math.end.latex +| ^^^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar +| ^ punctuation.definition.math.begin +| ^ constant.numeric.math +| ^ keyword.operator.math +| ^ constant.numeric.math +| ^ punctuation.definition.math.end | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup.math Math with -$1$() $2$-$3$a or $4$_ -| ^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar | ^^^ meta.paragraph.markdown - markup.math -| ^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar | ^^^^^^^^^^^^^^ meta.paragraph.markdown - markup.math Use `\$` to display a dollar sign: $\sqrt{\$4}$ | ^^^^ meta.paragraph.markdown markup.raw.inline.markdown -| ^^^^^^^^^^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex -| ^ punctuation.definition.math.begin.latex -| ^^^^^ support.function.math.tex +| ^^^^^^^^^^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar +| ^ punctuation.definition.math.begin +| ^^^^^ support.function.math | ^ punctuation.definition.group | ^^ constant.character.escape | ^ constant.numeric | ^ punctuation.definition -| ^ punctuation.definition.math.end.latex +| ^ punctuation.definition.math.end No math $1+1$ or $1+1$ |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup.math @@ -8297,19 +8297,19 @@ b$ math. |^^^^^^^^ meta.paragraph.markdown - markup.math Handle incomplete $\sqrt{b$ expressions well. -| ^^^^^^^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex -| ^ punctuation.definition.math.begin.latex -| ^^^^^ support.function.math.tex -| ^^ meta.group.brace.latex -| ^ punctuation.definition.math.end.latex - meta.group +| ^^^^^^^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar +| ^ punctuation.definition.math.begin +| ^^^^^ support.function.math +| ^^ meta.group.brace +| ^ punctuation.definition.math.end - meta.group | ^ meta.paragraph.markdown - markup.math 1. ordered list $\sqrt{b}$ equation $1+ - | ^^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + | ^^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar | ^^^^^^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math Math $1+1$ in paragraph. - | ^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + | ^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar No math $1+1$ or $1+1$ |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math @@ -8324,12 +8324,12 @@ Handle incomplete $\sqrt{b$ expressions well. | ^^^^^^ - markup.math - meta.tag + unordered $\sqrt{b}$ equation - | ^^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + | ^^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar Handle incomplete $\sqrt{b$ expressions well. - | ^^^^^^^^^ meta.paragraph.list.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex - | ^ punctuation.definition.math.begin.latex - | ^^^^^ support.function.math.tex - | ^^ meta.group.brace.latex - | ^ punctuation.definition.math.end.latex - meta.group + | ^^^^^^^^^ meta.paragraph.list.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar + | ^ punctuation.definition.math.begin + | ^^^^^ support.function.math + | ^^ meta.group.brace + | ^ punctuation.definition.math.end - meta.group | ^ meta.paragraph.list.markdown - markup.math From 93a5678886a1374f5fea7c143c72074bbea9544d Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 22 Nov 2022 20:06:59 +0100 Subject: [PATCH 06/11] Syntax: Add support for pandoc attributes in link defs Fixes #712 --- syntaxes/Markdown.sublime-syntax | 26 +++++++++++++++++++++--- tests/syntax_test_markdown.md | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/syntaxes/Markdown.sublime-syntax b/syntaxes/Markdown.sublime-syntax index 682d5844..a75892a3 100644 --- a/syntaxes/Markdown.sublime-syntax +++ b/syntaxes/Markdown.sublime-syntax @@ -2431,25 +2431,44 @@ contexts: 3: punctuation.definition.reference.end.markdown 4: punctuation.separator.key-value.markdown push: - - link-def-end + - link-def-meta + - link-def-attr - link-def-title - link-def-url - link-def-end: + link-def-meta: - meta_include_prototype: false - meta_scope: meta.link.reference.def.markdown - include: immediately-pop + link-def-attr: + - match: \{ + scope: punctuation.definition.attributes.begin.markdown + set: link-def-attr-body + - match: ^(?!\s*{)|(?=\S) + pop: 1 + + link-def-attr-body: + - meta_scope: meta.attributes.markdown + - include: tag-attributes + link-def-title: - match: ^(?!\s*["'(]) pop: true - match: (?=["'(]) set: - - expect-eol + - expect-attr-or-eol - link-title + - match: (?=\{) + pop: 1 - match: \S.+ scope: invalid.illegal.expected-eol.markdown + expect-attr-or-eol: + - match: (?=\{) + pop: 1 + - include: expect-eol + link-def-url: - match: < scope: punctuation.definition.link.begin.markdown @@ -3206,6 +3225,7 @@ contexts: scope: invalid.illegal.attribute-name.markdown tag-attr-meta: + - meta_include_prototype: false - meta_scope: meta.attribute-with-value.markdown - include: immediately-pop diff --git a/tests/syntax_test_markdown.md b/tests/syntax_test_markdown.md index 6d393ad1..9e463855 100644 --- a/tests/syntax_test_markdown.md +++ b/tests/syntax_test_markdown.md @@ -2508,6 +2508,41 @@ Foo | ^ punctuation.separator.key-value.markdown | ^^^^ markup.underline.link.markdown +## https://custom-tests/link-reference-definitions/with-attributes + +[link]: /url {#id .class width=30} +| ^^^^^^^^^^^^^^^^^^^^^ meta.link.reference.def.markdown meta.attributes.markdown + +[link]: /url (description) {#id .class width=30} +| ^^^^^^^^^^^^^^^^^^^^^ meta.link.reference.def.markdown meta.attributes.markdown + +[link]: /url "description" {#id .class width=30} +| ^^^^^^^^^^^^^^^^^^^^^ meta.link.reference.def.markdown meta.attributes.markdown + +[link]: + /url + {#id .class width=30} +| ^^^^^^^^^^^^^^^^^^^^^ meta.link.reference.def.markdown meta.attributes.markdown + +[link]: + /url + + {#id .class width=30} +| ^^^^^^^^^^^^^^^^^^^^^ - meta.link - meta.attributes + +[link]: + /url + "description" + {#id .class width=30} +| ^^^^^^^^^^^^^^^^^^^^^ meta.link.reference.def.markdown meta.attributes.markdown + +[link]: + /url + "description" + + {#id .class width=30} +| ^^^^^^^^^^^^^^^^^^^^^ - meta.link - meta.attributes + ## https://custom-tests/link-reference-definitions/in-block-quotes > [foo]: /url "description" From cd1112bc2bdadd053a900cfa4e5bd47095188943 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 23 Nov 2022 20:42:49 +0100 Subject: [PATCH 07/11] Satisfy linter --- plugins/headings/common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/headings/common.py b/plugins/headings/common.py index f8a1b01d..d23249e2 100644 --- a/plugins/headings/common.py +++ b/plugins/headings/common.py @@ -57,7 +57,9 @@ class MdeUnsavedViewNameSetter(MdeViewEventListener): MAX_NAME = 50 def on_modified(self): - if self.view.file_name() is not None or not self.view.settings().get("set_unsaved_view_name", True): + if self.view.file_name() is not None or not self.view.settings().get( + "set_unsaved_view_name", True + ): return name = first_heading_text(self.view) From b4279944b56da3cff9027fb16c202cf05733b3c0 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 23 Nov 2022 20:57:54 +0100 Subject: [PATCH 08/11] Add changelog --- messages.json | 3 ++- messages/3.1.8.md | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 messages/3.1.8.md diff --git a/messages.json b/messages.json index ec9077b6..55d95510 100644 --- a/messages.json +++ b/messages.json @@ -41,5 +41,6 @@ "3.1.4": "messages/3.1.4.md", "3.1.5": "messages/3.1.5.md", "3.1.6": "messages/3.1.6.md", - "3.1.7": "messages/3.1.7.md" + "3.1.7": "messages/3.1.7.md", + "3.1.8": "messages/3.1.8.md" } diff --git a/messages/3.1.8.md b/messages/3.1.8.md new file mode 100644 index 00000000..cebd2cb1 --- /dev/null +++ b/messages/3.1.8.md @@ -0,0 +1,15 @@ +# MarkdownEditing 3.1.8 Changelog + +Your _MarkdownEditing_ plugin is updated. Enjoy new version. For any type of +feedback you can use [GitHub issues][issues]. + +## Bug Fixes + +* Fix GFM auto-link termination +* Add support for pandoc attributes in reference definitions (#712) + +## New Features + +## Changes + +[issues]: https://github.com/SublimeText-Markdown/MarkdownEditing/issues From d1ce10065e178d84eff33c1ef4b064442908d35d Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 23 Nov 2022 21:01:08 +0100 Subject: [PATCH 09/11] Update changelog --- messages/3.1.8.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/messages/3.1.8.md b/messages/3.1.8.md index cebd2cb1..a74ea1ff 100644 --- a/messages/3.1.8.md +++ b/messages/3.1.8.md @@ -6,6 +6,8 @@ feedback you can use [GitHub issues][issues]. ## Bug Fixes * Fix GFM auto-link termination +* Fix inline raw code spans highlighting +* Fix stealing focus of Goto Anything Quick Panel (#710) * Add support for pandoc attributes in reference definitions (#712) ## New Features From 0791cb68ce3838266589b1b2c98621bf0511497a Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 23 Nov 2022 21:10:04 +0100 Subject: [PATCH 10/11] Syntax: Fix ST3 compatibility `pop: 1` is not supported by ST3 --- syntaxes/Markdown.sublime-syntax | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/syntaxes/Markdown.sublime-syntax b/syntaxes/Markdown.sublime-syntax index a75892a3..f9eb9cab 100644 --- a/syntaxes/Markdown.sublime-syntax +++ b/syntaxes/Markdown.sublime-syntax @@ -2446,7 +2446,7 @@ contexts: scope: punctuation.definition.attributes.begin.markdown set: link-def-attr-body - match: ^(?!\s*{)|(?=\S) - pop: 1 + pop: true link-def-attr-body: - meta_scope: meta.attributes.markdown @@ -2460,13 +2460,13 @@ contexts: - expect-attr-or-eol - link-title - match: (?=\{) - pop: 1 + pop: true - match: \S.+ scope: invalid.illegal.expected-eol.markdown expect-attr-or-eol: - match: (?=\{) - pop: 1 + pop: true - include: expect-eol link-def-url: @@ -3339,7 +3339,7 @@ contexts: autolink-inet-group: - match: \) - pop: 1 + pop: true - match: (?=(?:{{html_entity}})*[?!.,:;*_~'"]*[\s<]) pop: true - include: autolink-inet-common From 0b18708c55a59729104b02e179b5423cd0efe80f Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sun, 30 Oct 2022 17:23:48 +0100 Subject: [PATCH 11/11] Plugins: Modify heading style only before saving Fixes #710 --- plugins/headings/style.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/headings/style.py b/plugins/headings/style.py index 72b94761..32eb0fb2 100644 --- a/plugins/headings/style.py +++ b/plugins/headings/style.py @@ -66,6 +66,8 @@ def on_load(self): def on_pre_save(self): self.auto_detect_heading_style() + if self.view.settings().get("mde.auto_match_heading_hashes", False): + self.view.run_command("mde_match_heading_hashes") def auto_detect_heading_style(self): view = self.view @@ -86,6 +88,3 @@ def auto_detect_heading_style(self): view.settings().set("mde.match_heading_hashes", num_trailing / num_leading > 0.5) else: view.settings().erase("mde.match_heading_hashes") - - if view.settings().get("mde.auto_match_heading_hashes", False): - view.run_command("mde_match_heading_hashes")