dprint / dprint-plugin-markdown

Markdown code formatting plugin for dprint.
MIT License
29 stars 9 forks source link

Support formatting frontmatter #125

Open awmottaz opened 2 months ago

awmottaz commented 2 months ago

From what I've seen, the gray-matter library is the de facto standard for parsing frontmatter in markdown files. It parses YAML by default, and YAML is by far the most common syntax I see for frontmatter.

It would be great if dprint-plugin-markdown would format the frontmatter block following the syntax from gray-matter.

I have installed dprint-plugin-markdown and g-plane/pretty_yaml. Given the following input:

---
- some yaml frontmatter
        - this is nested too deep
---

```yaml
- a yaml code block
        - this is nested too deep

The output I get after formatting is:

````md
---
- some yaml frontmatter
        - this is nested too deep
---

```yaml
- a yaml code block
  - this is nested too deep

This is what I want to happen:

````md
---
- some yaml frontmatter
  - this is nested too deep
---

```yaml
- a yaml code block
  - this is nested too deep