-
-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds Renderer.default_output method for alternative output formats #20
Conversation
Useful for building alternative output methods (like docx) using the Renderer class.
This is useful for using an empty list as the default output value instead of a string. This allows renderers to build their own stack of directives using Python objects. This makes it easy to convert that tree of objects into other document formats besides HTML (such as docx).
👍 that would be very helpful for one of my projects. This would also make mistune a real parser and not just a string translator. |
What we'd need is a real parser that outputs a tree of the Markdown structure without rendering it first. The lexers are a first step but I'd need to replicate quite a lot of the |
Having the ability get the parse tree as emerald-tree/elementtree would be a boon. |
It has been merged into 96edd43 Working on |
Great! Thanks |
The new method returns the default, empty output value for the renderer.
All renderer methods use the '+=' operator to append to this value. Default is a string so rendering HTML can build up a result string with the rendered Markdown.
Can be overridden by Renderer subclasses to be types like an empty list, allowing the renderer to create a tree-like structure to represent the document (which can then be reprocessed later into a separate format like docx or pdf).
Includes an end-to-end test. I've been using it in my own projects for about 2 weeks now.