\@sdZddlmZddlmZddlmZddlmZddlmZdd l Z d d d d dddgZ GdddeZ iddZ GdddeZ d S)a Python-Markdown Extra Extension =============================== A compilation of various Python-Markdown extensions that imitates [PHP Markdown Extra](http://michelf.com/projects/php-markdown/extra/). Note that each of the individual extensions still need to be available on your PYTHONPATH. This extension simply wraps them all up as a convenience so that only one extension needs to be listed when initiating Markdown. See the documentation for each individual extension for specifics about that extension. In the event that one or more of the supported extensions are not available for import, Markdown will issue a warning and simply continue without that extension. There may be additional extensions that are distributed with Python-Markdown that are not included here in Extra. Those extensions are not part of PHP Markdown Extra, and therefore, not part of Python-Markdown Extra. If you really would like Extra to include additional extensions, we suggest creating your own clone of Extra under a differant name. You could also edit the `extensions` global variable defined below, but be aware that such changes may be lost when you upgrade to any future version of Python-Markdown. )absolute_import)unicode_literals) Extension)BlockProcessor)utilNZ smart_strongZ fenced_codeZ footnotesZ attr_listZdef_listZtablesZabbrc@s"eZdZdZddZdS)ExtraExtensionz* Add various extensions to Markdown class.cCs|jt|j|js~d|jd_|jjjdt |jdd|jj_ t j dt j |jj_ndS) z Register extension instances. T html_blockZmarkdown_block_beginrz*^(p|h[1-6]|li|dd|dt|td|th|legend|address)$N)registerExtensions extensionsconfigsafeMode preprocessorsmarkdown_in_rawparserblockprocessorsaddMarkdownInHtmlProcessor tag_counterrecompile IGNORECASEcontain_span_tags)selfmd md_globalsr&build/lib/markdown/extensions/extra.pyextendMarkdown1s  zExtraExtension.extendMarkdownN)__name__ __module__ __qualname____doc__r!rrrr r .s r cCstdt|S)Nconfigs)r dict)r&rrr makeExtension?sr(c@s@eZdZdZddZddZdddd ZdS) rz$Process Markdown Inside HTML Blocks.cCs$|tjt|jjjdkS)Nr)rTAG_PLACEHOLDERstrrrr)rparentblockrrr testEs zMarkdownInHtmlProcessor.testc Cs2g}|jjjd}xmt|j|kr|j|dr|j|d}|j|d}|j|d|f|d7}qWx`t|ddD]H\}\}}|j||||||||dddqW|j|||dd|d d||d ddddS) z1Process the element's child elements in self.run.r left_index right_indexNrTr r r r )rrrlen _tag_dataappend enumeraterun) relementr,Z nest_indexiZleft_child_indexZright_child_indexr.r/rrr _process_nestsIs))$&z&MarkdownInHtmlProcessor._process_nestsNFc Cs|jjjj|_|jjjd7_|j|jjj}|djd}tj j ||d|d}|r|jj |||dd}n-||dd|d}|d|d=|jjj j |dr|dks|dkrd j||_n|jjjd} t|j| kr|j| dr|j| dd} |jj ||d| |s|j||}qn|jj ||dS) Nrattrsmarkdowntagr.r/r,span )rr9 htmlStashtag_datar1rrpopretree SubElement parseBlocksrmatchjointextr0r7) rr+blockstailZnestr:Zmarkdown_valuer5r,r6Zfirst_subelement_indexrrr r4[s,  & zMarkdownInHtmlProcessor.run)r"r#r$r%r-r7r4rrrr rCs   r)r% __future__rrrrrrrrr r(rrrrr s