Document side-effects of renderers' initialisation
See original GitHub issueHello, this is possibly an issue concerning the doc and not the code.
- Parsing outside of the renderer’s context manager:
d = Document('a <b> c')
with HTMLRenderer() as r:
print(r.render(d)) # <p>a <b> c</p>
- Parsing inside of the renderer’s context manager:
with HTMLRenderer() as r:
d = Document('a <b> c')
print(r.render(d)) # <p>a <b> c</p>
Not sure where the difference in output comes from. CommonMark asks for the second output though, which seems to be what is performed in mistletoe.markdown
and by the mistletoe
command line.
$ python -V
Python 3.7.0
$ pip freeze
mistletoe==0.7.1
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Atom Effects | Recoil
Atom effects are an API for managing side-effects and synchronizing or initializing Recoil atoms. They have a variety of useful applications such as...
Read more >Module Constraints - Remix
Browser-only code - Remix renders on the server so your modules can't have module side effects or first-rendering logic that call browser-only APIs ......
Read more >Hooks API Reference - React
The default behavior for effects is to fire the effect after every completed render. That way an effect is always recreated if one...
Read more >Mesh Renderer component - Unity - Manual
If the materials are not fully opaque, you can layer different materials and create interesting visual effects. However, fully opaque materials overwrite ...
Read more >inlife/nexrender: Data-driven render automation for After Effects
The module returns 2 methods, init and render . render calls init internally, if it sees that there were some options provided to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I guess so.
For what it’s worth, here is what I was expecting when I first encountered missletoe last week:
Document
, I would expect to write something likeDocument(md, extra_tokens=[GithubWiki])
extra_tokens
: I would expect the renderer to just throw an exception if it doesn’t know about some token typeSo something like this:
In other words, I would expect the parsing and the rendering phases to be independent. Since the types of tokens has to be specified in the parsing phase, it seems odds to me to specify it in the rendering phase instead.
Just my two cents. Obviously, you do what you want with the project, and what I mentioned above is likely to change the API and break backward compatibility.
I don’t really have an opinion on the matter, except that it should probably be documented if that’s not the case.
That make me think of the following: it may be a good thing to be able to specify some tokens not to be generated. For example, if I want to do CommonMark and nothing more, how would I disable tables and footnotes? I’m not sure if that’s really an important feature though.
Thanks for your suggestions. 😃
So I’ve tried to document the side effects as originally requested. See f5ea6d66f7084921fd403030f7faebe312935c8d. I hope this will suffice for now.
Regarding separating parsing and rendering phases, I hope we will get to this one day, but let’s do this in a separate ticket.