SublimeText-Markdown/MarkdownEditing

How to use YAML frontmatter?

Closed this issue · 5 comments

with the latest update my YAML header are no longer by scope source.yaml. Is there any way to handle YAML frontmatter?

Nothing has changed with regards to YAML frontmatter.

grafik

Maybe: sublimehq/Packages#3288

I started ST4 in safe mode and installed MarkdownEditing, the scopes on line 2 are:

text.html.markdown.multimarkdown meta.content.multimarkdown markup.heading.2.markdown entity.name.section.markdown

Sublime Core uses the following scopes:

text.html.markdown.multimarkdown meta.content.multimarkdown text.html.markdown meta.frontmatter.markdown source.yaml.embedded.markdown source.yaml string.unquoted.plain.out.yaml entity.name.tag.yaml

I think that source.yaml is missing in MarkdownEditing for MultiMarkdown syntax.

If you want YAML frontmatter, use Markdown.sublime-syntax

MultiMarkdown doesn't support YAML frontmatter. It uses its own simple key-value style of meta data at the beginning of a document, which may look very similar to YAML in the first place, but doesn't support nested objects etc.

for differences see: https://stackoverflow.com/questions/44215896/markdown-metadata-format

ST opens markdown files using Markdown.sublime-syntax (out of the box), which highlights YAML frontmatter. MultiMarkdown is used only if actively assigned by user or if format: complete is found in the very first line.

The style of metadata is the only difference between Merkdown.sublime-syntax and MultiMarkdown.sublime-syntax.

Note: ST4's default MultiMarkdown.sublime-syntax highlighting YAML frontmatter is a bug, which will be fixed in one of the next ST4 releases.

Here's an example of how multimarkdown 6.6.0 translates YAML frontmatter of a markdown (on the left) to html (on the right).

grafik

Highlighting of markdown content using Multimarkdown.sublime-syntax matches the html output!

The previous screenshot was made with multimarkdown -b -c test.md. Omitting -c flag results in first --- being parsed as beginning of frontmatter. This will be fixed in the next release.