15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# markdown is released under the BSD license
25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# Copyright 2007, 2008 The Python Markdown Project (v. 1.7 and later)
35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# Copyright 2004 Manfred Stienstra (the original version)
55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#
65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# All rights reserved.
75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# Redistribution and use in source and binary forms, with or without
95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# modification, are permitted provided that the following conditions are met:
105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#
115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# *   Redistributions of source code must retain the above copyright
125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#     notice, this list of conditions and the following disclaimer.
135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# *   Redistributions in binary form must reproduce the above copyright
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#     notice, this list of conditions and the following disclaimer in the
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#     documentation and/or other materials provided with the distribution.
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# *   Neither the name of the <organization> nor the
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#     names of its contributors may be used to endorse or promote products
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#     derived from this software without specific prior written permission.
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#
205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# THIS SOFTWARE IS PROVIDED BY THE PYTHON MARKDOWN PROJECT ''AS IS'' AND ANY
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# DISCLAIMED. IN NO EVENT SHALL ANY CONTRIBUTORS TO THE PYTHON MARKDOWN PROJECT
245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# POSSIBILITY OF SUCH DAMAGE.
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)"""
345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)Python-Markdown Extra Extension
355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)===============================
365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)A compilation of various Python-Markdown extensions that imitates
385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)[PHP Markdown Extra](http://michelf.com/projects/php-markdown/extra/).
395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)Note that each of the individual extensions still need to be available
415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)on your PYTHONPATH. This extension simply wraps them all up as a
425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)convenience so that only one extension needs to be listed when
435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)initiating Markdown. See the documentation for each individual
445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)extension for specifics about that extension.
455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)In the event that one or more of the supported extensions are not
475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)available for import, Markdown will issue a warning and simply continue
485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)without that extension.
495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)There may be additional extensions that are distributed with
515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)Python-Markdown that are not included here in Extra. Those extensions
525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)are not part of PHP Markdown Extra, and therefore, not part of
535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)Python-Markdown Extra. If you really would like Extra to include
545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)additional extensions, we suggest creating your own clone of Extra
555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)under a differant name. You could also edit the `extensions` global
565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)variable defined below, but be aware that such changes may be lost
575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)when you upgrade to any future version of Python-Markdown.
585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)"""
605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)from __future__ import absolute_import
625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)from __future__ import unicode_literals
635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)from . import Extension
645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)extensions = ['smart_strong',
665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)              'fenced_code',
675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)              'footnotes',
685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)              'attr_list',
695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)              'def_list',
705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)              'tables',
715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)              'abbr',
725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)              ]
735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class ExtraExtension(Extension):
765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    """ Add various extensions to Markdown class."""
775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    def extendMarkdown(self, md, md_globals):
795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        """ Register extension instances. """
805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        md.registerExtensions(extensions, self.config)
815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        if not md.safeMode:
825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            # Turn on processing of markdown text within raw html
835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            md.preprocessors['html_block'].markdown_in_raw = True
845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)def makeExtension(configs={}):
865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return ExtraExtension(configs=dict(configs))
87