Skip to content

Commit 8453df0

Browse files
authored
Update Extension API documentation
* Document the priorities assigned by each extension for the API Reference. * Link Extension API docs to API Reference. Various sections were reduced to avoid repetition with the API Reference. Other sections were expanded to provide more links. A deeper explanation of the registry priority has been added. Fixes 1612.
1 parent 93ac448 commit 8453df0

21 files changed

Lines changed: 353 additions & 246 deletions

.spell-dict

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ namespace
8080
NanoDOM
8181
Neale
8282
nosetests
83+
noqa
8384
OrderedDict
8485
OrderedDicts
8586
OSX

docs/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ See the [Contributing Guide](contributing.md) for details.
1616

1717
* Fix `SetextHeaderProcessor` regex to prevent mixed `=` and `-` chars in setext-style headers (#1606).
1818
* Officially document all included extensions as being in maintenance mode.
19+
* Link the Extension API documentation to the API Reference (#1612).
1920

2021
## [3.10.2] - 2026-02-09
2122

docs/extensions/api.md

Lines changed: 187 additions & 232 deletions
Large diffs are not rendered by default.

markdown/extensions/abbr.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,16 @@ def load_glossary(self, dictionary: dict[str, str]):
6969
self.glossary = {**dictionary, **self.glossary}
7070

7171
def extendMarkdown(self, md):
72-
""" Insert `AbbrTreeprocessor` and `AbbrBlockprocessor`. """
72+
"""
73+
Register the processors.
74+
75+
| Class Instance | Registry | Name | Priority |
76+
| ------------------------------------------------------------------- | ---------------------------------------------------------------- | ------ | :------: |
77+
| [`AbbrTreeprocessor`][markdown.extensions.abbr.AbbrTreeprocessor] | [`treeprocessors`][markdown.treeprocessors.build_treeprocessors] | `abbr` | `7` |
78+
| [`AbbrBlockprocessor`][markdown.extensions.abbr.AbbrBlockprocessor] | [`blockprocessors`][markdown.blockprocessors.build_block_parser] | `abbr` | `16` |
79+
80+
"""
81+
# flake8: noqa: E501 75-78
7382
if (self.config['glossary'][0]):
7483
self.load_glossary(self.config['glossary'][0])
7584
self.abbrs.update(self.glossary)

markdown/extensions/admonition.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ class AdmonitionExtension(Extension):
4141
""" Admonition extension for Python-Markdown. """
4242

4343
def extendMarkdown(self, md):
44-
""" Add Admonition to Markdown instance. """
44+
"""
45+
Register the processor.
46+
47+
| Class Instance | Registry | Name | Priority |
48+
| --------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------ | :------: |
49+
| [`AdmonitionProcessor`][markdown.extensions.admonition.AdmonitionProcessor] | [`blockprocessors`][markdown.blockprocessors.build_block_parser] | `admonition` | `105` |
50+
51+
"""
52+
# flake8: noqa: E501 47-49
4553
md.registerExtension(self)
4654

4755
md.parser.blockprocessors.register(AdmonitionProcessor(md.parser), 'admonition', 105)

markdown/extensions/attr_list.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,15 @@ def sanitize_name(self, name: str) -> str:
196196
class AttrListExtension(Extension):
197197
""" Attribute List extension for Python-Markdown """
198198
def extendMarkdown(self, md):
199+
"""
200+
Register the processor.
201+
202+
| Class Instance | Registry | Name | Priority |
203+
| --------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------ | :------: |
204+
| [`AttrListTreeprocessor`][markdown.extensions.attr_list.AttrListTreeprocessor] | [`treeprocessors`][markdown.treeprocessors.build_treeprocessors] | `attr_list` | `8` |
205+
206+
"""
207+
# flake8: noqa: E501 202-204
199208
md.treeprocessors.register(AttrListTreeprocessor(md), 'attr_list', 8)
200209
md.registerExtension(self)
201210

markdown/extensions/codehilite.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,15 @@ def __init__(self, **kwargs):
335335
self.config[key] = [value, '']
336336

337337
def extendMarkdown(self, md):
338-
""" Add `HilitePostprocessor` to Markdown instance. """
338+
"""
339+
Register the processor.
340+
341+
| Class Instance | Registry | Name | Priority |
342+
| --------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------ | :------: |
343+
| [`HiliteTreeprocessor`][markdown.extensions.codehilite.HiliteTreeprocessor] | [`treeprocessors`][markdown.treeprocessors.build_treeprocessors] | `hilite` | `30` |
344+
345+
"""
346+
# flake8: noqa: E501 341-343
339347
hiliter = HiliteTreeprocessor(md)
340348
hiliter.config = self.getConfigs()
341349
md.treeprocessors.register(hiliter, 'hilite', 30)

markdown/extensions/def_list.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,16 @@ class DefListExtension(Extension):
110110
""" Add definition lists to Markdown. """
111111

112112
def extendMarkdown(self, md):
113-
""" Add an instance of `DefListProcessor` to `BlockParser`. """
113+
"""
114+
Register the processors.
115+
116+
| Class Instance | Registry | Name | Priority |
117+
| --------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------ | :------: |
118+
| [`DefListIndentProcessor`][markdown.extensions.def_list.DefListIndentProcessor] | [`blockprocessors`][markdown.blockprocessors.build_block_parser] | `defindent` | `85` |
119+
| [`DefListProcessor`][markdown.extensions.def_list.DefListProcessor] | [`blockprocessors`][markdown.blockprocessors.build_block_parser] | `deflist` | `25` |
120+
121+
"""
122+
# flake8: noqa: E501 116-119
114123
md.parser.blockprocessors.register(DefListIndentProcessor(md.parser), 'defindent', 85)
115124
md.parser.blockprocessors.register(DefListProcessor(md.parser), 'deflist', 25)
116125

markdown/extensions/fenced_code.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ def __init__(self, **kwargs):
4444
super().__init__(**kwargs)
4545

4646
def extendMarkdown(self, md):
47-
""" Add `FencedBlockPreprocessor` to the Markdown instance. """
47+
"""
48+
Register the processor.
49+
50+
| Class Instance | Registry | Name | Priority |
51+
| --------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------ | :------: |
52+
| [`FencedBlockPreprocessor`][markdown.extensions.fenced_code.FencedBlockPreprocessor] | [`blockprocessors`][markdown.blockprocessors.build_block_parser] | `fenced_code_block` | `25` |
53+
54+
"""
55+
# flake8: noqa: E501 50-52
4856
md.registerExtension(self)
4957

5058
md.preprocessors.register(FencedBlockPreprocessor(md, self.getConfigs()), 'fenced_code_block', 25)

markdown/extensions/footnotes.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,19 @@ def __init__(self, **kwargs):
8383
self.reset()
8484

8585
def extendMarkdown(self, md):
86-
""" Add pieces to Markdown. """
86+
""" Register the processors.
87+
88+
| Class Instance | Registry | Name | Priority |
89+
| --------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------ | :------: |
90+
| [`FootnoteBlockProcessor`][markdown.extensions.footnotes.FootnoteBlockProcessor] | [`blockprocessors`][markdown.blockprocessors.build_block_parser] | `footnote` | `17` |
91+
| [`FootnoteInlineProcessor`][markdown.extensions.footnotes.FootnoteInlineProcessor] | [`inlinepatterns`][markdown.inlinepatterns.build_inlinepatterns] | `footnote` | `175` |
92+
| [`FootnoteTreeprocessor`][markdown.extensions.footnotes.FootnoteTreeprocessor] | [`treeprocessors`][markdown.treeprocessors.build_treeprocessors] | `footnote` | `50` |
93+
| [`FootnoteReorderingProcessor`][markdown.extensions.footnotes.FootnoteReorderingProcessor] | [`treeprocessors`][markdown.treeprocessors.build_treeprocessors] | `footnote-reorder` | `19` |
94+
| [`FootnotePostTreeprocessor`][markdown.extensions.footnotes.FootnotePostTreeprocessor] | [`treeprocessors`][markdown.treeprocessors.build_treeprocessors] | `footnote-duplicate` | `15` |
95+
| [`FootnotePostprocessor`][markdown.extensions.footnotes.FootnotePostprocessor] | [`postprocessors`][markdown.postprocessors.build_postprocessors] | `footnote` | `25` |
96+
97+
"""
98+
# flake8: noqa: E501 88-95
8799
md.registerExtension(self)
88100
self.parser = md.parser
89101
self.md = md

0 commit comments

Comments
 (0)