Reputation: 9825
I am trying to render a table into HTML using Markdown syntax with the help of Python-markdown: https://python-markdown.github.io/
I tried the example provided here: https://python-markdown.github.io/extensions/tables/
from markdown import markdown
s = """
First Header | Second Header
------------- | -------------
Content Cell | Content Cell
Content Cell | Content Cell
"""
html = markdown(s)
print(html)
But what I get as the result is:
<p>First Header | Second Header
------------- | -------------
Content Cell | Content Cell
Content Cell | Content Cell</p>
What is wrong?
Upvotes: 11
Views: 8018
Reputation: 596
Since tables is an extension, you need to pass its name to markdown.markdown
:
html = markdown(s, extensions=['tables'])
https://python-markdown.github.io/extensions/
Upvotes: 18