mò *á¸Ec@sødZdkZeideddƒdkZdkZdkZeidƒid„Z dd„Z ddd „Z eid ƒid „Z d „Z d „Zdfd„ƒYZeƒZdfd„ƒYZdZdZdZdZeieed+deƒeieed,deƒeieed-deƒeieed.deƒd„Zdefd„ƒYZeidƒdfeid ƒd!feid"ƒd#feid$ƒd%ffd&„Zd'd(„Zd)„Zed*jo eƒndS(/s®Structured Text Manipulation Parse a structured text string into a form that can be used with structured formats, like html. Structured text is text that uses indentation and simple symbology to indicate the structure of a document. A structured string consists of a sequence of paragraphs separated by one or more blank lines. Each paragraph has a level which is defined as the minimum indentation of the paragraph. A paragraph is a sub-paragraph of another paragraph if the other paragraph is the last preceding paragraph that has a lower level. Special symbology is used to indicate special constructs: - A single-line paragraph whose immediately succeeding paragraphs are lower level is treated as a header. - A paragraph that begins with a '-', '*', or 'o' is treated as an unordered list (bullet) element. - A paragraph that begins with a sequence of digits followed by a white-space character is treated as an ordered list element. - A paragraph that begins with a sequence of sequences, where each sequence is a sequence of digits or a sequence of letters followed by a period, is treated as an ordered list element. - A paragraph with a first line that contains some text, followed by some white-space and '--' is treated as a descriptive list element. The leading text is treated as the element title. - Sub-paragraphs of a paragraph that ends in the word 'example' or the word 'examples', or '::' is treated as example code and is output as is. - Text enclosed single quotes (with white-space to the left of the first quote and whitespace or punctuation to the right of the second quote) is treated as example code. - Text surrounded by '*' characters (with white-space to the left of the first '*' and whitespace or punctuation to the right of the second '*') is emphasized. - Text surrounded by '**' characters (with white-space to the left of the first '**' and whitespace or punctuation to the right of the second '**') is made strong. - Text surrounded by '_' underscore characters (with whitespace to the left and whitespace or punctuation to the right) is made underlined. - Text encloded by double quotes followed by a colon, a URL, and concluded by punctuation plus white space, *or* just white space, is treated as a hyper link. For example: "Zope":http://www.zope.org/ is ... Is interpreted as 'Zope is ....' Note: This works for relative as well as absolute URLs. - Text enclosed by double quotes followed by a comma, one or more spaces, an absolute URL and concluded by punctuation plus white space, or just white space, is treated as a hyper link. For example: "mail me", mailto:amos@digicool.com. Is interpreted as 'mail me.' - Text enclosed in brackets which consists only of letters, digits, underscores and dashes is treated as hyper links within the document. For example: As demonstrated by Smith [12] this technique is quite effective. Is interpreted as '... by Smith [12] this ...'. Together with the next rule this allows easy coding of references or end notes. - Text enclosed in brackets which is preceded by the start of a line, two periods and a space is treated as a named link. For example: .. [12] "Effective Techniques" Smith, Joe ... Is interpreted as '[12] "Effective Techniques" ...'. Together with the previous rule this allows easy coding of references or end notes. - A paragraph that has blocks of text enclosed in '||' is treated as a table. The text blocks correspond to table cells and table rows are denoted by newlines. By default the cells are center aligned. A cell can span more than one column by preceding a block of text with an equivalent number of cell separators '||'. Newlines and '|' cannot be a part of the cell text. For example: |||| **Ingredients** || || *Name* || *Amount* || ||Spam||10|| ||Eggs||3|| is interpreted as::
Ingredients
Name Amount
Spam 10
Eggs 3
NskThe StructuredText package is deprecated and will be removed in Zope 2.12. Use zope.structuredtext instead.t stacklevelis\( \|^\)\( *\) c Cs¤d}|}x‘||d ƒ}|on|\}}t|dƒ}t|dƒ}||| }dd|ddd|||d|f}q||SqWdS( s, Convert indentation tabs to spaces. tiiis %s%st iN(ii( tresulttaStringtrestt indent_tabt ts_resultststarttgrpstlentlnltindent( RRR RR RRRR ((tC/data/zmath/zope/lib/python/StructuredText/ClassicStructuredText.pytuntabify’s 4cCs_t|ƒidƒ}|pdSn|dp |d=nd|}d|d|i|ƒfS(s*Indent a string the given number of spacess RiÿÿÿÿRs%s%s N(RRtsplittrR ttabtjoin(RR RR((R R ¦s  icCsÑ|pt|ƒ}nt|ƒd}||jo|Sng}|i}||jo:d||}x[|i dƒD]}|||ƒqvWn3||}x%|i dƒD]}|||ƒq¬Wdi |ƒS(s@reindent a block of text, so that the minimum indent is as giveniRs N( talready_untabifiedRRt indent_leveltlR RtappendRRtsR(RR RRRRRR((R treindent®s$    s \( *\)c CsËd}d|}t|ƒ}}x¤||d|ƒ}|o||\}}t|dƒ}||d}||joA||djo0|pd|fSn||jo |}q´qÂq#||fSq#WdS(sM Find the minimum indentation for a string, not counting blank lines. is iiN(ii( RRttextR R Rt indent_spaceRR ti( RRR RRRRRR ((R RÃs"   cCsdt|ƒ}||d}|d}x1||jo#||d|jo|d}q'W|d|S(Nii(R tlistRRtlevelR(RRRRR((R t paragraphsÙs  "cCs“|pgSnd}t|ƒ}g}xe||joWt||ƒ}|d}|i||ddt||||!ƒfƒ||}q*W|S(Nii( RRR RRRtsublenRt structure(RRRRR((R R às   0tTablecBs8tZdZdZdZeidƒd„Zd„ZRS(Ns* %s s %s s. %s
s[ \t\n]*\|\|([^\0|]*)cCs¹g|_td|idƒƒ}x‘|D]‰}g}xj|i |ƒ}|pdSn|i dƒ}|i|idƒƒ|t|ƒjoPn||}q7W|ii|ƒq(WdS(sEparses a table and returns nested list representing the tables iiN(tselfttabletfiltertNonetaParRRtlinetrowttd_regtmatchtmotendtposRtgroupR (R"R&R)RR-R'R+R(((R tcreateñs$ cCs¦g}x‰|iD]~}g}d}xL|D]D}|djo|d}q)q)|i|i||fƒd}q)W|i|i di |ƒƒqW|i di |ƒS(s'Creates an HTML representation of tableiRN( t htmltableR"R#R(thtmlrowtcolspantcellRtCELLtROWRtTABLE(R"R2R1R3R0R(((R thtmls    !( t__name__t __module__R4R5R6tretcompileR/R7(((R R!ís tStructuredTextcBs/tZdZdeidƒd„Zd„ZRS(sÄModel text as structured collection of paragraphs. Structure is implied by the indentation level. This class is intended as a base classes that do actual text output formatting. is \( ? *\)+ ? cCsþdtidtid}ti|tiƒ}|id|ƒ}dtidtid}ti|tiƒ}|id|ƒ}|i dƒ}|djotidd|ƒ}n||_ t it|ƒ|ƒ}tt|ƒ}t|ƒ|_d S( sÖConvert a structured text string into a structured text object. Aguments: aStructuredString -- The string to be parsed. level -- The level of top level headings to be created. s "([%s0-9-_,./?=@~&]*)":s([-:%s0-9_,./?=@#~&]*?)s ([.:?;] )s\1\3 s "([%s0-9-_,./?=@~&]*)", s \2\3s \1\2\3s\1\2\3s\1\2\3(RR%tstrongRBtundertcodetem(RRRRORPRQ((R tctagSs tHTMLcBsçtZdZeidƒeidƒeidƒd„Zd„Zd„Zd„Zd„Z d „Z d d „Z d „Z e id ƒie idƒie idƒie idƒie ideiƒie idƒid„ZRS(s+ An HTML structured text formatter. s
s