prettier
prettier copied to clipboard
[Markdown] Markdown components (MDC) syntax support
Hello.
It would help a lot if Prettier had a config option to support Markdown component syntax. In a scenario Prettier is used for CI to prevent the merging of the documentation that was not formatted, having any support for MDC would allow to use custom widgets in the documentation.
Currently, Prettier will break the formatting inside such a component so that newlines are replaced by the white spaces.
As an example, such configuration is used in Iroha 2 docs: package.json, integration step.
Thanks.
@piet-maier has provided an example of MDC syntax in ~https://github.com/prettier/prettier/issues/13512~ https://github.com/prettier/prettier/issues/13963, if anyone needs it.
@kachkaev I think you meant this playground example from this issue #13963
I would also be interested in this. There seem to be a more advanced proposal here https://talk.commonmark.org/t/generic-directives-plugins-syntax/444 with a generic directives syntax (that also includes the MDC syntax). Based on some small code research it seems like the only thing that needs to change is https://github.com/prettier/prettier/blob/main/src/language-markdown/printer-markdown.js#L131C17-L131C48 to expand that regex if a line starts with ^:[:A-Za-z] to always set preserve?
rmarkdown also seem to support a syntax like that (https://bookdown.org/yihui/rmarkdown-cookbook/multi-column.html) for multi column support.
It's been some time since I've had to deal with this issue in Markdown with custom directive myself and ended up here as I searched to know whether that was a known issue.
Here is a playground for reproduction