sergiocorreia/panflute

How to parse markdown text into internal panflute representation ?

perrette opened this issue · 1 comments

When converting markdown to html, I need to append image attributes to the caption ("source" for image credits), so that they can be processed correctly by other filters like citeproc. However, the figure caption, accessible as elem.content is already in AST format (panflute classes Str, Space, Link etc), whereas the figure attribute is in markdown. I cannot use pf.convert_text here because it needs to be processed in the context of the rest of the article (for citation references). Just using pf.RawInline makes it escape subsequent filters.

Is there any way I could "parse" the image attribute using panflute / pandoc machinery, so that I can append the parsed attribute to the image in a way that other filters will process its content normally?

I am not sure whether the internal AST representation comes from pandoc or panflute, so let me know if I should ask that question elsewhere ((py)pandoc...). In any case, thanks for the great work ! This package is extremely useful.

It seems that I had missed the obvious. panflute.convert_text does exactly what I was looking for. Thanks again.