extra.py 1.8 KB

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