# ‹› `` `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 `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:

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