From: <way...@ic...> - 2017-05-25 23:17:29
|
On May 25, 2017, 12:49 PM -0400, wrote: > > In my case the data source does not have any Markdown expectations (the > source does not even know there is Markdown in the middle or what > Markdown is). It sounds to me like you would benefit from a parser which generates an abstract syntax tree (AST). The AST is then feed to a renderer which then renders the output. You get the benefits of an already existing parser and can easily provide your own renderer which outputs whatever format you want. This is how Pandoc works to convert between so many different formats. If you are looking for a Python lib, you might want to look at mistune (haven’t used it myself but I like what I see). It is sort-of possible to do that with Python-Markdown. You can provide your own serializer. But we use an ElementTree instance rather than an AST. So the serializer would need to build your output from an HTML like object representation, which is less than ideal for anything but HTML. And then some of our postprocessers would need to be rewritten as the default ones expect HTML. Waylan |