prettier icon indicating copy to clipboard operation
prettier copied to clipboard

[Markdown] Markdown components (MDC) syntax support

Open 6r1d opened this issue 3 years ago • 4 comments

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.

6r1d avatar Sep 23 '22 09:09 6r1d

@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 avatar Dec 10 '22 12:12 kachkaev

@kachkaev I think you meant this playground example from this issue #13963

cyrilf avatar Dec 28 '22 23:12 cyrilf

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.

fkrauthan avatar Nov 14 '23 22:11 fkrauthan

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

angrybacon avatar Apr 24 '24 10:04 angrybacon