MCPcopy
hub / github.com/Python-Markdown/markdown / Markdown

Class Markdown

markdown/core.py:46–465  ·  view source on GitHub ↗

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_leve

Source from the content-addressed store, hash-verified

44
45
46class Markdown:
47 """
48 A parser which converts Markdown to HTML.
49
50 Attributes:
51 Markdown.tab_length (int): The number of spaces which correspond to a single tab. Default: `4`.
52 Markdown.ESCAPED_CHARS (list[str]): List of characters which get the backslash escape treatment.
53 Markdown.block_level_elements (list[str]): List of HTML tags which get treated as block-level elements.
54 See [`markdown.util.BLOCK_LEVEL_ELEMENTS`][] for the full list of elements.
55 Markdown.registeredExtensions (list[Extension]): List of extensions which have called
56 [`registerExtension`][markdown.Markdown.registerExtension] during setup.
57 Markdown.doc_tag (str): Element used to wrap document. Default: `div`.
58 Markdown.stripTopLevelTags (bool): Indicates whether the `doc_tag` should be removed. Default: 'True'.
59 Markdown.references (dict[str, tuple[str, str]]): A mapping of link references found in a parsed document
60 where the key is the reference name and the value is a tuple of the URL and title.
61 Markdown.htmlStash (util.HtmlStash): The instance of the `HtmlStash` used by an instance of this class.
62 Markdown.output_formats (dict[str, Callable[xml.etree.ElementTree.Element]]): A mapping of known output
63 formats by name and their respective serializers. Each serializer must be a callable which accepts an
64 [`Element`][xml.etree.ElementTree.Element] and returns a `str`.
65 Markdown.output_format (str): The output format set by
66 [`set_output_format`][markdown.Markdown.set_output_format].
67 Markdown.serializer (Callable[xml.etree.ElementTree.Element]): The serializer set by
68 [`set_output_format`][markdown.Markdown.set_output_format].
69 Markdown.preprocessors (util.Registry): A collection of [`preprocessors`][markdown.preprocessors].
70 Markdown.parser (blockparser.BlockParser): A collection of [`blockprocessors`][markdown.blockprocessors].
71 Markdown.inlinePatterns (util.Registry): A collection of [`inlinepatterns`][markdown.inlinepatterns].
72 Markdown.treeprocessors (util.Registry): A collection of [`treeprocessors`][markdown.treeprocessors].
73 Markdown.postprocessors (util.Registry): A collection of [`postprocessors`][markdown.postprocessors].
74
75 """
76
77 doc_tag = "div" # Element used to wrap document - later removed
78
79 output_formats: ClassVar[dict[str, Callable[[Element], str]]] = {
80 'html': to_html_string,
81 'xhtml': to_xhtml_string,
82 }
83 """
84 A mapping of known output formats by name and their respective serializers. Each serializer must be a
85 callable which accepts an [`Element`][xml.etree.ElementTree.Element] and returns a `str`.
86 """
87
88 def __init__(self, **kwargs):
89 """
90 Creates a new Markdown instance.
91
92 Keyword Arguments:
93 extensions (list[Extension | str]): A list of extensions.
94
95 If an item is an instance of a subclass of [`markdown.extensions.Extension`][],
96 the instance will be used as-is. If an item is of type `str`, it is passed
97 to [`build_extension`][markdown.Markdown.build_extension] with its corresponding
98 `extension_configs` and the returned instance of [`markdown.extensions.Extension`][]
99 is used.
100 extension_configs (dict[str, dict[str, Any]]): Configuration settings for extensions.
101 output_format (str): Format of output. Supported formats are:
102
103 * `xhtml`: Outputs XHTML style tags. Default.

Callers 6

assertMarkdownRendersMethod · 0.90
test_abbr_resetMethod · 0.90
testTOCResetMethod · 0.90
test_stash_to_stringMethod · 0.90
markdownFunction · 0.85
markdownFromFileFunction · 0.85

Calls

no outgoing calls

Tested by 4

assertMarkdownRendersMethod · 0.72
test_abbr_resetMethod · 0.72
testTOCResetMethod · 0.72
test_stash_to_stringMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…