Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Markdown] Add YAML frontmatter highlighting #2339

Merged
merged 5 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Markdown/Markdown.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,23 @@ variables:
# \s*$ # any amount of whitespace until EOL
# )
contexts:
file-start:
- match: (---)\s*
captures:
0: meta.frontmatter.markdown
1: punctuation.section.block.begin.frontmatter.yaml.markdown
embed: scope:source.yaml
embed_scope: meta.frontmatter.markdown source.yaml.embedded
escape: ^(---)\s*$ # pandoc requires the remainder of the line to be blank
escape_captures:
1: meta.frontmatter.markdown punctuation.section.block.end.frontmatter.yaml.markdown

main:
- include: file-start
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it is really worth adding a named context for just one match rule.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the context helps convey the semantic meaning of the match, imo, so I left that in.

- match: ''
set: markdown

markdown:
- match: |-
(?x)^
(?= {{block_quote}}
Expand Down
11 changes: 10 additions & 1 deletion Markdown/MultiMarkdown.sublime-syntax
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
FichteFoll marked this conversation as resolved.
Show resolved Hide resolved
# 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
FichteFoll marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 6 additions & 0 deletions Markdown/syntax_test_markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down