MCPcopy Create free account
hub / github.com/Python-Markdown/markdown / FootnoteExtension

Class FootnoteExtension

markdown/extensions/footnotes.py:39–243  ·  view source on GitHub ↗

Footnote Extension.

Source from the content-addressed store, hash-verified

37
38
39class FootnoteExtension(Extension):
40 """ Footnote Extension. """
41
42 def __init__(self, **kwargs):
43 """ Setup configs. """
44
45 self.config = {
46 'PLACE_MARKER': [
47 '///Footnotes Go Here///', 'The text string that marks where the footnotes go'
48 ],
49 'UNIQUE_IDS': [
50 False, 'Avoid name collisions across multiple calls to `reset()`.'
51 ],
52 'BACKLINK_TEXT': [
53 '↩', "The text string that links from the footnote to the reader's place."
54 ],
55 'SUPERSCRIPT_TEXT': [
56 '{}', "The text string that links from the reader's place to the footnote."
57 ],
58 'BACKLINK_TITLE': [
59 'Jump back to footnote %d in the text',
60 'The text string used for the title HTML attribute of the backlink. '
61 '%d will be replaced by the footnote number.'
62 ],
63 'SEPARATOR': [
64 ':', 'Footnote separator.'
65 ],
66 'USE_DEFINITION_ORDER': [
67 True,
68 'Order footnote labels by definition order (True) or by document order (False). '
69 'Default: True.'
70 ]
71 }
72 """ Default configuration options. """
73 super().__init__(**kwargs)
74
75 # In multiple invocations, emit links that don't get tangled.
76 self.unique_prefix = 0
77 self.found_refs: dict[str, int] = {}
78 self.used_refs: set[str] = set()
79
80 # Backward compatibility with old '%d' placeholder
81 self.setConfig('BACKLINK_TITLE', self.getConfig("BACKLINK_TITLE").replace("%d", "{}"))
82
83 self.reset()
84
85 def extendMarkdown(self, md):
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

Callers 2

testInstanceExtensionMethod · 0.90
makeExtensionFunction · 0.85

Calls

no outgoing calls

Tested by 1

testInstanceExtensionMethod · 0.72