GitHub-flavored Markdown#
Enable GitHub-flavored Markdown features with the github preset, then add
GitHub alert blockquotes when your product needs them.
Use the GitHub preset#
Use the github preset when you want tables, task list items, strikethrough,
bare URL autolinks, footnotes, and GFM disallowed HTML handling.
from wenmode import Wenmode
from wenmode.presets import github
wen = Wenmode(github)
text = '''
- [x] done
| A | B |
| --- | --- |
| **x** | https://example.com |
'''
html = wen.render(text)
assert '<input checked="" disabled="" type="checkbox">' in html
assert '<table>' in html
assert '<a href="https://example.com">https://example.com</a>' in html
For exact preset membership, see Presets and Rule matrix.
Add GitHub alerts#
GitHub alert blockquotes are provided by the github_alert plugin. Use it with
the github preset when your Markdown should support alert blocks such as
[!NOTE], [!TIP], [!IMPORTANT], [!WARNING], and [!CAUTION].
from wenmode import Wenmode
from wenmode.plugins import github_alert
from wenmode.presets import github
wen = Wenmode(github, plugins=[github_alert])
text = '''
> [!NOTE]
> **Read** this before deploying.
'''
html = wen.render(text)
assert '<div class="markdown-alert markdown-alert-note">' in html
assert '<p class="markdown-alert-title">Note</p>' in html
assert '<strong>Read</strong>' in html
When you want Wenmode’s admonition HTML classes instead of GitHub’s
markdown-alert classes, configure the plugin:
from wenmode import Wenmode
from wenmode.plugins import github_alert
from wenmode.presets import github
wen = Wenmode(github, plugins=[github_alert.configure(html_style='admonition')])
text = '''
> [!WARNING]
> Check the migration notes.
'''
html = wen.render(text)
assert '<aside class="admonition admonition-warning">' in html
assert '<p class="admonition-title">Warning</p>' in html
Custom alert types can be added with the alerts option. Defaults stay
enabled unless you override their titles:
from wenmode import Wenmode
from wenmode.plugins import github_alert
from wenmode.presets import github
wen = Wenmode(github, plugins=[
github_alert.configure(alerts={'think': 'Thinking'})
])
html = wen.render('> [!THINK]\n> Internal reasoning.\n')
assert '<div class="markdown-alert markdown-alert-think">' in html
assert '<p class="markdown-alert-title">Thinking</p>' in html
The alert plugin replaces the enabled blockquote rule. It does not enable
blockquote syntax by itself, so pair it with github, commonmark, or an
explicit rule list that includes blockquotes.