Skip to content
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

3.0.0 AstRender is gone? #349

Closed
matthewdeanmartin opened this issue Jun 8, 2023 · 5 comments · Fixed by #351
Closed

3.0.0 AstRender is gone? #349

matthewdeanmartin opened this issue Jun 8, 2023 · 5 comments · Fixed by #351

Comments

@matthewdeanmartin
Copy link
Contributor

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.

@lepture
Copy link
Owner

lepture commented Jun 9, 2023

@matthewdeanmartin
Copy link
Contributor Author

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?

@lepture
Copy link
Owner

lepture commented Jun 9, 2023

@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'}]}]}]

@lepture lepture closed this as completed Jun 9, 2023
@matthewdeanmartin
Copy link
Contributor Author

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.

@lepture
Copy link
Owner

lepture commented Jun 9, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants