3 \@sdZddlmZddlmZddlmZddlmZddlmZdd l Z d d d d dddgZ GdddeZ ifddZ 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@seZdZdZddZdS)ExtraExtensionz* Add various extensions to Markdown class.cCsZ|jt|j|jsVd|jd_|jjjdt |jdd|jj_ t j dt j |jj_dS) 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 .sr cCstt|dS)N)configs)r dict)r&rrr makeExtension?sr(c@s*eZdZdZddZddZd dd ZdS) rz$Process Markdown Inside HTML Blocks.cCs|tjt|jjjdkS)Nr)rTAG_PLACEHOLDERstrrrr)rparentblockrrr testEszMarkdownInHtmlProcessor.testc Csg}|jjjd}xVt|j|krh|j|drh|j|d}|j|d}|j|d|f|d7}qWxLt|ddD]8\}\}}|j||||||||dddq|W|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 CsH|jjjj|_|jjjd7_|j|jjj}|djd}tj j ||d|d}|rv|jj |||dd}n&||dd|d}|d|d=|jjj j |dr|dks|dkrd j||_nv|jjjd} t|j| ko|j| dr6|j| dd} |jj ||d| |sD|j||}n|jj ||dS) Nrattrsmarkdowntagr.r/r,span )rr9 htmlStashtag_datar1rrpopretree SubElement parseBlocksrmatchjointextr0r7) rr+blockstailZnestr:Zmarkdown_valuer5r,r6Zfirst_subelement_indexrrr r4[s, zMarkdownInHtmlProcessor.run)NF)r"r#r$r%r-r7r4rrrr rCsr)r% __future__rrrrrrrrr r(rrrrr s