From 60cc716f609500ccce63886b4de9fd97a1662ec7 Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sun, 19 Apr 2020 18:53:59 +0200 Subject: [PATCH 1/5] [Markdown] Add YAML frontmatter highlighting Because this may only match at the very beginning of the file, it cannot be tested. I tried. Closes #1783. --- Markdown/Markdown.sublime-syntax | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index 19dc685db7..570c237a5a 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -180,7 +180,21 @@ variables: # \s*$ # any amount of whitespace until EOL # ) contexts: + file-start: + - match: ^---$\n + scope: punctuation.section.block.begin.frontmatter.yaml.markdown + embed: scope:source.yaml + embed_scope: source.yaml.embedded + escape: ^---(?=\s) + escape_captures: + 0: punctuation.section.block.end.frontmatter.yaml.markdown + main: + - include: file-start + - match: '' + push: default + + default: - match: |- (?x)^ (?= {{block_quote}} From 2f3b10a26e54b226c0017fe2b10b2f6a5f6a3fac Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Mon, 20 Apr 2020 01:39:44 +0200 Subject: [PATCH 2/5] [Markdown] Add test for normal `---` token --- Markdown/syntax_test_markdown.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Markdown/syntax_test_markdown.md b/Markdown/syntax_test_markdown.md index 63796ab010..4be9e077eb 100644 --- a/Markdown/syntax_test_markdown.md +++ b/Markdown/syntax_test_markdown.md @@ -289,6 +289,12 @@ Paragraph break. Paragraph break. +--- +|^^^ meta.block-level meta.separator.thematic-break +|^^ punctuation.definition.thematic-break + +Paragraph break. + -------- |^^^^^^^^ meta.block-level meta.separator.thematic-break |^^^^^^^ punctuation.definition.thematic-break From 0bfe42f8f4891086886d737a9464be4c29e2701d Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Wed, 22 Jul 2020 16:59:50 +0200 Subject: [PATCH 3/5] [Markdown] Add `meta.formatter.markdown` scope - Better supports embedding by not anchoring to `^`. - Since some newish release we can also set out of the main context. --- Markdown/Markdown.sublime-syntax | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index 570c237a5a..6ad9415727 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -181,20 +181,22 @@ variables: # ) contexts: file-start: - - match: ^---$\n - scope: punctuation.section.block.begin.frontmatter.yaml.markdown + - match: (---)\s* + captures: + 0: meta.frontmatter.markdown + 1: punctuation.section.block.begin.frontmatter.yaml.markdown embed: scope:source.yaml - embed_scope: source.yaml.embedded - escape: ^---(?=\s) + embed_scope: meta.frontmatter.markdown source.yaml.embedded + escape: ^(---)\s*$ # pandoc requires the remainder of the line to be blank escape_captures: - 0: punctuation.section.block.end.frontmatter.yaml.markdown + 1: meta.frontmatter.markdown punctuation.section.block.end.frontmatter.yaml.markdown main: - include: file-start - match: '' - push: default + set: markdown - default: + markdown: - match: |- (?x)^ (?= {{block_quote}} From d389149ddfcbe4e3cdfa155bb45550db4fbea52e Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Wed, 22 Jul 2020 17:23:48 +0200 Subject: [PATCH 4/5] [Markdown] Fix Multimarkdown tests by embedding --- Markdown/MultiMarkdown.sublime-syntax | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Markdown/MultiMarkdown.sublime-syntax b/Markdown/MultiMarkdown.sublime-syntax index 679d80cc6c..0ec3f58295 100644 --- a/Markdown/MultiMarkdown.sublime-syntax +++ b/Markdown/MultiMarkdown.sublime-syntax @@ -1,6 +1,7 @@ %YAML 1.2 --- # http://www.sublimetext.com/docs/3/syntax.html +version: 2 name: MultiMarkdown first_line_match: (?i)^format:\s*complete\s*$ scope: text.html.markdown.multimarkdown @@ -25,4 +26,12 @@ contexts: - match: '' push: - meta_scope: meta.content.multimarkdown - - include: scope:text.html.markdown + - match: '' + embed: scope:text.html.markdown + escape: $(?!$) # should never match + # Replace with the following once + # https://github.com/sublimehq/sublime_text/issues/2395#issuecomment-662515815 is fixed. + # - match: '' + # embed: scope:text.html.markdown + # embed_scope: meta.content.multimarkdown + # escape: $(?!$) # should never match From a8c8daaca1c67e6972e7b5a67c8c275e05691159 Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Wed, 22 Jul 2020 17:37:05 +0200 Subject: [PATCH 5/5] [Markdown] Replace embed with multi-push --- Markdown/MultiMarkdown.sublime-syntax | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Markdown/MultiMarkdown.sublime-syntax b/Markdown/MultiMarkdown.sublime-syntax index 0ec3f58295..aa56414e5f 100644 --- a/Markdown/MultiMarkdown.sublime-syntax +++ b/Markdown/MultiMarkdown.sublime-syntax @@ -25,13 +25,5 @@ contexts: scope: string.unquoted.multimarkdown - match: '' push: - - meta_scope: meta.content.multimarkdown - - match: '' - embed: scope:text.html.markdown - escape: $(?!$) # should never match - # Replace with the following once - # https://github.com/sublimehq/sublime_text/issues/2395#issuecomment-662515815 is fixed. - # - match: '' - # embed: scope:text.html.markdown - # embed_scope: meta.content.multimarkdown - # escape: $(?!$) # should never match + - - meta_scope: meta.content.multimarkdown + - scope:text.html.markdown