dprint / dprint-plugin-markdown

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

Exclamation point before square brackets is always removed #90

Closed jakebailey closed 4 weeks ago

jakebailey commented 11 months ago

Describe the bug

dprint-plugin-markdown version: 0.16.2

I think there's some abiguity here given this syntax is used for markdown images, but when using [^footnote] syntax, placing the footnote directly after an exclamation point without a space (somewhat common for footnotes) causes the exlamation point to be removed from the output.

I'm not totally sure if there's a good resolution here as I'm no markdown syntax expert, but hopefully there's some syntax rule that means that the AST can know that a certain construct isn't an image.

Input Code

Hello, world![^footnote] This is some text.

[^footnote]: This is the footnote.

Expected Output

Hello, world![^footnote] This is some text.

[^footnote]: This is the footnote.

Actual Output

Hello, world[^footnote] This is some text.

[^footnote]: This is the footnote.

https://dprint.dev/playground/#code/BIUwNmD2A0AEDukBOYAmBCA2gPQGaUgBcA7IkAXVgBUALASwGdZHYHIBbEWQkAD0IB0AWABQonPiKke5AFzV6TFoRpdJJMgKA/language/markdown

jakebailey commented 11 months ago

This is of course easily worked around using \!, so I'm not too unhappy if this isn't fixable... but it does seem odd for non-whitespace characters to just disappear like that. I wouldn't have noticed if I hadn't been watching when I hit save.

dsherret commented 1 month ago

I opened https://github.com/pulldown-cmark/pulldown-cmark/issues/923