‹›
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.
‹›
markdown.extensions.Extension(**kwargs)
¶
Base class for extensions to subclass.
‹›
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][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:
-
dict[str, Any]–All configuration options.
‹›
markdown.extensions.Extension.getConfigInfo() -> list[tuple[str, str]]
¶
Return descriptions of all configuration options.
Returns:
-
list[tuple[str, str]]–All descriptions of configuration options.
‹›
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:
-
KeyError–If
keyis not known.
‹›
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:
-
items(Mapping[str, Any] | Iterable[tuple[str, Any]]) –Collection of configuration options.
Raises:
-
KeyError–for any unknown key.

