markdown API reference
182 public APIs from markdown (Python-Markdown/markdown) — 73 classes, 22 functions, 87 methods. Signatures extracted by static analysis of the actual source.
Repository: Python-Markdown/markdown
| Kind | Count |
|---|---|
| Classes | 73 |
| Functions | 22 |
| Methods | 87 |
API list
func
markdown.__main__.run()Run Markdown from the command line.
class
markdown.blockparser.BlockParserParse Markdown blocks into an `ElementTree` object.
method
markdown.blockparser.BlockParser.parseBlocks(parent:etree.Element, blocks:list[str]) -> NoneProcess blocks of Markdown text and attach to given `etree` node.
method
markdown.blockparser.BlockParser.parseChunk(parent:etree.Element, text:str) -> NoneParse a chunk of Markdown text and attach to given `etree` node.
method
markdown.blockparser.BlockParser.parseDocument(lines:Iterable[str]) -> etree.ElementTreeParse a Markdown document into an `ElementTree`.
class
markdown.blockparser.StateTrack the current and nested state of the parser.
method
markdown.blockparser.State.isstate(state:Any) -> boolTest that top (current) level is of given state.
method
markdown.blockparser.State.reset() -> NoneStep back one step in nested state.
method
markdown.blockparser.State.set(state:Any)Set a new state.
class
markdown.blockprocessors.BlockProcessorBase class for block processors.
method
markdown.blockprocessors.BlockProcessor.lastChild(parent:etree.Element) -> etree.Element | NoneReturn the last child of an `etree` element.
method
markdown.blockprocessors.BlockProcessor.looseDetab(text:str, level:int=1) -> strRemove a tab from front of lines but allowing dedented lines.
method
markdown.blockprocessors.BlockProcessor.run(parent:etree.Element, blocks:list[str]) -> bool | NoneRun processor.
method
markdown.blockprocessors.BlockProcessor.test(parent:etree.Element, block:str) -> boolTest for block type.
class
markdown.blockprocessors.BlockQuoteProcessorProcess blockquotes.
method
markdown.blockprocessors.BlockQuoteProcessor.clean(line:str) -> strRemove `>` from beginning of a line.
class
markdown.blockprocessors.CodeBlockProcessorProcess code blocks.
class
markdown.blockprocessors.HRProcessorProcess Horizontal Rules.
class
markdown.blockprocessors.HashHeaderProcessorProcess Hash Headers.
class
markdown.blockprocessors.ListIndentProcessorProcess children of list items.
method
markdown.blockprocessors.ListIndentProcessor.get_level(parent:etree.Element, block:str) -> tuple[int, etree.Element]Get level of indentation based on list level.
class
markdown.blockprocessors.OListProcessorProcess ordered list blocks.
method
markdown.blockprocessors.OListProcessor.get_items(block:str) -> list[str]Break a block into list items.
class
markdown.blockprocessors.ParagraphProcessorProcess Paragraph blocks.
class
markdown.blockprocessors.ReferenceProcessorProcess link references.
class
markdown.blockprocessors.SetextHeaderProcessorProcess Setext-style Headers.
class
markdown.blockprocessors.UListProcessorProcess unordered list blocks.
func
markdown.blockprocessors.build_block_parser(md:Markdown, **kwargs:Any) -> BlockParserBuild the default block parser used by Markdown.
class
markdown.core.MarkdownA parser which converts Markdown to HTML.
method
markdown.core.Markdown.build_parser() -> MarkdownBuild the parser from the various parts.
method
markdown.core.Markdown.convert(source:str) -> strConvert a Markdown string to a string in the specified output format.
method
markdown.core.Markdown.is_block_level(tag:Any) -> boolCheck if the given `tag` is a block level HTML tag.
method
markdown.core.Markdown.registerExtension(extension:Extension) -> MarkdownRegister an extension as having a resettable state.
method
markdown.core.Markdown.set_output_format(format:str) -> MarkdownSet the output format for the class instance.
func
markdown.core.markdown(text:str, **kwargs:Any) -> strConvert a markdown string to HTML and return HTML as a Unicode string.
class
markdown.extensions.ExtensionBase class for extensions to subclass.
method
markdown.extensions.Extension.getConfig(key:str, default:Any='') -> AnyReturn a single configuration option value.
method
markdown.extensions.Extension.getConfigs() -> dict[str, Any]Return all configuration options.
method
markdown.extensions.Extension.setConfig(key:str, value:Any) -> NoneSet a configuration option.
class
markdown.extensions.abbr.AbbrBlockprocessorParse text for abbreviation references.
class
markdown.extensions.abbr.AbbrExtensionAbbreviation Extension for Python-Markdown.
method
markdown.extensions.abbr.AbbrExtension.extendMarkdown(md)Register the processors.
method
markdown.extensions.abbr.AbbrExtension.load_glossary(dictionary:dict[str, str])Adds `dictionary` to our glossary.
class
markdown.extensions.abbr.AbbrInlineProcessorAbbreviation inline pattern.
class
markdown.extensions.abbr.AbbrTreeprocessorReplace abbreviation text with `<abbr>` elements.
method
markdown.extensions.abbr.AbbrTreeprocessor.create_element(title:str, text:str, tail:str) -> etree.ElementCreate an `abbr` element.
method
markdown.extensions.abbr.AbbrTreeprocessor.run(root:etree.Element) -> etree.Element | NoneStep through tree to find known abbreviations.
class
markdown.extensions.admonition.AdmonitionExtensionAdmonition extension for Python-Markdown.
method
markdown.extensions.admonition.AdmonitionExtension.extendMarkdown(md)Register the processor.
class
markdown.extensions.attr_list.AttrListExtensionAttribute List extension for Python-Markdown
method
markdown.extensions.attr_list.AttrListExtension.extendMarkdown(md)Register the processor.
func
markdown.extensions.attr_list.get_attrs(str:str) -> list[tuple[str, str]]Soft-deprecated.
method
markdown.extensions.codehilite.CodeHiliteExtension.extendMarkdown(md)Register the processor.
class
markdown.extensions.codehilite.HiliteTreeprocessorHighlight source code in code blocks.
method
markdown.extensions.codehilite.HiliteTreeprocessor.code_unescape(text:str) -> strUnescape code.
method
markdown.extensions.codehilite.HiliteTreeprocessor.run(root:etree.Element) -> NoneFind code blocks and store in `htmlStash`.
func
markdown.extensions.codehilite.parse_hl_lines(expr:str) -> list[int]Support our syntax for emphasizing certain lines of code.
class
markdown.extensions.def_list.DefListExtensionAdd definition lists to Markdown.
method
markdown.extensions.def_list.DefListExtension.extendMarkdown(md)Register the processors.
class
markdown.extensions.def_list.DefListIndentProcessorProcess indented children of definition list items.
class
markdown.extensions.def_list.DefListProcessorProcess Definition Lists.
class
markdown.extensions.extra.ExtraExtensionAdd various extensions to Markdown class.
method
markdown.extensions.extra.ExtraExtension.extendMarkdown(md)Register extension instances.
class
markdown.extensions.fenced_code.FencedBlockPreprocessorFind and extract fenced code blocks.
method
markdown.extensions.fenced_code.FencedBlockPreprocessor.run(lines:list[str]) -> list[str]Match and store Fenced Code Blocks in the `HtmlStash`.
class
markdown.extensions.footnotes.FootnoteBlockProcessorFind footnote definitions and store for later use.
method
markdown.extensions.footnotes.FootnoteBlockProcessor.detab(block:str) -> strRemove one level of indent from a block.
method
markdown.extensions.footnotes.FootnoteBlockProcessor.run(parent:etree.Element, blocks:list[str]) -> boolFind, set, and remove footnote definitions.
class
markdown.extensions.footnotes.FootnoteExtensionFootnote Extension.
method
markdown.extensions.footnotes.FootnoteExtension.addFootnoteRef(id:str) -> NoneStore a footnote reference id in order of appearance.
method
markdown.extensions.footnotes.FootnoteExtension.extendMarkdown(md)Register the processors.
method
markdown.extensions.footnotes.FootnoteExtension.get_separator() -> strGet the footnote separator.
method
markdown.extensions.footnotes.FootnoteExtension.makeFootnoteId(id:str) -> strReturn footnote link id.
method
markdown.extensions.footnotes.FootnoteExtension.makeFootnoteRefId(id:str, found:bool=False) -> strReturn footnote back-link id.
method
markdown.extensions.footnotes.FootnoteExtension.makeFootnotesDiv(root:etree.Element) -> etree.Element | NoneReturn `div` of footnotes as `etree` Element.
method
markdown.extensions.footnotes.FootnoteExtension.setFootnote(id:str, text:str) -> NoneStore a footnote for later retrieval.
method
markdown.extensions.footnotes.FootnoteExtension.unique_ref(reference:str, found:bool=False) -> strGet a unique reference if there are duplicates.
class
markdown.extensions.footnotes.FootnotePostTreeprocessorAmend footnote div with duplicates.
method
markdown.extensions.footnotes.FootnotePostTreeprocessor.get_num_duplicates(li:etree.Element) -> intGet the number of duplicate refs of the footnote.
class
markdown.extensions.footnotes.FootnotePostprocessorReplace placeholders with html entities.
class
markdown.extensions.footnotes.FootnoteReorderingProcessorReorder list items in the footnotes div.
class
markdown.extensions.footnotes.FootnoteTreeprocessorBuild and append footnote div to end of document.
class
markdown.extensions.legacy_em.LegacyEmExtensionAdd legacy_em extension to Markdown class.
method
markdown.extensions.legacy_em.LegacyEmExtension.extendMarkdown(md)Register the processor.
class
markdown.extensions.md_in_html.MarkdownInHtmlExtensionAdd Markdown parsing in HTML to Markdown class.
method
markdown.extensions.md_in_html.MarkdownInHtmlExtension.extendMarkdown(md)Register the processors.
class
markdown.extensions.meta.MetaExtensionMeta-Data extension for Python-Markdown.
method
markdown.extensions.meta.MetaExtension.extendMarkdown(md)Register the processor.
class
markdown.extensions.meta.MetaPreprocessorGet Meta-Data.
method
markdown.extensions.meta.MetaPreprocessor.run(lines:list[str]) -> list[str]Parse Meta-Data and store in Markdown.Meta.
class
markdown.extensions.nl2br.Nl2BrExtensionNewline-to-break extension for Python-Markdown.
method
markdown.extensions.nl2br.Nl2BrExtension.extendMarkdown(md)Register the processor.
class
markdown.extensions.sane_lists.SaneListExtensionAdd sane lists to Markdown.
method
markdown.extensions.sane_lists.SaneListExtension.extendMarkdown(md)Register the processors.
class
markdown.extensions.sane_lists.SaneUListProcessorOverride `SIBLING_TAGS` to not include `ol`.
class
markdown.extensions.smarty.SmartyExtensionAdd Smarty to Markdown.
method
markdown.extensions.smarty.SmartyExtension.extendMarkdown(md)Register the processors.
class
markdown.extensions.tables.TableExtensionAdd tables to Markdown.
method
markdown.extensions.tables.TableExtension.extendMarkdown(md)Register the processor.
class
markdown.extensions.tables.TableProcessorProcess Tables.
method
markdown.extensions.tables.TableProcessor.run(parent:etree.Element, blocks:list[str]) -> NoneParse a table block and build table.
class
markdown.extensions.toc.TocExtensionTable of Contents Extension to Python-Markdown.
method
markdown.extensions.toc.TocExtension.extendMarkdown(md)Register the processor.
class
markdown.extensions.toc.TocTreeprocessorStep through document and build TOC.
method
markdown.extensions.toc.TocTreeprocessor.build_toc_div(toc_list:list) -> etree.ElementReturn a string div given a toc list.
method
markdown.extensions.toc.TocTreeprocessor.replace_marker(root:etree.Element, elem:etree.Element) -> NoneReplace marker with elem.
method
markdown.extensions.toc.TocTreeprocessor.set_level(elem:etree.Element) -> NoneAdjust header level according to base level.
func
markdown.extensions.toc.escape_cdata(text:str) -> strEscape character data.
func
markdown.extensions.toc.get_name(el:etree.Element) -> strGet title name.
func
markdown.extensions.toc.render_inner_html(el:etree.Element, md:Markdown) -> strFully render inner html of an `etree` element as a string.
func
markdown.extensions.toc.run_postprocessors(text:str, md:Markdown) -> strRun postprocessors from Markdown instance on text.
func
markdown.extensions.toc.slugify(value:str, separator:str, unicode:bool=False) -> strSlugify a string, to make it URL friendly.
func
markdown.extensions.toc.strip_tags(text:str) -> strStrip HTML tags and return plain text.
func
markdown.extensions.toc.unescape(text:str) -> strUnescape Markdown backslash escaped text.
func
markdown.extensions.toc.unique(id:str, ids:MutableSet[str]) -> strEnsure id is unique in set of ids.
class
markdown.extensions.wikilinks.WikiLinkExtensionAdd inline processor to Markdown.
method
markdown.extensions.wikilinks.WikiLinkExtension.extendMarkdown(md)Register the processor.
class
markdown.extensions.wikilinks.WikiLinksInlineProcessorBuild link from `wikilink`.
func
markdown.extensions.wikilinks.build_url(label:str, base:str, end:str) -> strBuild a URL from the label, a base, and an end.
class
markdown.htmlparser.HTMLExtractorExtract raw HTML from text.
method
markdown.htmlparser.HTMLExtractor.at_line_start() -> boolReturns True if current position is at start of line.
method
markdown.htmlparser.HTMLExtractor.close()Handle any buffered data.
method
markdown.htmlparser.HTMLExtractor.get_endtag_text(tag:str) -> strReturns the text of the end tag.
method
markdown.htmlparser.HTMLExtractor.get_starttag_text() -> strReturn full source of start tag: `<...>`.
method
markdown.htmlparser.HTMLExtractor.handle_empty_tag(data:str, is_block:bool)Handle empty tags (`<data>`).
method
markdown.htmlparser.HTMLExtractor.reset()Reset this instance.
method
markdown.inlinepatterns.AsteriskProcessor.build_double(m:re.Match[str], tags:str, idx:int) -> etree.ElementReturn double tag.
method
markdown.inlinepatterns.AsteriskProcessor.build_element(m:re.Match[str], builder:str, tags:str, index:int) -> etree.ElementElement builder.
method
markdown.inlinepatterns.AsteriskProcessor.build_single(m:re.Match[str], tag:str, idx:int) -> etree.ElementReturn single tag.
method
markdown.inlinepatterns.AsteriskProcessor.handleMatch(m:re.Match[str], data:str) -> tuple[etree.Element | None, int | None, int | None]Parse patterns.
method
markdown.inlinepatterns.AsteriskProcessor.parse_sub_patterns(data:str, parent:etree.Element, last:etree.Element | None, idx:int) -> NoneParses sub patterns.
class
markdown.inlinepatterns.EmStrongItemEmphasis/strong pattern item.
class
markdown.inlinepatterns.EscapeInlineProcessorReturn an escaped character.
class
markdown.inlinepatterns.HtmlInlineProcessorStore raw inline html and return a placeholder.
method
markdown.inlinepatterns.HtmlInlineProcessor.unescape(text:str) -> strReturn unescaped text given text with an inline placeholder.
class
markdown.inlinepatterns.ImageInlineProcessorReturn a `img` element from the given match.
class
markdown.inlinepatterns.ImageReferenceInlineProcessorMatch to a stored reference and return `img` element.
class
markdown.inlinepatterns.InlineProcessorBase class that inline processors subclass.
class
markdown.inlinepatterns.LinkInlineProcessorReturn a link element from the given match.
class
markdown.inlinepatterns.PatternBase class that inline patterns subclass.
method
markdown.inlinepatterns.Pattern.getCompiledRegExp() -> re.PatternReturn a compiled regular expression.
method
markdown.inlinepatterns.Pattern.handleMatch(m:re.Match[str]) -> etree.Element | strReturn a ElementTree element from the given match.
method
markdown.inlinepatterns.Pattern.type() -> strReturn class name, to define pattern type
method
markdown.inlinepatterns.Pattern.unescape(text:str) -> strReturn unescaped text given text with an inline placeholder.
class
markdown.inlinepatterns.ReferenceInlineProcessorMatch to a stored reference and return link element.
method
markdown.inlinepatterns.ReferenceInlineProcessor.evalId(data:str, index:int, text:str) -> tuple[str | None, int, bool]Evaluate the id portion of `[ref][id]`.
class
markdown.inlinepatterns.ShortImageReferenceInlineProcessorShort form of image reference: `![ref]`.
method
markdown.inlinepatterns.ShortImageReferenceInlineProcessor.evalId(data:str, index:int, text:str) -> tuple[str, int, bool]Evaluate the id of `[ref]`.
class
markdown.inlinepatterns.ShortReferenceInlineProcessorShort form of reference: `[google]`.
method
markdown.inlinepatterns.ShortReferenceInlineProcessor.evalId(data:str, index:int, text:str) -> tuple[str, int, bool]Evaluate the id of `[ref]`.
class
markdown.inlinepatterns.SimpleTextInlineProcessorReturn a simple text of `group(1)` of a Pattern.
class
markdown.inlinepatterns.SimpleTextPatternReturn a simple text of `group(2)` of a Pattern.
method
markdown.inlinepatterns.SimpleTextPattern.handleMatch(m:re.Match[str]) -> strReturn string content of `group(2)` of a matching pattern.
class
markdown.inlinepatterns.SubstituteTagInlineProcessorReturn an element of type `tag` with no children.
class
markdown.inlinepatterns.SubstituteTagPatternReturn an element of type `tag` with no children.
func
markdown.inlinepatterns.build_inlinepatterns(md:Markdown, **kwargs:Any) -> util.Registry[InlineProcessor]Build the default set of inline patterns for Markdown.
func
markdown.inlinepatterns.dequote(string:str) -> strRemove quotes from around a string.
class
markdown.postprocessors.AndSubstitutePostprocessorRestore valid entities
class
markdown.postprocessors.RawHtmlPostprocessorRestore raw html to the document.
method
markdown.postprocessors.RawHtmlPostprocessor.isblocklevel(html:str) -> boolCheck is block of HTML is block-level.
method
markdown.postprocessors.RawHtmlPostprocessor.run(text:str) -> strIterate over html stash and restore html.
method
markdown.postprocessors.RawHtmlPostprocessor.stash_to_string(text:str) -> strConvert a stashed object to a string.
class
markdown.postprocessors.UnescapePostprocessorRestore escaped chars.
func
markdown.postprocessors.build_postprocessors(md:Markdown, **kwargs:Any) -> util.Registry[Postprocessor]Build the default postprocessors for Markdown.
class
markdown.preprocessors.NormalizeWhitespaceNormalize whitespace for consistent parsing.
class
markdown.preprocessors.PreprocessorPreprocessors are run after the text is broken into lines.
func
markdown.serializers.to_html_string(element:Element) -> strSerialize element and its children to a string of HTML5.
func
markdown.serializers.to_xhtml_string(element:Element) -> strSerialize element and its children to a string of XHTML.
method
markdown.treeprocessors.InlineProcessor.run(tree:etree.Element, ancestors:list[str] | None=None) -> etree.ElementApply inline patterns to a parsed Markdown tree.
class
markdown.treeprocessors.PrettifyTreeprocessorAdd line breaks to the html document.
method
markdown.treeprocessors.PrettifyTreeprocessor.run(root:etree.Element) -> NoneAdd line breaks to `Element` object and its children.
class
markdown.treeprocessors.UnescapeTreeprocessorRestore escaped chars
method
markdown.treeprocessors.UnescapeTreeprocessor.run(root:etree.Element) -> NoneLoop over all elements and unescape all text.
func
markdown.treeprocessors.build_treeprocessors(md:Markdown, **kwargs:Any) -> util.Registry[Treeprocessor]Build the default `treeprocessors` for Markdown.
class
markdown.util.AtomicStringA string which should not be further processed.
class
markdown.util.ProcessorThe base class for all processors.
class
markdown.util.RegistryA priority sorted registry.
method
markdown.util.Registry.deregister(name:str, strict:bool=True) -> NoneRemove an item from the registry.
method
markdown.util.Registry.get_index_for_name(name:str) -> intReturn the index of the given name.
method
markdown.util.Registry.register(item:_T, name:str, priority:float) -> NoneAdd an item to the registry with the given name and priority.
func
markdown.util.code_escape(text:str) -> strHTML escape a string of code.
func
markdown.util.parseBoolValue(value:str | None, fail_on_errors:bool=True, preserve_none:bool=False) -> bool | NoneParses a string representing a boolean value.
About this data
These signatures were extracted from the public source of Python-Markdown/markdown
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.