Rule matrix¶
Compare Wenmode rules by preset membership, generated nodes, configuration options, and streaming compatibility.
Use this page when you are building a custom dialect and need to decide which rules to enable. For syntax examples and default HTML output, use the Reference pages. For constructor details, use the generated Rules API page.
Preset membership¶
Rule |
Kind |
commonmark |
github |
streaming |
Generated node or behavior |
Options |
|---|---|---|---|---|---|---|
|
block |
yes |
yes |
yes |
|
none |
|
block |
yes |
yes |
yes |
|
none |
|
block |
yes |
yes |
yes |
|
none |
|
block |
yes |
configured |
yes |
|
|
|
block |
yes |
configured |
yes |
|
|
|
block |
yes |
yes |
yes |
|
|
|
continuation |
yes |
yes |
yes |
|
|
|
block |
yes |
yes |
yes |
|
none |
|
inline |
yes |
yes |
yes |
|
none |
|
inline |
yes |
yes |
yes |
|
none |
|
inline |
yes |
configured |
yes |
|
|
|
inline |
yes |
yes |
yes |
text escaping |
none |
|
inline |
yes |
yes |
yes |
decoded text |
none |
|
inline |
yes |
yes |
configured |
|
|
|
inline |
yes |
yes |
configured |
|
|
|
inline |
yes |
yes |
yes |
|
none |
|
inline |
yes |
yes |
yes |
|
none |
|
block |
no |
yes |
no |
|
none |
|
inline + transform |
no |
yes |
no |
|
none |
|
inline |
no |
yes |
no |
|
none |
|
inline |
no |
yes |
no |
|
none |
github configures HtmlBlock and RawHtml with the GFM disallowed tag list,
uses RawHtml(comment_style="gfm"), and configures List(task=True) so task
list markers become listItem.checked values. streaming configures
Image(references=False) and Link(references=False) to avoid document-wide
reference resolution.
ReferenceDefinition is enabled automatically by Link(references=True) and
Image(references=True). FootnoteDefinition is enabled automatically by
Footnote. You normally configure the user-facing inline rules rather than
adding those definition rules directly.
Extension-only rules¶
These rules are not part of the built-in commonmark, github, or streaming
presets. Enable them explicitly when your dialect needs the syntax.
Rule |
Kind |
Generated node or behavior |
Streaming note |
|---|---|---|---|
|
transform |
rewrites matching text to |
not streaming-compatible |
|
continuation |
|
compatible |
|
block |
|
compatible |
|
block |
|
compatible |
|
block |
|
compatible |
|
block |
|
compatible |
|
block |
|
compatible |
|
inline |
|
compatible |
|
inline |
|
compatible |
|
inline |
|
compatible |
|
inline |
|
compatible |
|
inline |
|
compatible |
|
inline |
|
compatible |
|
inline |
|
compatible |
|
inline |
|
compatible |
|
inline |
|
compatible |
Streaming compatibility¶
Streaming works only when enabled rules do not need deferred document-wide inline
resolution. Avoid these when using Wenmode(streaming).stream(...):
Link(references=True)andImage(references=True), because they attachReferenceTransform.Footnote, because footnote references need collected definitions.Abbreviation, because matching text nodes are rewritten after abbreviation definitions are collected.
Use the streaming preset when latency matters. It keeps direct links and
images, but leaves shortcut and reference-style links as text.
Common customizations¶
Generate heading IDs while keeping a small dialect:
from wenmode import Wenmode
from wenmode.rules import AtxHeading, SetextHeading
wenmode = Wenmode([
AtxHeading(id_transform=True),
SetextHeading(id_transform=True),
])
Disable reference-style links for streaming-like behavior without using the full streaming preset:
from wenmode import Wenmode
from wenmode.rules import Image, Link
wenmode = Wenmode([
Link(references=False),
Image(references=False),
])
Filter GFM-disallowed raw HTML tags in a custom rule list:
from wenmode.presets import GFM_DISALLOWED_HTML_TAGS
from wenmode.rules import HtmlBlock, RawHtml
rules = [
HtmlBlock(disallowed_tags=GFM_DISALLOWED_HTML_TAGS),
RawHtml(disallowed_tags=GFM_DISALLOWED_HTML_TAGS, comment_style='gfm'),
]