Qc@sWdZddlZddlZddlZddlmZddlZdZdZdZ dZ dZ ej d Z d Zd Zej d Zej d Zej dZej dZej dZdZdZdZdZdZej dZdZdZdZdZdZdZ ej ddej!Z"dZ#i ed d!6ed"d#6ed$d%6ed&d'6ed(d)6ed*d+6ed,d-6ed.d/6ed0d16Z$d2Z%d3Z&d4Z'd5dd6Z)d7Z*d8d5dd9d:Z+d;Z,d<Z-d5e.d=Z/dS(>ssimplified reStructuredText parser. This parser knows just enough about reStructuredText to parse the Mercurial docstrings. It cheats in a major way: nested blocks are not really nested. They are just indented blocks that look like they are nested. This relies on the user to keep the right indentation for the blocks. Remember to update http://mercurial.selenic.com/wiki/HelpStyleGuide when adding support for new constructs. iN(t_cCsd|dtj|fS(Ns%s %s s"(tencodingtcolwidth(ts((s5/sys/lib/python2.7/site-packages/mercurial/minirst.pytsectionscCsd|dtj|fS(Ns%s %s t=(RR(R((s5/sys/lib/python2.7/site-packages/mercurial/minirst.pyt subsectionscCsd|dtj|fS(Ns%s %s t-(RR(R((s5/sys/lib/python2.7/site-packages/mercurial/minirst.pyt subsubsection!scCsd|dtj|fS(Ns%s %s t.(RR(R((s5/sys/lib/python2.7/site-packages/mercurial/minirst.pytsubsubsubsection$scCsK|jtj}x&|D]\}}|j||}qW|jtjS(s5 Apply a list of (find, replace) pairs to a text. >>> replace("foo bar", [('f', 'F'), ('b', 'B')]) 'Foo Bar' >>> encoding.encoding = 'latin1' >>> replace('\x81\\', [('\\', '/')]) '\x81/' >>> encoding.encoding = 'shiftjis' >>> replace('\x81\\', [('\\', '/')]) '\x81\\' (tdecodeRtreplacetencode(ttexttsubststutexttftt((s5/sys/lib/python2.7/site-packages/mercurial/minirst.pyR 'ss \n(?:\s*\n)+cCsg}xtj|jdjD]j}|j}|r%td|D}g|D]}||^qZ}|jtd|d|q%q%W|S(sFind continuous blocks of lines in text. Returns a list of dictionaries representing the blocks. Each block has an 'indent' field and a 'lines' field. s css+|]!}t|t|jVqdS(N(tlentlstrip(t.0tl((s5/sys/lib/python2.7/site-packages/mercurial/minirst.pys Jstindenttlines(t_blockretsplitRtrstript splitlinestmintappendtdict(RtblockstbRRR((s5/sys/lib/python2.7/site-packages/mercurial/minirst.pyt findblocks@s% #cCsd}x|t|krd||d<||ddjdr|dt|kr||d}||dd|}||ddgkr||=|d8}nb||ddjd r||ddd ||ddRtgetcolsRRK( R RTtdivtxtcolumnstrowsRtrowtpostntstarttwidthtv((s5/sys/lib/python2.7/site-packages/mercurial/minirst.pyt findtabless6   <   cCsx|D]}|ddkrt|ddkrtj|ddt|ddkrtj|ddr|ddd|d (R(Rgtlevel(tlistnesttout(s5/sys/lib/python2.7/site-packages/mercurial/minirst.pytopenlistsR$RrRRRwRxR3s

%s %s

R#s

%s

s R%s
%s
RRkis%s iR[s sss s
s
R1tdls
%s
%s R.Rtultols
  • %s R0RDR/RHis sdefinition bullet field option( R>RRRRRKRtindextpopRR(R t headernestRRR!RetbtypeRRRwRR*R[RdRiRR.theadRDRSRPRgtnbtni((RRs5/sys/lib/python2.7/site-packages/mercurial/minirst.pyt formathtml s )    ! #  #    '           %   .  !  !    icCsg}t|}x|D]}|dc|7zs(R(R RhR((Rhs5/sys/lib/python2.7/site-packages/mercurial/minirst.pyt formatblocksysiPtplaincsvt|||pg\}}|dkr9t|}ndjfd|D}|dkrh|S||fSdS(s-Parse and format the text according to width.thtmlR2c3s|]}t|VqdS(N(R(RR!(Rh(s5/sys/lib/python2.7/site-packages/mercurial/minirst.pys sN(RRRtNone(RRhRRVtstyleR RW((Rhs5/sys/lib/python2.7/site-packages/mercurial/minirst.pytformat}s  cCsd}d}g}x|D]}|ddkr|d}||krR||7}n|j|d}|| }|j|dd||gfq|sddgfg}n|dd j|qW|S( s=return a list of (section name, nesting level, blocks) tuplesR2iR$RRkiRii(RR(R tnestRtsecsR!R*((s5/sys/lib/python2.7/site-packages/mercurial/minirst.pyt getsectionss     $cCsmg}x`t|D]R}|d}t|d|}|jg|jtD]}||f^qLqW|S(s=generate a list of (section name, line text) pairs for searchii(RRRRR:(R RhRRRRR((s5/sys/lib/python2.7/site-packages/mercurial/minirst.pytdecorateblockss  3c Csgt|D]}td|D^q }d|}|djd|Dd}|g}xz|D]r}g}xEt||D]4\} } d| tj| } |j| | qW|j|dj|dqjW|r t|dkr |jd|n|j||S(sAGenerate an RST table for the given table data as a list of linescss|]}tj|VqdS(N(RR(RR((s5/sys/lib/python2.7/site-packages/mercurial/minirst.pys sR3css|]}d|VqdS(RN((RR((s5/sys/lib/python2.7/site-packages/mercurial/minirst.pys ss ii(RRLRRRRRRs( tdataRR\RRR`RRdRRRiR((s5/sys/lib/python2.7/site-packages/mercurial/minirst.pyt maketables/ !  " (0t__doc__treRRti18nRRRRRR R tcompileRR"R-R'R;R<R=R]RCRRGRURZRlRjRmRoRqRtRut IGNORECASERyR|RRRRRRRRRRR4R(((s5/sys/lib/python2.7/site-packages/mercurial/minirst.pytsd         3 *  $ & 2               O [