# ‹› `` `markdown.extensions.footnotes`

Adds footnote handling to Python-Markdown.

See the documentation for details.

Classes:

- `FootnoteExtension` –

  Footnote Extension.

- `FootnoteBlockProcessor` –

  Find footnote definitions and store for later use.

- `FootnoteInlineProcessor` –

  `InlineProcessor` for footnote markers in a document’s body text.

- `FootnotePostTreeprocessor` –

  Amend footnote div with duplicates.

- `FootnoteTreeprocessor` –

  Build and append footnote div to end of document.

- `FootnoteReorderingProcessor` –

  Reorder list items in the footnotes div.

- `FootnotePostprocessor` –

  Replace placeholders with html entities.

Functions:

- `makeExtension` –

  Return an instance of the `FootnoteExtension`

## ‹› `` `markdown.extensions.footnotes.FootnoteExtension(**kwargs)`

Bases: `Extension`

Footnote Extension.

Methods:

- `extendMarkdown` –

  Register the processors.

- `reset` –

  Clear footnotes on reset, and prepare for distinct document.

- `unique_ref` –

  Get a unique reference if there are duplicates.

- `findFootnotesPlaceholder` –

  Return ElementTree Element that contains Footnote placeholder.

- `setFootnote` –

  Store a footnote for later retrieval.

- `addFootnoteRef` –

  Store a footnote reference id in order of appearance.

- `get_separator` –

  Get the footnote separator.

- `makeFootnoteId` –

  Return footnote link id.

- `makeFootnoteRefId` –

  Return footnote back-link id.

- `makeFootnotesDiv` –

  Return `div` of footnotes as `etree` Element.

Attributes:

- `config` –

  Default configuration options.

### ‹› `` `markdown.extensions.footnotes.FootnoteExtension.config` `instance-attribute`

Default configuration options.

Defined Value:

    self.config = {
        'PLACE_MARKER': [
            '///Footnotes Go Here///', 'The text string that marks where the footnotes go'
        ],
        'UNIQUE_IDS': [
            False, 'Avoid name collisions across multiple calls to `reset()`.'
        ],
        'BACKLINK_TEXT': [
            '&#8617;', "The text string that links from the footnote to the reader's place."
        ],
        'SUPERSCRIPT_TEXT': [
            '{}', "The text string that links from the reader's place to the footnote."
        ],
        'BACKLINK_TITLE': [
            'Jump back to footnote %d in the text',
            'The text string used for the title HTML attribute of the backlink. '
            '%d will be replaced by the footnote number.'
        ],
        'SEPARATOR': [
            ':', 'Footnote separator.'
        ],
        'USE_DEFINITION_ORDER': [
            True,
            'Order footnote labels by definition order (True) or by document order (False). '
            'Default: True.'
        ]
    }

### ‹› `` `markdown.extensions.footnotes.FootnoteExtension.extendMarkdown(md)`

Register the processors.

Class Instance | Registry | Name | Priority
--- | --- | --- | ---
`FootnoteBlockProcessor` | `blockprocessors` | `footnote` | `17`
`FootnoteInlineProcessor` | `inlinepatterns` | `footnote` | `175`
`FootnoteTreeprocessor` | `treeprocessors` | `footnote` | `50`
`FootnoteReorderingProcessor` | `treeprocessors` | `footnote-reorder` | `19`
`FootnotePostTreeprocessor` | `treeprocessors` | `footnote-duplicate` | `15`
`FootnotePostprocessor` | `postprocessors` | `footnote` | `25`

### ‹› `` `markdown.extensions.footnotes.FootnoteExtension.reset() -> None`

Clear footnotes on reset, and prepare for distinct document.

### ‹› `` `markdown.extensions.footnotes.FootnoteExtension.unique_ref(reference: str, found: bool = False) -> str`

Get a unique reference if there are duplicates.

### ‹› `` `markdown.extensions.footnotes.FootnoteExtension.findFootnotesPlaceholder(root: etree.Element) -> tuple[etree.Element, etree.Element, bool] | None`

Return ElementTree Element that contains Footnote placeholder.

### ‹› `` `markdown.extensions.footnotes.FootnoteExtension.setFootnote(id: str, text: str) -> None`

