Debian Codegraph @

markdown/extensions/extra.py

raw
1 # Python-Markdown Extra Extension
2 # ===============================
3
4 # A compilation of various Python-Markdown extensions that imitates
5 # [PHP Markdown Extra](http://michelf.com/projects/php-markdown/extra/).
6
7 # See https://Python-Markdown.github.io/extensions/extra
8 # for documentation.
9
10 # Copyright The Python Markdown Project
11
12 # License: [BSD](https://opensource.org/licenses/bsd-license.php)
13
14 """
15 A compilation of various Python-Markdown extensions that imitates
16 [PHP Markdown Extra](http://michelf.com/projects/php-markdown/extra/).
17
18 Note that each of the individual extensions still need to be available
19 on your `PYTHONPATH`. This extension simply wraps them all up as a
20 convenience so that only one extension needs to be listed when
21 initiating Markdown. See the documentation for each individual
22 extension for specifics about that extension.
23
24 There may be additional extensions that are distributed with
25 Python-Markdown that are not included here in Extra. Those extensions
26 are not part of PHP Markdown Extra, and therefore, not part of
27 Python-Markdown Extra. If you really would like Extra to include
28 additional extensions, we suggest creating your own clone of Extra
29 under a different name. You could also edit the `extensions` global
30 variable defined below, but be aware that such changes may be lost
31 when you upgrade to any future version of Python-Markdown.
32
33 See the [documentation](https://Python-Markdown.github.io/extensions/extra)
34 for details.
35 """
36
37 from __future__ import annotations
38
39 from . import Extension
40
41 extensions = [
42 'fenced_code',
43 'footnotes',
44 'attr_list',
45 'def_list',
46 'tables',
47 'abbr',
48 'md_in_html'
49 ]
50 """ The list of included extensions. """
51
52
53 class ExtraExtension(Extension):
54 """ Add various extensions to Markdown class."""
55
56 def __init__(self, **kwargs):
57 """ `config` is a dumb holder which gets passed to the actual extension later. """
58 self.config = kwargs
59
60 def extendMarkdown(self, md):
61 """ Register extension instances. """
62 md.registerExtensions(extensions, self.config)
63
64
65 def makeExtension(**kwargs): # pragma: no cover
66 return ExtraExtension(**kwargs)