‹› markdown.extensions.abbr

This extension adds abbreviation handling to Python-Markdown.

See the documentation for details.

‹› markdown.extensions.abbr.AbbrExtension(**kwargs)

Bases: Extension

Abbreviation Extension for Python-Markdown.

‹› markdown.extensions.abbr.AbbrExtension.config instance-attribute

Default configuration options.

Defined Value:

self.config = {
    'glossary': [
        {},
        'A dictionary where the `key` is the abbreviation and the `value` is the definition.'
        "Default: `{}`"
    ],
}

‹› 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)

Insert AbbrTreeprocessor and AbbrBlockprocessor.

‹› markdown.extensions.abbr.AbbrTreeprocessor(md: Markdown | None = None, abbrs: dict | None = None)

Bases: Treeprocessor

Replace abbreviation text with <abbr> elements.

‹› 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.

‹› 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.