Adds Renderer.default_output method for alternative output formats #20

Closed
wants to merge 6 commits into
from

Conversation

Projects
None yet
4 participants
@bslatkin
Contributor

bslatkin commented Aug 28, 2014

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.

bslatkin added some commits Jun 12, 2014

Adds Renderer.text hook for unformatted text.
Useful for building alternative output methods (like docx) using the Renderer class.
Enables alternative representations of the render tree.
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).
@matze

This comment has been minimized.

Show comment
Hide comment
@matze

matze Aug 30, 2014

👍 that would be very helpful for one of my projects. This would also make mistune a real parser and not just a string translator.

matze commented Aug 30, 2014

👍 that would be very helpful for one of my projects. This would also make mistune a real parser and not just a string translator.

@lepture

This comment has been minimized.

Show comment
Hide comment
@lepture

lepture Aug 30, 2014

Owner

@bslatkin @matze What you need is the BlockLexer and InlineLexer. It should not be the renderer's job.

Owner

lepture commented Aug 30, 2014

@bslatkin @matze What you need is the BlockLexer and InlineLexer. It should not be the renderer's job.

@matze

This comment has been minimized.

Show comment
Hide comment
@matze

matze Aug 30, 2014

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 Markdown parser object to get where I want to get.

matze commented Aug 30, 2014

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 Markdown parser object to get where I want to get.

@lepture

This comment has been minimized.

Show comment
Hide comment
@lepture

lepture Sep 4, 2014

Owner

@matze @bslatkin Thanks for the feedback. I'd like a better way to create the token tree.

Owner

lepture commented Sep 4, 2014

@matze @bslatkin Thanks for the feedback. I'd like a better way to create the token tree.

@lu-zero

This comment has been minimized.

Show comment
Hide comment
@lu-zero

lu-zero Sep 6, 2014

Having the ability get the parse tree as emerald-tree/elementtree would be a boon.

lu-zero commented Sep 6, 2014

Having the ability get the parse tree as emerald-tree/elementtree would be a boon.

@lepture

This comment has been minimized.

Show comment
Hide comment
@lepture

lepture Nov 11, 2014

Owner

It has been merged into 96edd43

Working on sprint branch. It will be available in v0.5

Owner

lepture commented Nov 11, 2014

It has been merged into 96edd43

Working on sprint branch. It will be available in v0.5

@lepture lepture closed this Nov 11, 2014

@bslatkin

This comment has been minimized.

Show comment
Hide comment
@bslatkin

bslatkin Nov 11, 2014

Contributor

Great! Thanks

Contributor

bslatkin commented Nov 11, 2014

Great! Thanks

@chintal chintal referenced this pull request Apr 26, 2016

Closed

Help with parse-only use #98

@pyup-bot pyup-bot referenced this pull request in rochacbruno/quokka Feb 6, 2018

Closed

Pin mistune to latest version 0.8.3 #547

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment