djblets.markdown.extensions.wysiwyg_email¶
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)¶
Bases:
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)¶
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.
- run(root)¶
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.
- class WysiwygEMailExtension(**kwargs)¶
Bases:
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', 'djblets.markdown.extentions.wysiwyg', ], }
- extendMarkdown(md)¶
Extend the list of Markdown processors.
- Parameters:
md (
markdown.Markdown
) – The Markdown instance.
- makeExtension(*args, **kwargs)¶
Create and return an instance of this extension.
- Parameters:
- Returns:
The extension instance.
- Return type: