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 |
configured |
configured |
|
|
|
inline + transform |
no |
yes |
no |
|
none |
|
inline |
no |
yes |
yes |
|
none |
|
inline |
no |
yes |
no |
|
none |
|
block |
no |
no |
no |
|
none |
|
block |
no |
no |
no |
|
none |
|
inline |
no |
no |
no |
|
none |
github configures Table(require_body_pipe=False), 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
Table(require_body_pipe=False), Image(references=False), and
Link(references=False) to keep tables GFM-compatible while avoiding
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.
Plugin rules#
These rules are not part of wenmode.rules. Enable them with the plugins
argument from wenmode.plugins when your dialect needs the syntax.
The plugin name in the first column is the module you import from
wenmode.plugins.
Plugin |
Rule class |
Kind |
Generated node or behavior |
Streaming note |
|---|---|---|---|---|
|
|
transform |
rewrites matching text to |
not streaming-compatible |
|
|
continuation |
|
compatible |
|
|
block + transform |
stores parsed data on |
compatible |
|
|
block |
replaces enabled |
compatible |
|
|
node transform |
adds generated |
compatible |
|
|
block |
replaces |
compatible |
|
configured fenced rule |
block |
|
compatible |
|
configured literal rule |
inline |
|
compatible |
|
|
block |
|
compatible |
|
configured delimiter rule |
inline |
|
compatible |
|
|
block |
|
compatible |
|
|
inline |
|
compatible |
|
configured delimiter rule |
inline |
|
compatible |
|
configured delimiter rule |
inline |
|
compatible |
|
|
inline |
|
compatible |
|
|
inline |
|
compatible |
|
|
inline |
|
compatible |
fenced_directive defaults to backtick and tilde fences and
literal_names={"code-block"}. Pass a custom fence tuple when a dialect also
accepts colon fences.
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.wenmode.plugins.abbr, because matching text nodes are rewritten after abbreviation definitions are collected.
Use the streaming preset when latency matters. It keeps tables,
strikethrough, direct links, and direct images, but leaves shortcut and
reference-style links as text.
If a custom rule set raises StreamingUnsupportedError, compare it with this
section first. The issue is usually a rule or transform that waits for the full
document before resolving inline content.
Common customizations#
Generate heading IDs while keeping a small dialect:
from wenmode import Wenmode
from wenmode.headings import HeadingIdTransform
from wenmode.rules import AtxHeading, SetextHeading
wen = Wenmode([
AtxHeading(transforms=[HeadingIdTransform()]),
SetextHeading(transforms=[HeadingIdTransform()]),
])
Disable reference-style links for streaming-like behavior without using the full streaming preset:
from wenmode import Wenmode
from wenmode.rules import Image, Link
wen = 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'),
]