markdown-it / markdown-it-container

Fenced container plugin for markdown-it markdown parser
MIT License
496 stars 74 forks source link

Add option to omit content output #47

Closed alxmagro closed 9 months ago

alxmagro commented 1 year ago

I was trying to use markdown-it-container for get block content and render myself with some transformations, and I could append it to "opening tag" return, but the content is still rendering on output.

Aside "validate", "render" and "marker", it could have option to omit output (eg.: "output: false").

It give more options to dev, to do thigs like I described above.

alkaitagi commented 1 year ago

Yes, it'd be ready helpful. In my project I wrap a container around a table, then on container rendering I parse the table's data and pass it into a custom Vue component. Since I no longer need the original table I've ended up just wrapping the content in <!-- comments.

KaelWD commented 1 year ago

You can iterate tokens until you find one with type: 'container_<name>_close' and remove all tokens between that and the open one.

puzrin commented 9 months ago

This does not look like intended use

  1. You probably need custom fenced block instead, for raw content access
  2. Or you can call .parse manually, then update tokens as needed, then call render.