Store a footnote for later retrieval.

### ‹› `` `markdown.extensions.footnotes.FootnoteExtension.addFootnoteRef(id: str) -> None`

Store a footnote reference id in order of appearance.

### ‹› `` `markdown.extensions.footnotes.FootnoteExtension.get_separator() -> str`

Get the footnote separator.

### ‹› `` `markdown.extensions.footnotes.FootnoteExtension.makeFootnoteId(id: str) -> str`

Return footnote link id.

### ‹› `` `markdown.extensions.footnotes.FootnoteExtension.makeFootnoteRefId(id: str, found: bool = False) -> str`

Return footnote back-link id.

### ‹› `` `markdown.extensions.footnotes.FootnoteExtension.makeFootnotesDiv(root: etree.Element) -> etree.Element | None`

Return `div` of footnotes as `etree` Element.

## ‹› `` `markdown.extensions.footnotes.FootnoteBlockProcessor(footnotes: FootnoteExtension)`

Bases: `BlockProcessor`

Find footnote definitions and store for later use.

Methods:

- `run` –

  Find, set, and remove footnote definitions.

- `detectTabbed` –

  Find indented text and remove indent before further processing.

- `detab` –

  Remove one level of indent from a block.

### ‹› `` `markdown.extensions.footnotes.FootnoteBlockProcessor.run(parent: etree.Element, blocks: list[str]) -> bool`

Find, set, and remove footnote definitions.

### ‹› `` `markdown.extensions.footnotes.FootnoteBlockProcessor.detectTabbed(blocks: list[str]) -> list[str]`

Find indented text and remove indent before further processing.

Returns:

- `list[str]` –

  A list of blocks with indentation removed.

### ‹› `` `markdown.extensions.footnotes.FootnoteBlockProcessor.detab(block: str) -> str`

Remove one level of indent from a block.

Preserve lazily indented blocks by only removing indent from indented lines.

## ‹› `` `markdown.extensions.footnotes.FootnoteInlineProcessor(pattern: str, footnotes: FootnoteExtension)`

Bases: `InlineProcessor`

`InlineProcessor` for footnote markers in a document’s body text.

## ‹› `` `markdown.extensions.footnotes.FootnotePostTreeprocessor(footnotes: FootnoteExtension)`

Bases: `Treeprocessor`

Amend footnote div with duplicates.

Methods:

- `add_duplicates` –

  Adjust current `li` and add the duplicates: `fnref2`, `fnref3`, etc.

- `get_num_duplicates` –

  Get the number of duplicate refs of the footnote.

- `handle_duplicates` –

  Find duplicate footnotes and format and add the duplicates.

- `run` –

  Crawl the footnote div and add missing duplicate footnotes.

### ‹› `` `markdown.extensions.footnotes.FootnotePostTreeprocessor.add_duplicates(li: etree.Element, duplicates: int) -> None`

Adjust current `li` and add the duplicates: `fnref2`, `fnref3`, etc.

### ‹› `` `markdown.extensions.footnotes.FootnotePostTreeprocessor.get_num_duplicates(li: etree.Element) -> int`

Get the number of duplicate refs of the footnote.

### ‹› `` `markdown.extensions.footnotes.FootnotePostTreeprocessor.handle_duplicates(parent: etree.Element) -> None`

Find duplicate footnotes and format and add the duplicates.

### ‹› `` `markdown.extensions.footnotes.FootnotePostTreeprocessor.run(root: etree.Element) -> None`

Crawl the footnote div and add missing duplicate footnotes.

## ‹› `` `markdown.extensions.footnotes.FootnoteTreeprocessor(footnotes: FootnoteExtension)`

Bases: `Treeprocessor`

Build and append footnote div to end of document.

## ‹› `` `markdown.extensions.footnotes.FootnoteReorderingProcessor(footnotes: FootnoteExtension)`

Bases: `Treeprocessor`

Reorder list items in the footnotes div.

## ‹› `` `markdown.extensions.footnotes.FootnotePostprocessor(footnotes: FootnoteExtension)`

Bases: `Postprocessor`

Replace placeholders with html entities.

## ‹› `` `markdown.extensions.footnotes.makeExtension(**kwargs)`

Return an instance of the `FootnoteExtension`