Support for "ignore" comments
Is your feature request related to a problem? Please describe.
Some officially supported Python Markdown extensions (like admonition use non-standard Markdown syntax. These cases are not properly handled by the parser currently. For example:
# Some title
!!! note
This will render as a tooltip box.
Back to normal markdown content.
Describe the solution you'd like
It would be useful if there was an "ignore" comment that could be added to a markdown file to skip formatting specific sections. The prettier library uses <!-- prettier-ignore --> and <!-- prettier-ignore-end --> for this purpose.
Describe alternatives you've considered
Plugins could be written for to handle cases like this, but it would be useful if there was a global way to disable formatting in specific sections of a document.
Additional context
It looks like there's a similar discussion happening on an existing PR about how to ignore blocks of code. I'd be fine with a solution where I could wrap certain sections in a div that sets a class that's globally ignored, but I feel like a plain comment would be a better interface for this use case, as it wouldn't require modifying the AST of the markdown.
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
Hi @jamescurtin and thanks for the issue!
I like the feature.
Some notes/thoughts regarding implementation already :smile:
- reference links (spanning in and out of the ignored block) could be problematic
- I think deciding what to ignore has to happen after parsing. Doing so before parser is problematic because, e.g. there is no ignore block in the MD below, and it's difficult to know that without parsing:
<!-- mdformat ignore start --> ``` <!-- mdformat ignore end --> ``` - The token stream the renderer currently receives is abstract, not concrete syntax. The renderer doesn't know the original formatting. One way or the other it would have to I guess.
I'm expecting a bug free implementation could be quite hard to come up with. A plugin that brings formatting support for admonition (that you mentioned) might be easier (although not as general solution ofc).
It looks like there's a similar discussion happening on an existing PR about how to ignore blocks of code.
This discussion is related to ignoring stuff from a safeguard that ensures mdformat does not alter markdown AST. All markdown is still formatted, so it's not really the same thing.
Hi folks, any updates here? This is currently a bit of a deal breaker for me.
No one is currently working on this to my knowledge.
It seems you also need support for the non-standard admonition syntax, so seems like a plugin that brings support for that syntax would help you as well.
Hi @jamescurtin and thanks for the issue!
I like the feature.
Some notes/thoughts regarding implementation already 😄
- reference links (spanning in and out of the ignored block) could be problematic
- I think deciding what to ignore has to happen after parsing. Doing so before parser is problematic because, e.g. there is no ignore block in the MD below, and it's difficult to know that without parsing:
<!-- mdformat ignore start -->- The token stream the renderer currently receives is abstract, not concrete syntax. The renderer doesn't know the original formatting. One way or the other it would have to I guess.
I'm expecting a bug free implementation could be quite hard to come up with. A plugin that brings formatting support for admonition (that you mentioned) might be easier (although not as general solution ofc).
It looks like there's a similar discussion happening on an existing PR about how to ignore blocks of code.
This discussion is related to ignoring stuff from a safeguard that ensures mdformat does not alter markdown AST. All markdown is still formatted, so it's not really the same thing.
Hi @hukkin , is there any progress to support the feature?