mò *á¸Ec@s2dkZdklZdklZdklZdkl Z l Z l Z e e fZ dei fd„ƒYZdei fd„ƒYZd ei fd „ƒYZd ei fd „ƒYZd ei fd„ƒYZdei fd„ƒYZdei fd„ƒYZdei fd„ƒYZdeifd„ƒYZdeifd„ƒYZdei fd„ƒYZdeifd„ƒYZdefd„ƒYZdefd „ƒYZd!efd"„ƒYZd#efd$„ƒYZd%efd&„ƒYZ d'efd(„ƒYZ!d)efd*„ƒYZ"d+fd,„ƒYZ#dS(-N(sstng(sstdom(sletters(s StringTypes UnicodeTypesListTypetStructuredTextExamplecBs)tZdZd„Zd„Zd„ZRS(sCRepresents a section of document with literal text, as for examplescKsVg}|i}x|D]}||iƒƒqWtii|di |ƒf|dS(Ns ( tttappendtatsubstst getNodeValuetSTtStructuredTextParagrapht__init__tselftjointkw(R RR RRR((tB/data/zmath/zope/lib/python/StructuredText/ClassicDocumentClass.pyR s cCsfS(N((R ((R tgetColorizableTextsscCsdS(N((R tsrc((R tsetColorizableTextss(t__name__t __module__t__doc__R RR(((R Rs   tStructuredTextBulletcBstZdZRS(s:Represents a section of a document with a title and a body(RRR(((R R!s tStructuredTextNumberedcBstZdZRS(s:Represents a section of a document with a title and a body(RRR(((R R$s tStructuredTextDescriptionTitlecBstZdZRS(s:Represents a section of a document with a title and a body(RRR(((R R's tStructuredTextDescriptionBodycBstZdZRS(s:Represents a section of a document with a title and a body(RRR(((R R*s tStructuredTextDescriptioncBs2tZdZd„Zd„Zd„Zd„ZRS(s:Represents a section of a document with a title and a bodycKs&tii||||||_dS(N( RRR R RRR ttitlet_title(R RRRR ((R R 0scCs|i|ifS(N(R Rt_src(R ((R R4scCs|\|_|_dS(N(RR RR(R R((R R5scCs"t|iƒt|i|iƒfS(N(RR RRRt_subs(R ((R t getChildren7s(RRRR RRR(((R R-s    tStructuredTextSectionTitlecBstZdZRS(s:Represents a section of a document with a title and a body(RRR(((R R;s tStructuredTextSectioncBs,tZdZed„Zd„Zd„ZRS(s:Represents a section of a document with a title and a bodycKs#tii|t|ƒ||dS(N(RRR R RRRR (R RRR ((R R @scCs |iiƒS(N(R RR(R ((R RDscCs|ii|ƒdS(N(R RRR(R R((R RGs(RRRtNoneR RR(((R R>s   tStructuredTextTablecBsMtZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS(s§ rows is a list of lists containing tuples, which represent the columns/cells in each rows. EX rows = [[('row 1:column1',1)],[('row2:column1',1)]] cKsXtii|||g|_x2|D]*}|o|ii t ||ƒƒq&q&WdS(N( RtStructuredTextDocumentR R RR t_rowstrowstrowRtStructuredTextRow(R R$RRR R%((R R Ss  cCs |igS(N(R R#(R ((R tgetRowsZscCs |iƒS(N(R R'(R ((R t_getRows]scCsPg}xC|iD]8}x/|iƒdD]}|i|iƒdƒq'WqW|S(sµ return a tuple where each item is a column/cell's contents. The tuple, result, will be of this format. ("r1 col1", "r1=col2", "r2 col1", "r2 col2") iN(tresultR R#R%t getColumnstcolumnRR(R R+R)R%((R R`s cCswxptt|iƒƒD]Y}xPtt|i|iƒƒD]2}|i|i|i|dfƒ|d}q9WqWdS(s× texts is going to a tuple where each item is the result of being mapped to the colortext function. Need to insert the results appropriately into the individual columns/cells iiN( trangetlenR R#t row_indext_columnst column_indexRttexts(R R1R.R0((R Ros"cCs |iƒS(N(R R(R ((R t_getColorizableTexts{scCs |iƒS(N(R R(R ((R t_setColorizableTexts~s( RRRR R'R(RRR2R3(((R R!Ks      R&cBs#tZd„Zd„Zd„ZRS(NcCsXtii|g|g|_x2|D]*}|iit |d|d|ƒƒq&WdS(s× row is a list of tuples, where each tuple is the raw text for a cell/column and the span of that cell/column. EX [('this is column one',1), ('this is column two',1)] iiN( RR"R R R R/R%R+RtStructuredTextColumn(R R%R R+((R R „s  cCs |igS(N(R R/(R ((R R*scCs |igS(N(R R/(R ((R t _getColumns“s(RRR R*R5(((R R&‚s R4cBs)tZdZd„Zd„Zd„ZRS(sÑ StructuredTextColumn is a cell/column in a table. This contains the actual text of a column and is thus a StructuredTextParagraph. A StructuredTextColumn also holds the span of its column cCs&tii||g|||_dS(N(RRR R ttextR tspant_span(R R6R7R ((R R ŸscCs|iS(N(R R8(R ((R tgetSpan£scCs|iS(N(R R8(R ((R t_getSpan¦s(RRRR R9R:(((R R4—s   tStructuredTextMarkupcBsAtZd„Zeegƒd„Zd„Zd„Zd„ZRS(NcKsI||_|iƒ|_x*|iƒD]\}}t|||ƒq%WdS(N( tvR t_valueR tkeyst _attributestitemstktsetattr(R R<R RA((R R «s   cCs-|i}||ƒ|j o |g}n|S(N(R R=R<ttypetlt(R RCRDR<((R R°s  cCs |ifS(N(R R=(R ((R RµscCs|d|_dS(Ni(R<R R=(R R<((R R¶scCsd|ii|i fS(Ns%s(%s)(R t __class__RR=(R ((R t__repr__¸s(RRR RCRRRRF(((R R;©s    tStructuredTextLiteralcBstZd„Zd„ZRS(NcCsfS(N((R ((R R¼scCsdS(N((R R<((R R½s(RRRR(((R RG»s tStructuredTextEmphasiscBstZRS(N(RR(((R RH¿stStructuredTextStrongcBstZRS(N(RR(((R RIÁstStructuredTextInnerLinkcBstZRS(N(RR(((R RJÃstStructuredTextNamedLinkcBstZRS(N(RR(((R RKÅstStructuredTextUnderlinecBstZRS(N(RR(((R RLÇstStructuredTextLinkcBstZdZRS(sA simple hyperlink(RRR(((R RMÉs t DocumentClasscBs$tZdZdddddgZdddd d d d d gZd„Zeeegƒd„Ze d„Z eegƒefƒfed„Z e i dƒid„Ze i dƒid„Ze i deƒid„Ze i dƒie i dƒid„Ze i deƒid„Ze i dƒid„Ze i deƒid „Ze i d!ƒie i d"eƒid#„Ze i d$eƒid%„Ze i d&eƒid'„Ze i d(eƒid)„Ze i d*eƒid+„Ze i d,eƒid-„Ze i d.ƒid/„ZRS(0s! Class instance calls [ex.=> x()] require a structured text structure. Doc will then parse each paragraph in the structure and will find the special structures within each paragraph. Each special structure will be stored as an instance. Special structures within another special structure are stored within the 'top' structure EX : '-underline this-' => would be turned into an underline instance. '-underline **this**' would be stored as an underline instance with a strong instance stored in its string t doc_bullett doc_numberedtdoc_descriptiont doc_headert doc_tablet doc_href1t doc_href2t doc_strongt doc_emphasizet doc_literaltdoc_inner_linktdoc_named_linkt doc_underlinecCsdt|ƒtjo/ti|ƒ}|i|i|iƒƒƒnti |i|iƒƒƒ}|S(N( RCtdoct StringTypesRtStructuredTexttsetSubparagraphsR tcolor_paragraphstgetSubparagraphsR"(R R\((R t__call__ìs  c Cs9g}|i} ||ƒ|jot||ƒ}nxº||ƒ} | pPn| \} }}|o| |d|!ƒn|| ƒ} | |jo| ||t |ƒ!}q8| |jo| |t |ƒ)n | | ƒ||t |ƒ!}q8W|p|Sn|o| |ƒn t |ƒdjo |dSn|S(su Parse accepts a raw_string, an expr to test the raw_string, and the raw_string's subparagraphs. Parse will continue to search through raw_string until all instances of expr in raw_string are found. If no instances of expr are found, raw_string is returned. Otherwise a list of substrings and instances is returned iiN(ttmpRRCt text_typetststgetattrR t raw_stringRtstarttendtttR-RD( R RgRdRCReRDRcRiRhRRjR((R tparseös6        cCsn|djo |i}nxM|D]E}t|ƒtjo|i||ƒ}q!t|ƒt jo­g}|i }x‘|D]‰}t|ƒtjoG|i||ƒ}t|ƒt jo||t|ƒ)q||ƒqy|it|i|iƒƒƒ||ƒqyW|}q!g}|i }|i}x.|iƒD] }|||fƒ||ƒq5W|i|ƒq!W|S(s8Search the paragraph for each special structure N(ttypesR R t text_typesRdRCtstrR]RktListTypetrRRRR-Rtmapt color_textRtcolor(R RnRlRRsRdRRp((R Rr&s6   c Cs[g} xN|D]F}|iƒdjo| i|ƒq nxÙ|iD]—}||ƒ|jot ||ƒ}n||ƒ}|oX||ƒ|jo |f}n|}x*|D]"}|i|i|iƒƒƒq°WPqDqDWti|iƒd|i|iƒƒd|iƒf}x:|D]2}|it|i|iƒƒƒ| i|ƒqWq W| S(NRitindent(R)traw_paragraphst paragrapht getNodeNameRR tparagraph_typestptRCReRfRptsequence_typestnew_paragraphsR_R`RaRRRRtRRqRr( R RuRCRzReRpRyR{RvR)((R R`Gs8      s (\s*)([||]+)cCsÞ|iƒd} || ƒ}|pdSng}x$| idƒD]} |i | ƒqAWx¬t t |ƒƒD]˜}g}||iƒ||\?'"]+cCsâ|iƒ}|pdSn|iƒd}|iƒpdSn|ddjoTt|ƒ}|iƒdjo|Snti |d |gd|i d|i ƒSn|i dƒdjodSnt ||d|i d|i ƒS(Niiþÿÿÿs::iÿÿÿÿRttlevels (RvRaRR RR†RRRRRtRŒRŠR(R RvR}RR†((R RRÞs"     sB(?:\s|^)'([^ ']|[^ '][^ ']*[^ '])'(?:\s|[,.;:!?]|$)cCsV||ƒ}|o;|idƒ\}}t|||!ƒ|d|dfSndSdS(Ni(R}RRpR7RhRiRGR (R RR}RiRhRp((R RXðs  &s0\s*\*([ %s0-9.:/;,'"\?\=\-\>\<\(\)]+)\*(?!\*|-)cCsV||ƒ}|o;|idƒ\}}t|||!ƒ|d|dfSndSdS(Ni(R}RRpR7RhRiRHR (R RR}RiRhRp((R RWÿs  &s\.\.\s*s \[[%s0-9]+\]c Csé||ƒo||ƒor||ƒiƒ\}}||ƒiƒ\}}||jodSn&t ||d|dfƒ||fSdSnZ||ƒoL||ƒ o>||ƒiƒ\} }t || d|d!ƒ| |fSndS(Ni( texpr2Rtexpr1R7tstart1tend1tstart2tend2R RJRhRi( R RRŽRRR’RiR‘RRh((R RY s %&s(\.\.\s)(\[[%s0-9]+\])c Csj||ƒ}|oS|idƒ\}}||d|d!}|iƒ\}}t |ƒ||fSndS(Nii( R}RR)R7RhRiRntsttenRKR ( R RR}R”RiR“RhR)Rn((R RZ s s_([%s0-9\s\.,\?\/]+)_cCs`||ƒ}|oE|idƒ\}}|iƒ\}}t|||!ƒ||fSndSdS(Ni( R}RR)R7RhRiR“teRLR (R RR}RiR“RhR)R•((R R[,s  s#\s*\*\*([ %s0-9.:/;\-,!\?'"]+)\*\*cCsV||ƒ}|o;|idƒ\}}t|||!ƒ|d|dfSndSdS(Nii(R}RRpR7RhRiRIR (R RR}RiRhRp((R RV9s  &sS("[ %s0-9 \-\.\,\;\(\)\/\:\/\*']+")(:)([a-zA-Z0-9\@\.\,\?\!\/\:\;\-\#\~]+)([,]*\s*)cCs|i||ƒS(N(R tdoc_hrefRR}(R RR}((R RTGssQ("[ %s0-9 \-\.\:\;\(\)\/\*']+")([,]+\s+)([a-zA-Z0-9\@\.\,\?\!\/\:\;\-\#\~]+)(\s*)cCs|i||ƒS(N(R R–RR}(R RR}((R RULss [\,\.\?\!\;]+c Cs·||ƒ}|oœ|idƒ\}}|||!}|idddƒ}|idƒ\}} ||| d| !ƒo| d} n||| !} t |d| ƒ|| fSndSdS(Nit"R|iithref(R}RRpR7RhR•tnametreplaceR“Rit punctuationtlinkRMR ( R RR}R›R•R™R“RhRpRœRi((R R–Qs   (RRRRxRmRbRCR]RkR RrR`tretcompiletmatchRSROtlettersRPtsearchRQRRRXRWRYRZR[RVRTRUR–(((R RNÌs*  0 !$&/' +  ($Rtzope.structuredtexttstngRtstdomtSTDOMtzope.structuredtext.stlettersR Rlt StringTypet UnicodeTypeRoR]RRRRRRRRRR"R!R&R4tElementR;RGRHRIRJRKRLRMRN(RR RRRKR¥R§RRNRHRR4R]RIRLRJR;RoR!RGRRR&R¨RRRRM((R t?s2       7