dprint / dprint-plugin-markdown

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

Play nice with `<!-- prettier-ignore -->` switching between prettier<>dprint #83

Closed nuke-web3 closed 1 year ago

nuke-web3 commented 1 year ago

To make use of this tool easy to transition or be directly compatible with Prettier users, I would love to have https://dprint.dev/plugins/markdown/#ignore-comments be expanded to also ignore using:

nuke-web3 commented 1 year ago

https://dprint.dev/plugins/markdown/config/#ignoreDirective

Actually if I can get this to work, that is all I need. The playground is working for this:

## Something

Working              format

<!-- prettier-ignore -->
Ignore                 format

With config snippet:

{
  "ignoreNodeCommentText": "prettier-ignore",
}
nuke-web3 commented 1 year ago

So in collaborating with others that use prettier instead of dprint (for example via prettier setup to automatically run on an IDE), here is an example of problem:

<diagram class="mermaid limit size-40">
<!-- prettier-ignore-start -->
flowchart TD
subgraph paraA[Parachain A              .]
  executor --"success?"--> palletxcm
  palletxcm("pallet-xcm") --"execute"--> executor("xcm-executor")
end
execute("execute(xcm)") --> palletxcm
<!-- prettier-ignore-end -->
</diagram>

Prettier needs there to be no new lines to respect the inner block. But dprint formats to

<diagram class="mermaid limit size-40">
<!-- prettier-ignore-start -->

flowchart TD
subgraph paraA[Parachain A              .]
  executor --"success?"--> palletxcm
  palletxcm("pallet-xcm") --"execute"--> executor("xcm-executor")
end
execute("execute(xcm)") --> palletxcm

<!-- prettier-ignore-end -->
</diagram>

And a run of prettier after this formats the block in an untended way.