PyMdown Extensions
Overview
PyMdown Extensions is a collection of extensions for Python Markdown. They were originally written to make writing documentation more enjoyable. They cover a wide range of solutions, and while not every extension is needed by all people, there is usually at least one useful extension for everybody.
Usage
All extensions are found under the module namespace of pymdownx
. Assuming we wanted to specify the use of the MagicLink extension, we would include it in Python Markdown like so:
>>> import markdown
>>> text = "A link https://google.com"
>>> html = markdown.markdown(text, extensions=['pymdownx.magiclink'])
'<p>A link <a href="https://google.com">https://google.com</a></p>'
Check out documentation on each extension to learn more about how to configure and use each one.
Reminder
Please read the Usage Notes for information on extension compatibility and general notes to be aware of when using these extensions.
Extensions
Arithmatex
Arithmatex is an extension that preserves LaTeX math equations (\(\frac{\sqrt x}{y^3}\)) during the Markdown conversion process so that they can be used with MathJax.
B64
B64 converts all local images in a document to base64 encoding and embeds them in the document.
BetterEm
BetterEm is a different approach to emphasis than Python Markdown's default. It works similar but handles certain corner cases differently.
Caret
Caret is an extension that is syntactically built around the ^
character. It adds support for inserting superscripts and adds an easy way to place text in an <ins>
tag.
Critic
Critic adds handling and support of Critic Markup.
Emoji
Emoji makes adding emoji via Markdown easy .
EscapeAll
EscapeAll allows the escaping of any character, some with additional effects. Check it out to learn more.
Extra
Extra is just like Python Markdown's Extra package except it uses PyMdown Extensions to substitute similar extensions.
Highlight
Highlight allows you to configure the syntax highlighting of SuperFences and InlineHilite. Also passes standard Markdown indented code blocks through the syntax highlighter.
InlineHilite
InlineHilite highlights inline code: from module import function as func
.
Keys
Keys makes inserting key inputs into documents as easy as pressing Ctrl+Alt+Del.
MagicLink
MagicLink linkafies URL and email links without having to wrap them in Markdown syntax. Also, shortens repository issue, pull request, and commit links automatically for popular code hosting providers. You can even use special shorthand syntax to link to issues, diffs, and even mention people
Mark
Mark allows you to mark words easily.
PathConverter
PathConverter converts paths to absolute or relative to a given base path.
SaneHeaders
SaneHeaders modifies hash headers to only be evaluated if the starting hash symbols are followed by at least one space. This is useful if you use other extensions that also use the hash symbol (like our own MagicLink extension).
SmartSymbols
SmartSymbols inserts commonly used Unicode characters via simple ASCII representations: =/=
→ ≠.
Snippets
Snippets include other Markdown or HTML snippets into the current Markdown file being parsed.
StripHTML
StripHTML can strip out HTML comments and specific tag attributes.
SuperFences
SuperFences is like Python Markdown's fences, but better. Nest fences under lists, admonitions, and other syntaxes. You can even create special custom fences for content like UML.
graph TB
c1-->a2
subgraph one
a1-->a2
end
subgraph two
b1-->b2
end
subgraph three
c1-->c2
end
```diagram
graph TB
c1-->a2
subgraph one
a1-->a2
end
subgraph two
b1-->b2
end
subgraph three
c1-->c2
end
```
Tilde
Tilde is syntactically built around the ~
character. It adds support for inserting subscripts and adds an easy way to place text in a <del>
tag.