1 min read
pyssg.plugins.markdown
Markdown loader + parser plugin.
Loads .md files (load_node) and, in the parse phase, renders the body to
content_html and records the heading tree (the toc extension's
toc_tokens) on node.ast for the content-meta plugin. Frontmatter splitting
runs in an earlier parse stage (see the frontmatter plugin), so this plugin reads
__body__ if present, falling back to the raw text.
Rendering uses Python-Markdown <https://python-markdown.github.io/>_ with a
fixed extension set: fenced_code (so ``` blocks become
<pre><code class="language-...">, which the mermaid/highlight plugins rewrite),
tables (GFM-style pipe tables), sane_lists and toc. The toc
extension assigns heading id attributes using the project's :func:slugify,
so in-page anchors resolve and the same slug is shared with the link resolver's
fragment links.
The parser instance is reused across documents but reset() is called before
every parse, so no state leaks between documents and two builds are byte-identical.
Third-party (markdown) lives only in this peripheral plugin, never in
pyssg.core.
class MarkdownPlugin
Parses Markdown documents to HTML via Python-Markdown.
MarkdownPlugin.__init__(self) -> None
MarkdownPlugin.apply(self, builder: Builder) -> None
markdown() -> MarkdownPlugin
Factory used in pyssg.config.py.