Skip to content

Commit

Permalink
Simplify markdown punctuation scope
Browse files Browse the repository at this point in the history
caused by: sublimehq/Packages#3941

This commit ...

1. adjusts scope names
2. adjusts frontmatter contexts to follow those of syntax definitions
   like Astro/Liquid/Slim
  • Loading branch information
deathaxe committed Mar 10, 2024
1 parent 3fd0ec7 commit b6a8192
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
44 changes: 26 additions & 18 deletions syntaxes/Markdown.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -297,54 +297,62 @@ variables:
contexts:

main:
- include: frontmatter
- meta_include_prototype: false
- match: ''
set: markdown
set: [markdown, frontmatter]

frontmatter:
- match: (---)\s*(?i:(coffee)\s*)\n
- meta_include_prototype: false
- match: \s*(---)\s*(?i:(coffee)\s*)\n
captures:
0: meta.frontmatter.markdown
1: punctuation.section.block.begin.frontmatter.markdown
1: punctuation.section.frontmatter.begin.markdown
2: constant.other.language-name.markdown
embed: scope:source.coffee
embed_scope: meta.frontmatter.markdown source.coffee.embedded.markdown
escape: ^(---|\.{3})\s*\n # pandoc requires the remainder of the line to be blank
escape: ^\s*(---|\.{3})\s*$\n? # pandoc requires the remainder of the line to be blank
escape_captures:
0: meta.frontmatter.markdown
1: punctuation.section.block.end.frontmatter.markdown
- match: (---)\s*(?i:(json)\s*)\n
1: punctuation.section.frontmatter.end.markdown
pop: 1
- match: \s*(---)\s*(?i:(json)\s*)\n
captures:
0: meta.frontmatter.markdown
1: punctuation.section.block.begin.frontmatter.markdown
1: punctuation.section.frontmatter.begin.markdown
2: constant.other.language-name.markdown
embed: scope:source.json
embed_scope: meta.frontmatter.markdown source.json.embedded.markdown
escape: ^(---|\.{3})\s*\n # pandoc requires the remainder of the line to be blank
escape: ^\s*(---|\.{3})\s*$\n? # pandoc requires the remainder of the line to be blank
escape_captures:
0: meta.frontmatter.markdown
1: punctuation.section.block.end.frontmatter.markdown
- match: (---)\s*(?i:(yaml|yml)\s*)?\n
1: punctuation.section.frontmatter.end.markdown
pop: 1
- match: \s*(---)\s*(?i:(yaml|yml)\s*)?\n
captures:
0: meta.frontmatter.markdown
1: punctuation.section.block.begin.frontmatter.markdown
1: punctuation.section.frontmatter.begin.markdown
2: constant.other.language-name.markdown
embed: scope:source.yaml
embed_scope: meta.frontmatter.markdown source.yaml.embedded.markdown
escape: ^(---|\.{3})\s*\n # pandoc requires the remainder of the line to be blank
escape: ^\s*(---|\.{3})\s*$\n? # pandoc requires the remainder of the line to be blank
escape_captures:
0: meta.frontmatter.markdown
1: punctuation.section.block.end.frontmatter.markdown
- match: (\+{3})\s*\n
1: punctuation.section.frontmatter.end.markdown
pop: 1
- match: \s*(\+{3})\s*\n
captures:
0: meta.frontmatter.markdown
1: punctuation.section.block.begin.frontmatter.markdown
1: punctuation.section.frontmatter.begin.markdown
embed: scope:source.toml
embed_scope: meta.frontmatter.markdown source.toml.embedded.markdown
escape: ^(\+{3})\s*\n
escape: ^\s*(\+{3})\s*$\n?
escape_captures:
0: meta.frontmatter.markdown
1: punctuation.section.block.end.frontmatter.markdown
1: punctuation.section.frontmatter.end.markdown
pop: 1
# Ensure to highlight frontmatter if the syntax is embedded, but pop as early as possible
- match: ^|(?=\S)
pop: 1

markdown:
- include: indented-code-blocks
Expand Down
9 changes: 5 additions & 4 deletions syntaxes/MultiMarkdown.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ contexts:
set: [markdown, frontmatter]

frontmatter:
- meta_include_prototype: false
# MultiMarkdown 6 supports frontmatter like headers for compatibility reasons
# Note: The content is still limited to simple key-value pairs, no YAML!
- match: ^(---)\s*\n
- match: ^\s*(---)\s*\n
captures:
0: meta.frontmatter.multimarkdown
1: punctuation.section.block.begin.frontmatter.multimarkdown
1: punctuation.section.frontmatter.begin.multimarkdown
embed: frontmatter-content
embed_scope: meta.frontmatter.multimarkdown
escape: ^(---|\.{3})\s*\n
escape: ^\s*(---|\.{3})\s*$\n?
escape_captures:
0: meta.frontmatter.multimarkdown
1: punctuation.section.block.end.frontmatter.multimarkdown
1: punctuation.section.frontmatter.end.multimarkdown
pop: 1
# Classic key-value frontmatter beginning with first key, terminated by empty line.
- match: ^(?={{header}})
Expand Down

0 comments on commit b6a8192

Please sign in to comment.