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

Enable editing of .md with "front matter" #33

Open
shoffmeister opened this issue Aug 19, 2022 · 2 comments
Open

Enable editing of .md with "front matter" #33

shoffmeister opened this issue Aug 19, 2022 · 2 comments

Comments

@shoffmeister
Copy link

shoffmeister commented Aug 19, 2022

Astro (https://astro.build/) is the new hotness in content-rich static site rendering - and they have a concept called "front matter" (https://docs.astro.build/en/guides/markdown-content/) which simply has a "---"-enclosed section at the very top:

---
some: yaml
content: here
---
We now get into markdown territory...

At the moment, milkdown-vscode will corrupt the front matter of any such .md file; the above content will be transformed into

***

some: yaml
content: here
-------------

We now get into markdown territory...

by a roundtrip through milkdown-vscode. It would be quite nice to be able to edit such .md files through milkdown, because Astro itself is all about working inside Visual Studio Code, creating content and implementing site functionality there.

What confuses me a bit is that milkdown suggests that it does gfm-formatted markup (https://github.github.com/gfm/#tables-extension-), and those Astro frontmatter-enriched .md render fine inside the Github renderer (see, for exmple, https://github.com/withastro/astro/blob/main/examples/with-markdown-plugins/src/pages/index.md)

So, in the end, this could possibly be made to work by adjusting the gfm plugin / enabling the gfm?

Perhaps a configuration option on milkdown-vscode along the lines of

Retain front matter in files (yes/no) - Some markdown files may contain a --- ... --- section at the very top - "front matter". If such front matter is present in a markdown file, retain this front matter section unchanged through edits.

?

@shoffmeister
Copy link
Author

It just occurred to me that front matter as above can be (re)interpreted as a custom code fence (https://spec.commonmark.org/0.30/#fenced-code-blocks, https://github.github.com/gfm/#fenced-code-blocks) with - being the character used for wrapping the fence block (expanding beyond `` and ~)?

@shoffmeister
Copy link
Author

... and just discovered that another static site renderer, Jekyll (https://jekyllrb.com/docs/step-by-step/03-front-matter/), does front matter, too. That renderer also does markdown, so the use case for enabling --- fences would be much broader than just Astro.

For reference, https://jamstack.org/generators/ lists plenty of static site renderers; I'd guess more of these might do front matter, too (with renderer proprietary content that milkdown processing would ignore)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant