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

Method extendMarkdown

markdown/extensions/smarty.py:259–291  ·  view source on GitHub ↗

Register the processors. | Class Instance | Registry | Name | Priority | | --------------------------------------------------------------------------- | ----------

(self, md)

Source from the content-addressed store, hash-verified

257 self._addPatterns(md, patterns, 'quotes', 30)
258
259 def extendMarkdown(self, md):
260 """ Register the processors.
261
262 | Class Instance | Registry | Name | Priority |
263 | --------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------ | :------: |
264 | [`markdown.treeprocessors.InlineProcessor`][markdown.treeprocessors.InlineProcessor] | [`treeprocessors`][markdown.treeprocessors.build_treeprocessors] | `smarty` | `6` |
265 | [`markdown.inlinepatterns.HtmlInlineProcessor`][markdown.inlinepatterns.HtmlInlineProcessor] | [`inlinepatterns`][markdown.inlinepatterns.build_inlinepatterns] | `html` | `90` |
266
267 The `HtmlInlineProcessor` , above, is only used if the `smart_angled_quotes` option is enabled.
268
269 The `InlineProcessor`, above, is a separate instance from the `InlineProcessor` used for
270 standard inline parsing. It contains a collection of inline patterns dependent upon the
271 various configuration options.
272
273 """
274 # flake8: noqa: E501 263-265
275 configs = self.getConfigs()
276 self.inlinePatterns: Registry[inlinepatterns.InlineProcessor] = Registry()
277 if configs['smart_ellipses']:
278 self.educateEllipses(md)
279 if configs['smart_quotes']:
280 self.educateQuotes(md)
281 if configs['smart_angled_quotes']:
282 self.educateAngledQuotes(md)
283 # Override `HTML_RE` from `inlinepatterns.py` so that it does not
284 # process tags with duplicate closing quotes.
285 md.inlinePatterns.register(HtmlInlineProcessor(HTML_STRICT_RE, md), 'html', 90)
286 if configs['smart_dashes']:
287 self.educateDashes(md)
288 inlineProcessor = InlineProcessor(md)
289 inlineProcessor.inlinePatterns = self.inlinePatterns
290 md.treeprocessors.register(inlineProcessor, 'smarty', 6)
291 md.ESCAPED_CHARS.extend(['"', "'"])
292
293
294def makeExtension(**kwargs): # pragma: no cover

Callers

nothing calls this directly

Calls 9

educateEllipsesMethod · 0.95
educateQuotesMethod · 0.95
educateAngledQuotesMethod · 0.95
educateDashesMethod · 0.95
RegistryClass · 0.85
HtmlInlineProcessorClass · 0.85
getConfigsMethod · 0.80
registerMethod · 0.80
InlineProcessorClass · 0.50

Tested by

no test coverage detected