Home | History | Annotate | Download | only in extensions
      1 #!/usr/bin/env python
      2 """
      3 Python-Markdown Extra Extension
      4 ===============================
      5 
      6 A compilation of various Python-Markdown extensions that imitates
      7 [PHP Markdown Extra](http://michelf.com/projects/php-markdown/extra/).
      8 
      9 Note that each of the individual extensions still need to be available
     10 on your PYTHONPATH. This extension simply wraps them all up as a 
     11 convenience so that only one extension needs to be listed when
     12 initiating Markdown. See the documentation for each individual
     13 extension for specifics about that extension.
     14 
     15 In the event that one or more of the supported extensions are not 
     16 available for import, Markdown will issue a warning and simply continue 
     17 without that extension. 
     18 
     19 There may be additional extensions that are distributed with 
     20 Python-Markdown that are not included here in Extra. Those extensions
     21 are not part of PHP Markdown Extra, and therefore, not part of
     22 Python-Markdown Extra. If you really would like Extra to include
     23 additional extensions, we suggest creating your own clone of Extra
     24 under a differant name. You could also edit the `extensions` global 
     25 variable defined below, but be aware that such changes may be lost 
     26 when you upgrade to any future version of Python-Markdown.
     27 
     28 """
     29 
     30 import markdown
     31 
     32 extensions = ['fenced_code',
     33               'footnotes',
     34               'headerid',
     35               'def_list',
     36               'tables',
     37               'abbr',
     38               ]
     39               
     40 
     41 class ExtraExtension(markdown.Extension):
     42     """ Add various extensions to Markdown class."""
     43 
     44     def extendMarkdown(self, md, md_globals):
     45         """ Register extension instances. """
     46         md.registerExtensions(extensions, self.config)
     47 
     48 def makeExtension(configs={}):
     49     return ExtraExtension(configs=dict(configs))
     50