lepture/mistune

3.0.0 AstRender is gone?

matthewdeanmartin opened this issue · 5 comments

If I set the renderer to "ast", it will attempt to treat the string "ast" as a class.
If I set renderer to None as shown here I get an HTML Render.

The 3.0.0 documentation still mentions the AstRenderer/"ast" parameter.

I guess you're in your rights to remove a class from your library, but at the very least that documentation is confusing. If someone wants the AST, passing None to the renderer and getting back an HTML string is not a similar solution, it is a unrelated solution to an unrelated problem. If all I have is an HTML string, I'd have to run it through Beautiful Soup or the like to get an AST again.

Mistune used to be a library where you could get an Abstract Syntax Tree, as compared to libraries that go directly from markdown to HTML.

Is the intention that the AST is to be a 3rd party plugin?

@matthewdeanmartin If you pass renderer=None, the returning result is the Abstract Syntax Tree.

>>> import mistune
>>> md = mistune.create_markdown(renderer=None)
>>> md('hello **world**')
[{'type': 'paragraph', 'children': [{'type': 'text', 'raw': 'hello '}, {'type': 'strong', 'children': [{'type': 'text', 'raw': 'world'}]}]}]

Would you mind if I created a merge request to make "ast" a synonym for None?

I can't easily explain why, but mistune.create_markdown() and mistune.create_markdown(renderer=None) behaving differently is very non-intuitive.

Also, if renderer="ast" was restored, it would restore some compatibility with 2.x and you could still use the more cryptic renderer=None if that was more intuitive.

@matthewdeanmartin yeah. It would be ok to alias ast to None.