widgetti/reacton

Markdown example does not work with myst_parser>=0.18

Alexboiboi opened this issue · 1 comments

The example from https://github.com/widgetti/reacton#markdown-component-example does not work with myst_parser>=0.18 since the to_html function has been removed from the python api (see https://github.com/executablebooks/MyST-Parser/blob/28725fceb8e1e117cb247b06a267f82c501ce527/CHANGELOG.md#breaking-changes)

One solution:

@reacton.component
def Markdown(md: str):
    from markdown_it.renderer import RendererHTML
    from myst_parser.config.main import MdParserConfig
    from myst_parser.parsers.mdit import create_md_parser
    md_parser = create_md_parser(MdParserConfig(), RendererHTML)
    html = md_parser.render(md)
    return w.HTML(value=html)

BR, Alex

(FYI, sorry for the late reply, just noticed I didn't get GH notifications from the repo)

I just fixed this in af8b6e0 , and also included a Markdown example at:

Markdown example live with Jupyter lite
Markdown component and editor