Jump to >


Markdown extension to safely escape HTML content.

This is built as a replacement for the safe_mode='escape' Markdown render mode, which is deprecated in Python-Markdown 2.5.

class EscapeHTMLExtension(**kwargs)[source]

Bases: markdown.extensions.Extension

Extension to safely escape HTML content.

This will remove any HTML preprocessors and patterns from the renderer, preventing HTML from being interpreted in any form. This results in the HTML being escaped instead, directly mimicking the behavior of the old safe_mode='escape'.


Extend the list of Markdown processors.

Rather than extending, this will actually remove all HTML-based processors from the renderer, ensuring that the HTML is instead escaped.


md (markdown.Markdown) – The Markdown renderer.

makeExtension(*args, **kwargs)[source]

Create and return an instance of this extension.

  • *args (tuple) – Positional arguments for the extension.

  • **kwargs (dict) – Keyword arguments for the extension.


The extension instance.

Return type