markdown
§
Python-Markdown provides two public functions (markdown.markdown and markdown.markdownFromFile)
both of which wrap the public class markdown.Markdown. All submodules support these public functions
and class and/or provide extension support.
Modules:
-
core–Core functionality.
-
preprocessors–Pre-processors.
-
blockparser–Core Markdown block parser.
-
blockprocessors–Block processors.
-
treeprocessors–Tree processors.
-
inlinepatterns–Inline patterns.
-
postprocessors–Post-processors.
-
serializers–Serializers.
-
util–Utility functions.
-
htmlparser–HTML parser.
-
test_tools–Testing utilities.
-
extensions–Markdown extensions.
Classes:
-
Markdown–A parser which converts Markdown to HTML.
Functions:
-
markdown–Convert a markdown string to HTML and return HTML as a Unicode string.
-
markdownFromFile–Read Markdown text from a file or stream and write HTML output to a file or stream.
markdown.Markdown(**kwargs)
§
A parser which converts Markdown to HTML.
Attributes:
-
Markdown.tab_length(int) –The number of spaces which correspond to a single tab. Default:
4. -
Markdown.ESCAPED_CHARS(list[str]) –List of characters which get the backslash escape treatment.
-
Markdown.block_level_elements(list[str]) –List of HTML tags which get treated as block-level elements. See
markdown.util.BLOCK_LEVEL_ELEMENTSfor the full list of elements. -
Markdown.registeredExtensions(list[Extension]) –List of extensions which have called
registerExtensionduring setup. -
Markdown.doc_tag(str) –Element used to wrap document. Default:
div. -
Markdown.stripTopLevelTags(bool) –Indicates whether the
doc_tagshould be removed. Default: ‘True’. -
Markdown.references(dict[str, tuple[str, str]]) –A mapping of link references found in a parsed document where the key is the reference name and the value is a tuple of the URL and title.
-
Markdown.htmlStash(HtmlStash) –The instance of the
HtmlStashused by an instance of this class. -
Markdown.output_formats(dict[str, Callable[Element]]) –A mapping of known output formats by name and their respective serializers. Each serializer must be a callable which accepts an
Elementand returns astr. -
Markdown.output_format(str) –The output format set by
set_output_format. -
Markdown.serializer(Callable[Element]) –The serializer set by
set_output_format. -
Markdown.preprocessors(Registry) –A collection of
preprocessors. -
Markdown.parser(BlockParser) –A collection of
blockprocessors. -
Markdown.inlinePatterns(Registry) –A collection of
inlinepatterns. -
Markdown.treeprocessors(Registry) –A collection of
treeprocessors. -
Markdown.postprocessors(Registry) –A collection of
postprocessors.
Other Parameters:
-
extensions(list[Extension | str]) –A list of extensions.
If an item is an instance of a subclass of
markdown.extensions.Extension, the instance will be used as-is. If an item is of typestr, it is passed tobuild_extensionwith its correspondingextension_configsand the returned instance ofmarkdown.extensions.Extensionis used. -
extension_configs(dict[str, dict[str, Any]]) –Configuration settings for extensions.
-
output_format(str) –Format of output. Supported formats are:
xhtml: Outputs XHTML style tags. Default.html: Outputs HTML style tags.
-
tab_length(int) –Length of tabs in the source. Default:
4
Methods:
-
build_parser–Build the parser from the various parts.
-
registerExtensions–Load a list of extensions into an instance of the
Markdownclass. -
build_extension–Build extension from a string name, then return an instance using the given
configs. -
registerExtension–Register an extension as having a resettable state.
-
reset–Resets all state variables to prepare the parser instance for new input.
-