15 lines
400 B
Python
15 lines
400 B
Python
from markdown_it import MarkdownIt
|
|
|
|
_markdown = MarkdownIt('js-default', {'html': False, 'breaks': True})
|
|
|
|
|
|
def render_markdown(text):
|
|
"""Render markdown text to safe HTML.
|
|
|
|
Raw HTML is escaped and dangerous link schemes (javascript:, data:,
|
|
vbscript:) are rejected by markdown-it with html=False.
|
|
"""
|
|
if not text:
|
|
return ''
|
|
return _markdown.render(text).rstrip('\n')
|