Jump to >


Markdown extension to render content similar to the source in e-mails.

This will render Markdown such that the spacing and alignment in the source text and the rendered content looks roughly the same. It’s meant to help ensure that what’s typed is very close to what’s viewed when rendered.

class InlineStyleProcessor(md=None)[source]

Bases: markdown.treeprocessors.Treeprocessor

Injects CSS styles directly into the tags, for use in e-mails.

This will process each element and, depending on the element type, create inline styles. These styles are meant to match the stylesheets in the markdown-wysiwyg.less file.

process_element(context, el)[source]

Process an element in the tree.

This adds a handful of inline styles to the resulting document which mimic the .rich-text rules in markdown-wysiwyg.less.

This does not do quite everything that the markdown-wysiwyg.less rules do, due to the complexity in implementing CSS selectors in Python, and the CSS compatibility logic in most e-mail clients.

The end result is that the e-mail will look similar but not identical to the page.


Subclasses of Treeprocessor should implement a run method, which takes a root ElementTree. This method can return another ElementTree object, and the existing root ElementTree will be replaced, or it can modify the current tree and return None.

__annotations__ = {}
class WysiwygEMailExtension(**kwargs)[source]

Bases: markdown.extensions.Extension

A Markdown extension to inject CSS into elements for HTML output.

This is meant as a counterpart to the Wysiwyg Markdown extension. It aims to provide HTML output that looks as similar as possible to the input, preserving the spacing, font sizes, alignment, and other styles from the raw text.

This is meant to be used with the following Markdown configuration and extensions:

    'extensions': [
        'codehilite(noclasss=True)', 'tables',

Extend the list of Markdown processors.


md (markdown.Markdown) – The Markdown instance.

__annotations__ = {}
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