MCPcopy Index your code
hub / github.com/Python-Markdown/markdown / registerExtensions

Method registerExtensions

markdown/core.py:159–193  ·  view source on GitHub ↗

Load a list of extensions into an instance of the `Markdown` class. 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

(
        self,
        extensions: Sequence[Extension | str],
        configs: Mapping[str, dict[str, Any]]
    )

Source from the content-addressed store, hash-verified

157 return self
158
159 def registerExtensions(
160 self,
161 extensions: Sequence[Extension | str],
162 configs: Mapping[str, dict[str, Any]]
163 ) -> Markdown:
164 """
165 Load a list of extensions into an instance of the `Markdown` class.
166
167 Arguments:
168 extensions (list[Extension | str]): A list of extensions.
169
170 If an item is an instance of a subclass of [`markdown.extensions.Extension`][],
171 the instance will be used as-is. If an item is of type `str`, it is passed
172 to [`build_extension`][markdown.Markdown.build_extension] with its corresponding `configs` and the
173 returned instance of [`markdown.extensions.Extension`][] is used.
174 configs (dict[str, dict[str, Any]]): Configuration settings for extensions.
175
176 """
177 for ext in extensions:
178 if isinstance(ext, str):
179 ext = self.build_extension(ext, configs.get(ext, {}))
180 if isinstance(ext, Extension):
181 ext.extendMarkdown(self)
182 logger.debug(
183 'Successfully loaded extension "%s.%s".'
184 % (ext.__class__.__module__, ext.__class__.__name__)
185 )
186 elif ext is not None:
187 raise TypeError(
188 'Extension "{}.{}" must be of type: "{}.{}"'.format(
189 ext.__class__.__module__, ext.__class__.__name__,
190 Extension.__module__, Extension.__name__
191 )
192 )
193 return self
194
195 def build_extension(self, ext_name: str, configs: Mapping[str, Any]) -> Extension:
196 """

Callers 2

__init__Method · 0.95
extendMarkdownMethod · 0.80

Calls 2

build_extensionMethod · 0.95
extendMarkdownMethod · 0.45

Tested by

no test coverage detected