Skip to content

Markdown/HTML injection #880

Answered by Archmonger
numpde asked this question in Question
Discussion options

You must be logged in to vote

You can use markdown with the following steps:

  1. Convert the markdown to a string using your preferred library (such as python-markdown)
  2. Use idom.utils.html_to_vdom to convert it to VDOM
  3. Render the VDOM within an IDOM component.
import markdown
from idom.utils import html_to_vdom
from idom import component, run, html

example_md = "### Hello World"
example_html = markdown.markdown(example_md)
example_vdom = html_to_vdom(example_html)

@component
def example_component():
    return html.div(example_vdom)


run(example_component)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by numpde
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants