Ñò éíÑXc@sdZddkZddkZddd„ƒYZdefd„ƒYZdefd„ƒYZd efd „ƒYZd efd „ƒYZd efd„ƒYZdefd„ƒYZ defd„ƒYZ defd„ƒYZ defd„ƒYZ defd„ƒYZ dS(sð CORE MARKDOWN BLOCKPARSER ============================================================================= This parser handles basic parsing of Markdown blocks. It doesn't concern itself with inline elements such as **bold** or *italics*, but rather just catches blocks, lists, quotes, etc. The BlockParser is made up of a bunch of BlockProssors, each handling a different type of block. Extensions may add/replace/remove BlockProcessors as they need to alter how markdown blocks are parsed. iÿÿÿÿNtBlockProcessorcBsJeZdZdd„Zd„Zd„Zdd„Zd„Zd„Z RS( s  Base class for block processors. Each subclass will provide the methods below to work with the source and tree. Each processor will need to define it's own ``test`` and ``run`` methods. The ``test`` method should return True or False, to indicate whether the current block should be processed by this processor. If the test passes, the parser will call the processors ``run`` method. cCs ||_dS(N(tparser(tselfR((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyt__init__scCst|ƒo |dSdSdS(s, Return the last child of an etree element. iÿÿÿÿN(tlentNone(Rtparent((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyt lastChild s  cCsšg}|idƒ}x\|D]T}|idtiƒo|i|tiƒq|iƒp|idƒqPqWdi|ƒdi|t|ƒƒfS(s= Remove a tab from the front of each line of the given text. s t t(tsplitt startswithtmarkdownt TAB_LENGTHtappendtstriptjoinR(Rttexttnewtexttlinestline((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pytdetab's icCsu|idƒ}xVtt|ƒƒD]B}||idti|ƒo||ti|||ºs tBlockQuoteProcessorcBs2eZeidƒZd„Zd„Zd„ZRS(s(^|\n)[ ]{0,3}>[ ]?(.*)cCst|ii|ƒƒS(N(tbooltREtsearch(RRR((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyRÝsc Csô|idƒ}|ii|ƒ}|op||iƒ }|ii||gƒdig}||iƒidƒD]}||i|ƒqr~ƒ}n|i |ƒ}|o|i djo |} nt i i |dƒ} |ii| |ƒdS(Nis t blockquote(R+RGRHtstartRR.RR tcleanRR(R R3R4R/( RRRRR9tbeforet_[1]RR2tquote((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyRàs = cCsG|ii|ƒ}|iƒdjodS|o|idƒS|SdS(s( Remove ``>`` from beginning of a line. t>R iN(RGR7RR8(RRR9((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyRKôs (RRR<R=RGRRRK(((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyREÙs  tOListProcessorcBs\eZdZdZeidƒZeidƒZeidƒZd„Z d„Z d„Z RS(s Process ordered list blocks. R$s^[ ]{0,3}\d+\.[ ](.*)s^[ ]{0,3}((\d+\.)|[*+-])[ ](.*)s^[ ]{4,7}((\d+\.)|[*+-])[ ].*cCst|ii|ƒƒS(N(RFRGR7(RRR((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyR sc Cs¼|i|idƒƒ}|i|ƒ}|oÞ|id joÎ|}t|ƒoZ|dioLt|dƒ o:tii|ddƒ}|di|_d|d_ntii|dƒ}|i i i dƒ|idƒ}|i i ||gƒ|i i i ƒntii||iƒ}|i i i d ƒxn|D]f} | id tiƒo|i i |d| gƒq>tii|dƒ}|i i || gƒq>W|i i i ƒdS( NiR$R#iÿÿÿÿtpR R"t looselistR5R(solsul(t get_itemsR+RR(RRR R3R4RR&R-R.R1tTAGR R ( RRRtitemsR2tlstRQR"t firstitemtitem((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyR s,-cCsÊg}x½|idƒD]¬}|ii|ƒ}|o|i|idƒƒq|ii|ƒoH|didtiƒod|d|f|d#{1,6})(?P
.*?)#*(\n|$)cCst|ii|ƒƒS(N(RFRGRH(RRR((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyRPscCsÙ|idƒ}|ii|ƒ}|o ||iƒ }||iƒ}|o|ii||gƒntii |dt |i dƒƒƒ}|i dƒi ƒ|_ |o|id|ƒqÕnttdƒdS(Nish%dRtheadersWe've got a problem header!(R+RGRHRJtendRR.R R3R4RR8RRRCtmessagetCRITICAL(RRRRR9RLtafterth((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyRSs((RRR R<R=RGRR(((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyR[Js tSetextHeaderProcessorcBs5eZdZeideiƒZd„Zd„ZRS(s Process Setext-style Headers. s^.*?\n[=-]{3,}cCst|ii|ƒƒS(N(RFRGR7(RRR((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyRoscCs |idƒidƒ}|didƒo d}nd}tii|d|ƒ}|diƒ|_t|ƒdjo!|i ddi |dƒƒndS(Nis it=ish%d( R+R R R R3R4RRRRCR(RRRRRRa((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyRrs ( RRR R<R=t MULTILINERGRR(((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyRbis t HRProcessorcBsLeZdZdZeideƒZeideƒZd„Zd„Z RS(s Process Horizontal Rules. s.[ ]{0,3}(?P[*_-])[ ]?((?P=ch)[ ]?){2,}[ ]*s(^|\n)%s(\n|$)s^%s$cCst|ii|ƒƒS(N(RFt SEARCH_RERH(RRR((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyR‰scCsá|idƒidƒ}g}x9|D]1}|ii|ƒ}|oPq%|i|ƒq%Wt|ƒo#|ii|di|ƒgƒnt i i |dƒ}|t|ƒd}t|ƒo|i ddi|ƒƒndS(Nis thri( R+R tMATCH_RER7RRRR.RR R3R4RC(RRRRtprelinesRR9Rg((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyRŒs # ( RRR RGR<R=RfRhRR(((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyRe€s  tEmptyBlockProcessorcBs/eZdZeidƒZd„Zd„ZRS(s. Process blocks and start with an empty line. s^\s*\ncCst|ii|ƒƒS(N(RFRGR7(RRR((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyR©scCs´|idƒ}|ii|ƒ}|oˆ|id||iƒƒ|i|ƒ}|oT|idjoD|do9|didjo%tid|di ƒ|d_ q°ndS(NiR?R@s%s/n/n/n( R+RGR7RCR]RR(R RAR(RRRRR9R2((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyR¬s"(RRR R<R=RGRR(((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyRj¢s tParagraphProcessorcBs eZdZd„Zd„ZRS(s Process Paragraph blocks. cCstS(N(tTrue(RRR((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyR¼scCs•|idƒ}|iƒou|iiidƒo7|iod|i|f|_q|iƒ|_q‘tii |dƒ}|iƒ|_ndS(NiR5s%s %sRQ( R+RRR&R'RtlstripR R3R4(RRRRRQ((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyR¿s  (RRR RR(((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyRk¹s ((R R<R RR!R>RERPRZR[RbReRjRk(((s</usr/lib/python2.6/site-packages/markdown/blockprocessors.pyt s  WQ%E"