fairdm.utils.markdown#
Markdown rendering with HTML sanitisation.
Module Contents#
Functions#
Render markdown to HTML that is safe to insert into a page. |
API#
- markdownify(content)[source]#
Render markdown to HTML that is safe to insert into a page.
Markdown authored by users may contain raw HTML, so the rendered output is sanitised before it is returned: scripts, event-handler attributes and dangerous URL schemes are stripped, and links gain
rel="noopener noreferrer". The extensions applied come fromsettings.FAIRDM_MARKDOWN_EXTENSIONS.Both the
safe_markdowntemplate filter and the editor’s live preview render through this function, so a preview always matches the page.Args: content: The markdown source.
Nonerenders as an empty string.Returns: The sanitised HTML.
Example: >>> markdownify(“bold ”) ‘
bold
’