‹› markdown.extensions

Markdown accepts an Extension instance for each extension. Therefore, each extension must to define a class that extends Extension and over-rides the extendMarkdown method. Within this class one can manage configuration options for their extension and attach the various processors and patterns which make up an extension to the Markdown instance.

Modules:

  • abbr

    This extension adds abbreviation handling to Python-Markdown.

  • admonition

    Adds rST-style admonitions to Python-Markdown.

  • attr_list

    Adds attribute list syntax to Python-Markdown.

  • codehilite

    Adds code/syntax highlighting to standard Python-Markdown code blocks.

  • def_list

    Adds parsing of Definition Lists to Python-Markdown.

  • extra

    A compilation of various Python-Markdown extensions that imitates

  • fenced_code

    This extension adds Fenced Code Blocks to Python-Markdown.

  • footnotes

    Adds footnote handling to Python-Markdown.

  • legacy_attrs

    An extension to Python Markdown which implements legacy attributes.

  • legacy_em

    This extension provides legacy behavior for connected_words.

  • md_in_html

    Parse Markdown syntax within raw HTML.

  • meta

    This extension adds Meta Data handling to markdown.

  • nl2br

    A Python-Markdown extension to treat newlines as hard breaks.

  • sane_lists

    Modify the behavior of Lists in Python-Markdown to act in a sane manor.

  • smarty

    Convert ASCII dashes, quotes and ellipses to their HTML entity equivalents.

  • tables

    Adds parsing of tables to Python-Markdown.

  • toc

    Add table of contents support to Python-Markdown.

  • wikilinks

    Converts [[WikiLinks]] to relative links.

Classes:

  • Extension

    Base class for extensions to subclass.

‹› markdown.extensions.Extension(**kwargs)

Base class for extensions to subclass.

Methods:

  • getConfig

    Return a single configuration option value.

  • getConfigs

    Return all configuration options.

  • getConfigInfo

    Return descriptions of all configuration options.

  • setConfig

    Set a configuration option.

  • setConfigs

    Loop through a collection of configuration options, passing each to

  • extendMarkdown

    Add the various processors and patterns to the Markdown Instance.

Attributes:

‹› markdown.extensions.Extension.config: Mapping[str, list] class-attribute instance-attribute

Default configuration for an extension.

This attribute is to be defined in a subclass and must be of the following format:

config = {
    'key': ['value', 'description']
}

Note that setConfig will raise a KeyError if a default is not set for each option.

Defined Value:

config: Mapping[str, list] = {}

‹› markdown.extensions.Extension.getConfig(key: str, default: Any = '') -> Any

Return a single configuration option value.

Parameters:

  • key (str) –

    The configuration option name.

  • default (Any, default: '' ) –

    Default value to return if key is not set.

Returns:

  • Any

    Value of stored configuration option.

‹› markdown.extensions.Extension.getConfigs() -> dict[str, Any]

Return all configuration options.

Returns:

‹› markdown.extensions.Extension.getConfigInfo() -> list[tuple[str, str]]

Return descriptions of all configuration options.

Returns:

‹› markdown.extensions.Extension.setConfig(key: str, value: Any) -> None

Set a configuration option.

If the corresponding default value set in config is a bool value or None, then value is passed through parseBoolValue before being stored.

Parameters:

  • key (str) –

    Name of configuration option to set.

  • value (Any) –

    Value to assign to option.

Raises:

‹› markdown.extensions.Extension.setConfigs(items: Mapping[str, Any] | Iterable[tuple[str, Any]]) -> None

Loop through a collection of configuration options, passing each to setConfig.

Parameters:

Raises:

‹› markdown.extensions.Extension.extendMarkdown(md: Markdown) -> None

Add the various processors and patterns to the Markdown Instance.

This method must be overridden by every extension.

Parameters:

  • md (Markdown) –

    The Markdown instance.