wooorm / markdown-rs

CommonMark compliant markdown parser in Rust with ASTs and extensions

Home Page:https://docs.rs/markdown/1.0.0-alpha.17/markdown/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inlines in Image

xelatihy opened this issue · comments

I was wondering if it may be possible to have a list of inlines in Node::Image and Node::ImageRef for the alt property.
That would be similar to how links works, and would allow to support Figures in the same manner than Pandoc does.

Hey Fabio!

I’ve thought about this before, but the main problem is that it makes the AST unstable, difficult to work with. Changing the alt field means the children are out of date. Vice versa.
There’s also a particular way the alt has to be handled in markdown, based on how it is parsed, so dropping alt in favor of children will make it difficult to match reference parsers (CM, GFM).
So I don’t think this is a good idea from the AST perspective.

As for pandoc, that is not a goal, this focusses on CommonMark.
For extensions, such as directives, I’d recommend directives: #57.

Thanks for looking into this!

Your comment makes complete sense. The real issue is that Markdown does not have "block figures" but only "inline images", even if the most common way to use images in markdown would be figures. Every markdown library that handles figures, often for generating reports, does it in its own manner, or uses Pandoc which forces a particular extension to CommonMark. I do not see an easy way out of this.

Thanks again for considering it.

Sure, no problem! :)