ó Šç\c@@sždZddlmZddlmZddlmZddlmZddlm Z dd l Z d efd „ƒYZ d efd „ƒYZ id„Z d S(uŸ Admonition extension for Python-Markdown ======================================== Adds rST-style admonitions. Inspired by [rST][] feature with the same name. The syntax is (followed by an indented block with the contents): !!! [type] [optional explicit title] Where `type` is used as a CSS class name of the div. If not present, `title` defaults to the capitalized `type`, so "note" -> "Note". rST suggests the following `types`, but you're free to use whatever you want: attention, caution, danger, error, hint, important, note, tip, warning A simple example: !!! note This is the first line inside the box. Outputs:

Note

This is the first line inside the box

You can also specify the title and CSS class of the admonition: !!! custom "Did you know?" Another line here. Outputs:

Did you know?

Another line here.

[rST]: http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions By [Tiago Serafim](http://www.tiagoserafim.com/). i(tabsolute_import(tunicode_literalsi(t Extensioni(tBlockProcessor(tetreeNtAdmonitionExtensioncB@seZdZd„ZRS(u+ Admonition extension for Python-Markdown. cC@s3|j|ƒ|jjjdt|jƒdƒdS(u& Add Admonition to Markdown instance. u admonitionu_beginN(tregisterExtensiontparsertblockprocessorstaddtAdmonitionProcessor(tselftmdt md_globals((sB/usr/lib/python2.7/site-packages/markdown/extensions/admonition.pytextendMarkdown6s  (t__name__t __module__t__doc__R(((sB/usr/lib/python2.7/site-packages/markdown/extensions/admonition.pyR3sR cB@s>eZdZdZejdƒZd„Zd„Zd„Z RS(u admonitionuadmonition-titleu%(?:^|\n)!!!\ ?([\w\-]+)(?:\ "(.*?)")?cC@s_|j|ƒ}|jj|ƒp^|jd|jƒo^|o^|jddƒj|jƒdkS(Nu uclassui˙˙˙˙(t lastChildtREtsearcht startswitht tab_lengthtgettfindt CLASSNAME(R tparenttblocktsibling((sB/usr/lib/python2.7/site-packages/markdown/extensions/admonition.pyttestEsc C@s|j|ƒ}|jdƒ}|jj|ƒ}|rM||jƒd}n|j|ƒ\}}|rĉ|j|ƒ\}}tj|dƒ} | j dd|j |fƒ|rìtj| dƒ} || _ | j d|j ƒqìn|} |j j| |ƒ|r|jd|ƒndS(Niiudivuclassu%s %sup(RtpopRRtendtdetabtget_class_and_titleRt SubElementtsetRttexttCLASSNAME_TITLERt parseChunktinsert( R RtblocksRRtmttheResttklassttitletdivtp((sB/usr/lib/python2.7/site-packages/markdown/extensions/admonition.pytrunKs$ cC@s_|jdƒjƒ|jdƒ}}|dkr@|jƒ}n|dkrUd}n||fS(Niiu(tgrouptlowertNonet capitalize(R tmatchR+R,((sB/usr/lib/python2.7/site-packages/markdown/extensions/admonition.pyR!hs %   ( RRRR%tretcompileRRR/R!(((sB/usr/lib/python2.7/site-packages/markdown/extensions/admonition.pyR ?s   cC@s td|ƒS(Ntconfigs(R(R7((sB/usr/lib/python2.7/site-packages/markdown/extensions/admonition.pyt makeExtensionus(Rt __future__RRtRRRtutilRR5RR R8(((sB/usr/lib/python2.7/site-packages/markdown/extensions/admonition.pyt)s  6