markdown.extensions.abbr
§
This extension adds abbreviation handling to Python-Markdown.
See the documentation for details.
Classes:
-
AbbrExtension–Abbreviation Extension for Python-Markdown.
-
AbbrTreeprocessor–Replace abbreviation text with
<abbr>elements. -
AbbrBlockprocessor–Parse text for abbreviation references.
-
AbbrInlineProcessor–Abbreviation inline pattern.
markdown.extensions.abbr.AbbrExtension(**kwargs)
§
Bases: Extension
Abbreviation Extension for Python-Markdown.
Methods:
-
reset–Clear all previously defined abbreviations.
-
reset_glossary–Clear all abbreviations from the glossary.
-
load_glossary–Adds
dictionaryto our glossary. Any abbreviations that already exist will be overwritten. -
extendMarkdown–Register the processors.
Attributes:
-
config–Default configuration options.
markdown.extensions.abbr.AbbrExtension.config
instance-attribute
§
markdown.extensions.abbr.AbbrExtension.reset()
§
Clear all previously defined abbreviations.
markdown.extensions.abbr.AbbrExtension.reset_glossary()
§
Clear all abbreviations from the glossary.
markdown.extensions.abbr.AbbrExtension.load_glossary(dictionary: dict[str, str])
§
Adds dictionary to our glossary. Any abbreviations that already exist will be overwritten.
markdown.extensions.abbr.AbbrExtension.extendMarkdown(md)
§
Register the processors.
| Class Instance | Registry | Name | Priority |
|---|---|---|---|
AbbrTreeprocessor |
treeprocessors |
abbr |
7 |
AbbrBlockprocessor |
blockprocessors |
abbr |
16 |
markdown.extensions.abbr.AbbrTreeprocessor(md: Markdown | None = None, abbrs: dict | None = None)
§
Bases: Treeprocessor
Replace abbreviation text with <abbr> elements.
Methods:
-
create_element–Create an
abbrelement. -
iter_element–Recursively iterate over elements, run regex on text and wrap matches in
abbrtags. -
run–Step through tree to find known abbreviations.
markdown.extensions.abbr.AbbrTreeprocessor.create_element(title: str, text: str, tail: str) -> etree.Element
§
Create an abbr element.
markdown.extensions.abbr.AbbrTreeprocessor.iter_element(el: etree.Element, parent: etree.Element | None = None) -> None
§
Recursively iterate over elements, run regex on text and wrap matches in abbr tags.
markdown.extensions.abbr.AbbrTreeprocessor.run(root: etree.Element) -> etree.Element | None
§
Step through tree to find known abbreviations.
markdown.extensions.abbr.AbbrBlockprocessor(parser: BlockParser, abbrs: dict)
§
Bases: BlockProcessor
Parse text for abbreviation references.
Methods:
-
run–Find and remove all abbreviation references from the text.
markdown.extensions.abbr.AbbrBlockprocessor.run(parent: etree.Element, blocks: list[str]) -> bool
§
Find and remove all abbreviation references from the text. Each reference is added to the abbreviation collection.
markdown.extensions.abbr.AbbrInlineProcessor(pattern: str, title: str)
deprecated
§
Bases: InlineProcessor
Deprecated
This class will be removed in the future; use AbbrTreeprocessor instead.
Abbreviation inline pattern.