MCPcopy Create free account
hub / github.com/Python-Markdown/markdown / __init__

Method __init__

markdown/core.py:88–131  ·  view source on GitHub ↗

Creates a new Markdown instance. Keyword Arguments: 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

(self, **kwargs)

Source from the content-addressed store, hash-verified

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.
104 * `html`: Outputs HTML style tags.
105 tab_length (int): Length of tabs in the source. Default: `4`
106
107 """
108
109 self.last_run: float = 0.0
110 self.tab_length: int = kwargs.get('tab_length', 4)
111
112 self.ESCAPED_CHARS: list[str] = [
113 '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!'
114 ]
115 """ List of characters which get the backslash escape treatment. """
116
117 self.block_level_elements: list[str] = BLOCK_LEVEL_ELEMENTS.copy()
118
119 self.registeredExtensions: list[Extension] = []
120 self.docType = "" # TODO: Maybe delete this. It does not appear to be used anymore.
121 self.stripTopLevelTags: bool = True
122 self.delimiters: DelimiterProcessor | None = None
123
124 self.build_parser()
125
126 self.references: dict[str, tuple[str, str]] = {}
127 self.htmlStash: util.HtmlStash = util.HtmlStash()
128 self.registerExtensions(extensions=kwargs.get('extensions', []),
129 configs=kwargs.get('extension_configs', {}))
130 self.set_output_format(kwargs.get('output_format', 'xhtml'))
131 self.reset()
132
133 def build_parser(self) -> Markdown:
134 """

Callers

nothing calls this directly

Calls 4

build_parserMethod · 0.95
registerExtensionsMethod · 0.95
set_output_formatMethod · 0.95
resetMethod · 0.95

Tested by

no test coverage detected