β€Ήβ€Ί markdown.extensions.abbr ΒΆ

This extension adds abbreviation handling to Python-Markdown.

See the documentation for details.

Classes:

β€Ήβ€Ί 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 dictionary to our glossary. Any abbreviations that already exist will be overwritten.

  • extendMarkdown –

    Insert AbbrTreeprocessor and AbbrBlockprocessor.

Attributes:

  • config –

    Default configuration options.

β€Ήβ€Ί 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.

Methods:

  • create_element –

    Create an abbr element.

  • iter_element –

    Recursively iterate over elements, run regex on text and wrap matches in abbr tags.

  • 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.