Prettier plugin for Markdoc tags
Is your feature request related to a problem? Please describe.
By default, Prettier does not understand Markdoc syntax and after formatting it just simply pushes all content to the left side and ignores attribute formatting at all (all redundant spaces will be preserved).
Describe the solution you'd like
It would be great if Prettier understands Markdoc syntax (natively or via some plugin) to format Markdoc tags similar to XML/HTML tags. Currently, we have an option either to disable Prettier for documentation to preserve nested structure, or have enabled Prettier but with flat Markdoc structure.
Use case example:
https://redocly.com/learn/markdoc/tags/tabs#syntax-and-usage
Before formatting:
{% tabs %}
{% tab label="Tab 1" %}
Content for Tab 1
{% /tab %}
{% tab label="Tab 2" %}
Content for Tab 2
{% /tab %}
{% /tabs %}After formatting with Prettier:
{% tabs %}
{% tab label="Tab 1" %}
Content for Tab 1
{% /tab %}
{% tab label="Tab 2" %}
Content for Tab 2
{% /tab %}
{% /tabs %}Example from your documentation which also could have the benefit of proper formatting: https://raw.githubusercontent.com/markdoc/docs/refs/heads/main/pages/docs/variables.md
Additional context
By default, Prettier does not format XML so for SVG files, but it could be simply fixed with html parser option. And for sh, we have the prettier-plugin-sh plugin. It would be nice to have simular prettier-plugin-markdoc plugin as well.
{
"singleQuote": true,
"printWidth": 100,
"overrides": [
{
"files": ["*svg", "*.xml"],
"options": {
"parser": "html"
}
},
{
"options": {
"plugins": ["prettier-plugin-sh"]
}
}
]
}Source: markdoc/markdoc