U å€C^}ã@sòdZdZddlZddlZddlmZmZddlmZm Z m Z ddlm Z m Z ddl mZmZddlmZdd lmZddlZdd lmZmZmZmZdd lmZdd lmZmZmZdd lm Z m!Z!m"Z"ddlm#Z#Gdd„de ƒZ$Gdd„de ƒZ%Gdd„de ƒZ&Gdd„de ƒZ'Gdd„de(ƒZ)Gdd„dƒZ*Gdd„deƒZ+Gdd„deƒZ,Gdd „d eƒZ-dSd"d#„Z.Gd$d%„d%ƒZ/e0d&ƒd'fd(d)„Z1e0d*ƒd'fd+d,„Z2d-d.„Z3Gd/d0„d0e-ƒZ4Gd1d2„d2e4ƒZ5Gd3d4„d4e4ƒZ6Gd5d6„d6e6ƒZ7Gd7d8„d8e6ƒZ8Gd9d:„d:e6ƒZ9Gd;d<„d„d>e6ƒZ;Gd?d@„d@e6e5ƒZGdEdF„dFe6ƒZ?GdGdH„dHe4ƒZ@GdIdJ„dJe-ƒZAGdKdL„dLeAƒZBGdMdN„dNeBƒZCGdOdP„dPeBƒZDGdQdR„dRe-ƒZEe4e7e8e9e:e;e>e=e?eAeCeDe@e5er?r8r;r5r@rrrr<·szNestedStateMachine.runN)TrArrrrrB°srBc@s˜eZdZdZeZgZd dd„Zdd„Zdd„Z d d „Z d d „Z d!dd„Z d idd d fdd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zd S)"ÚRSTStatez` reStructuredText State superclass. Contains methods used by all State subclasses. FcCstddœ|_t |||¡dS)NÚBody©Ú state_classesÚ initial_state)rFÚnested_sm_kwargsr r)©r(Ú state_machineÚdebugrrrr)ÕsÿzRSTState.__init__cCsVt |¡|jj}||_|j|_|j|_|j|_|jj|_t |jdƒsR|jj |j_ dS)NÚget_source_and_line) r Ú runtime_initrJr8r-r2r,r;ÚparentÚhasattrrL)r(r8rrrrMÚs   zRSTState.runtime_initcCs*z|j |¡Wntk r$YnXdS)zT Jump to input line `abs_line_offset`, ignoring jumps past the end. N)rJÚ goto_lineÚEOFError)r(Úabs_line_offsetrrrrPçszRSTState.goto_linecCs*|j d|jj|||jjf¡|dgfS)zs Override `StateWS.no_match` to generate a system message. This code should never be run. zjInternal error: no transition pattern match. State: "%s"; transitions: %s; context: %s; current line: %r.N)r-ÚsevereÚ __class__rrJÚline)r(ÚcontextÚ transitionsrrrÚno_matchðs ÿþÿzRSTState.no_matchcCsggfS)zCalled at beginning of file.r©r(rVrrrÚbofýsz RSTState.bofNc Csêd}|dkr|j}|d7}|dkr0|j}|d7}t|ƒ}d} |dkrhz|j ¡} Wntk rfYnX| s€|fd|ji|—Ž} | j|||j||d|dkr¬|j  | ¡n|   ¡|   ¡} |j ræt|ƒ|dkræ|j  t|ƒ|¡| S)zg Create a new StateMachine rooted at `node` and run it over the input `block`. rNéérK©r8r;r5)Ú nested_smrHÚlenÚnested_sm_cacheÚpopÚ IndexErrorrKr<r8ÚappendÚunlinkrRrNrJÚ next_line) r(Úblockr?r;r5Ústate_machine_classÚstate_machine_kwargsZ use_defaultZ block_lengthrJZ new_offsetrrrÚ nested_parses: ÿ ÿzRSTState.nested_parsec Cs²| dkr|j} | dkr |j ¡} || d<| fd|ji| —Ž} |dkrH|}|| j|_t| ¡ƒD]\} } t| j|| | ƒq`| j |||j ||d| j|j}|   ¡|   ¡|fS)zÀ Create a new StateMachine rooted at `node` and run it over the input `block`. Also keep track of optional intermediate blank lines and the required final one. NrGrKr]) r^rHÚcopyrKZstatesÚ blank_finishÚlistÚitemsÚsetattrr<r8rdrR)r(rfr?r;rGrkÚblank_finish_stateÚextra_settingsr5rgrhrJÚkeyÚvaluerrrÚnested_list_parse&s(   ÿ  ÿ zRSTState.nested_list_parsecCs | |||¡r| |||¡dS)z=Check for a valid subsection and create one if it checks out.N)Úcheck_subsectionÚnew_subsection)r(Útitler3ÚstyleÚlinenoÚmessagesrrrÚsectionDszRSTState.sectionc CsÚ|j}|j}|j}z| |¡d}WnNtk rrt|ƒ|jkrR| |¡YdS|j| ||¡7_YdSYnX||kr¬||_t|ƒdkr”d|_ |j   t|ƒd¡t ‚||dkr¼dS|j| ||¡7_dSdS)aÙ Check for a valid subsection header. Return 1 (true) or None (false). When a new section is reached that isn't a subsection of the current section, back up the line count (use ``previous_line(-x)``), then ``raise EOFError``. The current StateMachine will finish, then the calling StateMachine can re-examine the title. This will work its way back up the calling chain until the correct section level isreached. @@@ Alternative: Evaluate the title, store the title info & level, and back up the chain until that level is reached. Store in memo? Or return in results? :Exception: `EOFError` when a sibling or supersection encountered. r[Nr\T) r8r/r0ÚindexÚ ValueErrorr_rcrNÚtitle_inconsistentr1rJÚ previous_linerQ)r(r3rwrxr8r/ÚmylevelÚlevelrrrrtIs*    zRSTState.check_subsectioncCs|jjdt d|¡|d}|S)NzTitle level inconsistent:Ú©rU)r-rSrÚ literal_block)r(Z sourcetextrxÚerrorrrrr}rs  þzRSTState.title_inconsistentcCsì|j}|j}|jd7_t ¡}|j|7_| ||¡\}}tj|df|žŽ} t|  ¡ƒ} |d  | ¡|| 7}||7}||7}|j   ||¡|j j d} |j  ¡d} |j|j j| d…| |dd} | | ¡|j|krât‚||_dS)z?Append new subsection to document tree. On return, check level.r[rÚnamesNT)r?r;r5)r8r0rrzrNÚ inline_textrvÚnormalize_nameÚastextrcr,Znote_implicit_targetrJÚ line_offsetrRrir>rPrQ)r(rvrxryr8rZ section_nodeÚ textnodesZtitle_messagesZ titlenodeÚnameÚoffsetZ absoffsetZ newabsoffsetrrrruxs2  þ  zRSTState.new_subsectionc Csªd |¡ ¡}t d|¡r^t|ƒdkr.gdfS|ddkrL|dd… ¡}n |dd…}d}n|}d }| ||¡\}}tj|d f|žŽ}|j  |¡\|_ |_ |g||fS) zW Return a list (paragraph & messages) & a boolean: literal_block next? Ú z(?%(or_group)s)%(suffix)s) ÚtypeÚtuplercÚ build_regexprÚlocalsr’ÚcompileÚUNICODE) Ú definitionr£r‹ÚprefixÚsuffixÚpartsÚ part_stringsÚpartZor_groupÚregexprrrr¡·s     r¡c @seZdZdZdd„Zdd„Zdd„ZdZd Zd Z d Z d Z d Z dZ dZdeƒZdZdZdd„Zd=dd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd>d.d/„Z d0d1„Z!d2d3„Z"d4d5„Z#d6Z$d7d8„Z%d9d:„Z&eeeeeeee e!d;œ Z'd%s)(?P__?)Ú footnotelabelz\[z(?P\]_)ú[0-9]+z\#(%s)?z\*z(?P%s)Ú backquotez(?P(:%s:)?)z`(?!`)z(\*)z(\*\*)a %(non_unescaped_whitespace_escape_before)s ( ` (?P (?P:%(simplename)s:)? (?P__?)? ) ) %(end_string_suffix)s aÍ ( (?:[ \n]+|^) # spaces or beginning of line/string < # open bracket %(non_whitespace_after)s (([^<>]|\x00[<>])+) # anything but unescaped angle brackets %(non_whitespace_escape_before)s > # close bracket ) $ # end of string z(``)z(`)z (\|_{0,2})ú$a5 %(start_string_prefix)s (?P (?P # absolute URI (?P # scheme (http, ftp, mailto) [a-zA-Z][a-zA-Z0-9.+-]* ) : ( ( # either: (//?)? # hierarchical URI %(uric)s* # URI characters %(uri_end)s # final URI char ) ( # optional query \?%(uric)s* %(uri_end)s )? ( # optional fragment \#%(uric)s* %(uri_end)s )? ) ) | # *OR* (?P # email address z] ) ) %(end_string_suffix)s a %(start_string_prefix)s ( (pep-(?P\d+)(.txt)?) # reference to source file | (PEP\s+(?P\d+)) # reference by name ) %(end_string_suffix)sz{ %(start_string_prefix)s (RFC(-|\s+)?(?P\d+)) %(end_string_suffix)s) ÚinitialÚemphasisÚstrongÚinterpreted_or_phrase_refÚ embedded_linkÚliteralÚtargetÚsubstitution_refÚemailÚuriÚpepÚrfc)$ÚgetattrrZopenersÚ delimitersZclosing_delimitersZclosersr¢rjr'ÚvarsrTÚnon_whitespace_afterÚ simplenameÚstart_string_prefixÚend_string_suffixr¨r$r¡r’r£Únon_whitespace_escape_beforer¤ÚVERBOSEÚnon_whitespace_beforeÚ email_patternÚpatternsr¬rcr¾Ústandalone_uriZpep_referencesr¿Ú pep_referenceZrfc_referencesrÀÚ rfc_reference)r(r4rÆrÇÚargsr¨rrrr7Ùs ÿÿþÿ üÿýÿþÿ ýîÿÿÿÿÿÿÿ ö õ  ö õ ÿÿÿÿÿÿþþ ÿææâ á ù ø ý ü°V ÿ ÿ ÿzInliner.init_customizationscCsú|j|_|j|_|j|_||_|jjj}|j}t|ƒ}g}g} g} |rÐ||ƒ} | rÐ|   ¡} || dpz| dpz| dpz| d} | || |ƒ\}}}}|   |¡| |7} |rÎ||  d  | ¡|¡7}||7}g} qBqÐqBd  | ¡|}|rò||  ||¡7}|| fS)aÓ Return 2 lists: nodes (text and inline elements), and system_messages. Using `self.patterns.initial`, a pattern which matches start-strings (emphasis, strong, interpreted, phrase reference, literal, substitution reference, and inline target) and complete constructs (simple reference, footnote reference), search for a candidate. When one is found, check for validity (e.g., not a quoted '*' character). If valid, search for the corresponding end string if applicable, and check it for validity. If not found or invalid, generate a warning and ignore the start-string. Implicit inline markup (e.g. standalone URIs) is found last. r­r³ÚrefendZfnendr) r-r,r.rNrÌrµr“ÚdispatchrÚ groupdictrcÚimplicit_inliner)r(r—rxr8rNZpattern_searchrÒÚ remainingÚ processedZ unprocessedryÚmatchÚgroupsÚmethodÚbeforeÚinlinesÚ sysmessagesrrrršfsF ÿÿÿ  ÿz Inliner.parsez(?]z[_~*/=+a-zA-Z0-9]z-(?:%(urilast)s|%(uric)s(?=%(uri_end_delim)s))z"[-_!~*'{|}/#?^`&=+$%a-zA-Z0-9\x00]z× %(emailc)s+(?:\.%(emailc)s+)* # name (?2sÿz%Inliner.phrase_ref..éþÿÿÿ©Úrefurizproblem with embedded link: %r©r‹Ú__rùrÚ anonymousr…)rÌr¹r“rr­ráÚendswithr¾r×r‡rr»Úindirect_reference_namerrÚ adjust_uriZ referencedrÚ referencer ràr,Ú note_refnamercÚnote_indirect_targetÚnote_explicit_targetrN)r(rÚÚafterràrör—r×ZrawtextZ aliastextZ rawaliastextZunderscore_escapedZ aliastypeÚaliasr»Z alias_partsrùr Ú node_listrrrró!st  ÿ ÿ  ÿ ÿ       zInliner.phrase_refcCs"|jj |¡}|rd|S|SdS)Númailto:)rÌr½r×)r(r¾r×rrrr eszInliner.adjust_uric Csœt ||j||j¡\}}|rj||||||ƒ\}}zt|dƒ|dd_Wntk r\YnX|||fS|jjd||d} | ||| ¡g|| gfSdS)NTrz#Unknown interpreted text role "%s".r‚) rrñr.r-rràrbr„râ) r(ràr—rñrxZrole_fnryrZ messages2rérrrrôls" ÿ þÿzInliner.interpretedcCs0|j|||jjtjdd\}}}}}||||fS)NT)rä)rërÌrºrrïrrrrº}sþzInliner.literalc Cs‚| |||jjtj¡\}}}}}|rvt|dtjƒrvt|ƒdksDt‚|d}t| ¡ƒ} |d  | ¡|j   ||j ¡||||fS)Nrr[r…) rërÌr»rÚ isinstancer_r=r‡rˆrcr,r rN) r(r×rxrÚrÛrÕrÜrðr»r‹rrrÚinline_internal_targetƒsÿ zInliner.inline_internal_targetc CsÆ| |||jjtj¡\}}}}}t|ƒdkrº|d}t|tjƒrº| ¡} |j  || ¡|dd…dkrºt  d| |fd¡} |dd…dkr”d| d <nt | ƒ| d <|j  | ¡| |7} | g}||||fS) Nr[rrròz|%s%srrrrrù) rërÌr¼rÚsubstitution_referencer_rrˆr,Znote_substitution_refr r‡r ) r(r×rxrÚrÛrÕrÜrðZ subref_nodeZ subref_textZreference_noderrrrŽs.þ   ÿ   zInliner.substitution_referencec Cs| d¡}t|ƒ}|j}|d| d¡…}|| d¡d…}| d¡rttjd||d}|t |¡7}|j  |¡nœt  d|¡}|ddkr°|d d…}d |d <|j  |¡n0|d krÒd }d |d <|j  |¡n|t |¡7}|rø||d <|j  |¡t |jj¡r| ¡}||g|gfS)ze Handles `nodes.footnote_reference` and `nodes.citation_reference` elements. r±Nr°Z citationlabelz[%s]_rørú#r[ÚautoÚ*rrù)rár‡rÝr­rÞrZcitation_referenceÚTextr,Znote_citation_refÚfootnote_referenceZnote_autofootnote_refZnote_symbol_footnote_refZnote_footnote_refrZget_trim_footnote_ref_spacer4r‘) r(r×rxÚlabelrùrÝrÚrÕZrefnoderrrr£s:   ÿ  ÿ zInliner.footnote_referencec Cs”| d¡}t|ƒ}tj|| d¡|t|ƒd}||d_|rHd|d<n||d<|j |¡|j}|  d¡}|  d¡} |d|…|g|| d…gfS)NrùrÑrrr[rr°) rár‡rr r ràr,r rÝr­rÞ) r(r×rxrZ referencenamerùZ referencenoderÝrårærrrr Æs   þ     zInliner.referencecCs|j||ddS)Nr[)r)r )r(r×rxrrrÚanonymous_reference×szInliner.anonymous_referencecCsz| d¡r| d¡ ¡tjkrr| d¡r.d}nd}| d¡}t|ƒ}t|dƒ}tj||||d}||d_|gSt‚dS) NÚschemer½rrr°Trr) ráÚlowerrÚschemesrrr ràr#)r(r×rxZ addschemer—Ú unescapedràr rrrrÍÚs ÿ   ÿ zInliner.standalone_uricCsz| d¡}| d¡r$t| d¡ƒ}n| d¡r>t| d¡ƒ}nt‚|jjj|jjj|}t|ƒ}t j t|dƒ||dgS)Nrzpep-Zpepnum1ZPEPZpepnum2Tr) ráÚ startswithÚintr#r,r4Z pep_base_urlZpep_file_url_templaterrr )r(r×rxr—ZpepnumÚrefrrrrrÎës    ÿzInliner.pep_referencez rfc%d.htmlcCs\| d¡}| d¡r8t| d¡ƒ}|jjj|j|}nt‚t|ƒ}t j t|dƒ||dgS)NrZRFCÚrfcnumTr) rár r!r,r4Z rfc_base_urlÚrfc_urlr#rrr )r(r×rxr—r#r"rrrrrÏús  zInliner.rfc_referencec Cs–|sgS|jD]l\}}| |¡}|rz@| |d| ¡…|¡|||ƒ| || ¡d…|¡WStk rxYqXqtjt|ƒt|dƒdgS)a Check each of the patterns in `self.implicit_dispatch` for a match, and dispatch to the stored method for the pattern. Recursively check the text before and after the match. Return a list of `nodes.Text` and inline element nodes. NT©rà) r¬r“rÔr­rÞr#rrr)r(r—rxÚpatternrÙr×rrrrÔs ÿþ zInliner.implicit_inline) rz**ú`r®r¯z]_ržròrN)F)F)(rrrr*r)r7ršrÊrÈZ&non_unescaped_whitespace_escape_beforerÄrÅZuricZ uri_end_delimZurilastr¢Zuri_endZemailcrËrßrërâr¶r·r¸rór rôrºrrrr rrÍrÎr$rÏrÔrÒrrrrr6Îs^3 ÿ 4D #   ør6Úar[cCs t|ƒ|Sr%©Úord©ÚsZ_zerorrrÚ_loweralpha_to_int%sr-ÚAcCs t|ƒ|Sr%r)r+rrrÚ_upperalpha_to_int(sr/cCst | ¡¡Sr%)rÚ fromRomanÚupper)r,rrrÚ_lowerroman_to_int+sr2c @szeZdZdZejjZeƒZedddddedddddedd dddd œe_ e ej   ¡ƒe_ d d d ddge_ ddddddœe_eeeeejdœe_ie_ej D]"Ze ejedej¡eje<qže d¡Ze d¡Ze d¡ZiZded<ded<ded<d ed!<d"ejed#<d$eed%<d&eed'<d(eed)<d*eed+<d,eed-<ej D]:Zd.ee  ej ej!¡ed#e  ej ej"¡fee<qTd/d0ed1d2ed3d4eed5d6d7edd8œ Z#d8Z$d9d:„Z%d;d<„Z&e d=ej¡Z'd>d?„Z(d@dA„Z)dBdC„Z*dDdE„Z+dFdG„Z,dHdI„Z-d´dKdL„Z.dMdN„Z/dOdP„Z0dQdR„Z1dSdT„Z2dUdV„Z3dWdX„Z4dYdZ„Z5d[d\„Z6d]d^„Z7d_d`„Z8dadb„Z9dcdd„Z:dedf„Z;dgdh„Zdmdn„Z?dodp„Z@dqdr„ZAdsdt„ZBdµdudv„ZCd¶dwdx„ZDdydz„ZEeƒZFee d{eGeHƒejIejB¡e d|eGeHƒejIejB¡e d}eGeHƒejIejB¡d~eF_#dd€„ZJdd‚„ZKdƒd„„ZLd…d†„ZMd‡dˆ„ZNd‰dŠ„ZOd‹dŒ„ZPddŽ„ZQdd„ZRd‘d’„ZSd“d”„ZTd•d–„ZUd—d˜„ZVd™dš„ZWd›dœ„ZXddž„ZYdŸd „ZZeJe d¡eHj[ejIejB¡feKe d¢eHj[ejIejB¡feLe d£ejIejB¡feQe d¤ejIejB¡feSe d¥eHj[ejIejB¡fgeF_\d¦d§„Z]d¨d©„Z^dªd«„Z_d¬d­„Z`d®d¯„Zad°d±„Zbd²d³„ZcdJS)·rDz: Generic classifier of the first line of a block. ú(ú)r[r)r¦r§r­rÞrrÚ.)ÚparensZrparenZperiodÚarabicÚ loweralphaÚ upperalphaÚ lowerromanÚ upperromanr²z[a-z]z[A-Z]z [ivxlcdm]+z [IVXLCDM]+)r7r8r9r:r;r´z\+-[-+]+-\+ *$z =+( +=+)+ *$z=+[ =]*$z[!-/:-@[-`{-~]Znonalphanum7bitz[a-zA-Z]Úalphaz [a-zA-Z0-9]Zalphanumz [a-zA-Z0-9_-]Z alphanumpluszJ(%(arabic)s|%(loweralpha)s|%(upperalpha)s|%(lowerroman)s|%(upperroman)s|#)Úenumz%(alphanum)s%(alphanumplus)s*Úoptnamez%(%(alpha)s%(alphanumplus)s*|<[^<>]+>)Úoptargz!(-|\+)%(alphanum)s( ?%(optarg)s)?Zshortoptz"(--|/)%(optname)s([ =]%(optarg)s)?Zlongoptz(%(shortopt)s|%(longopt)s)Úoptionz(?P<%s>%s%s%s)u[-+*•‣âƒ]( +|$)z((%(parens)s|%(rparen)s|%(period)s)( +|$)z1:(?![: ])([^:\\]|\\.|:(?!([ `]|$)))*(?>>( +|$)z\|( +|$)z \.\.( +|$)z__( +|$)z(%(nonalphanum7bit)s)\1* *$) ÚbulletÚ enumeratorÚ field_markerÚ option_markerÚdoctestÚ line_blockÚgrid_table_topÚsimple_table_topÚexplicit_markuprrUr—c CsN|j ¡\}}}}| ||¡}|j|7_|sD|j| d¡7_||gfS)z Block quote.z Block quote)rJÚ get_indentedÚ block_quoterNr) r(r×rVÚ next_stateÚindentedÚindentr‰rkÚelementsrrrrN‹sÿ  z Body.indentc CsŽg}|rŠ| ||¡\}}}}}t ¡}| |||¡| |¡|rb| ||¡\} } || 7}|| 7}|}|r|ds|dd…}|d7}qfq|S)Nrr[)Úsplit_attributionrrKrircÚparse_attribution) r(rMr‰rOZblockquote_linesZattribution_linesZattribution_offsetÚnew_line_offsetÚ blockquoteÚ attributionryrrrrK•s. ü ÿ   zBody.block_quoteu(---?(?!-)|—) *(?=[^ \n])c CsÈd}d}tt|ƒƒD]¤}|| ¡}|r´|r®||dkr®|j |¡}|r®| ||¡\}} |r®|||…} | j| ¡dd| j| dd|d|…| |||d…||fSd}q|}q|ddddfS)aá Check for a block quote attribution and split it off: * First line after a blank line must begin with a dash ("--", "---", em-dash; matches `self.attribution_pattern`). * Every line after that must have consistent indentation. * Attributions must be preceded by block quote content. Return a tuple of: (block quote content lines, content offset, attribution lines, attribution offset, remaining indented lines). NFr[)rÞ)r­T)Úranger_r‘Úattribution_patternr×Úcheck_attributionZ trim_leftrÞ) r(rMr‰ÚblankZ nonblank_seenÚirUr×Zattribution_endrNZa_linesrrrrP¯s0   ÿ   þzBody.split_attributioncCsˆd}|d}t|dt|ƒƒD]T}|| ¡}|s6q||dkrTt|ƒt| ¡ƒ}qt|ƒt| ¡ƒ|krdSq|d7}||p„dfS)zt Check attribution shape. Return the index past the end of the attribution, and the indent. Nr[)NNr)rUr_r‘Úlstrip)r(rMZattribution_startrNrYrUrrrrWÒs zBody.check_attributioncCsZd |¡ ¡}|j ¡|}| ||¡\}}tj|df|žŽ}|j |¡\|_|_ ||fS)Nrr) rr‘rJr›r†rrTrLr3rU)r(rMr‰r—rxrŠryr;rrrrQæs zBody.parse_attributionc Cs¶t ¡}|j ¡\|_|_|j|7_|jd|d<| |  ¡¡\}}||7}|jj d}|j |jj |d…|j  ¡d|d|d\}}| |¡|s¬|j| d¡7_g|gfS)úBullet list item.rrAr[NÚ BulletList©r?r;rGrkz Bullet list)rZ bullet_listrJrLr3rUrNrÝÚ list_itemrÞr‰rsr>rRrPr) r(r×rVrLZ bulletlistrYrkrŒrRrrrrAîs(ÿ  ü  z Body.bulletcCsd|jj|d…r$|j |¡\}}}n|j |¡\}}}}t d |¡¡}|r\|j|||d||fS)Nr©r?r;)rJrUZget_known_indentedÚget_first_known_indentedrr^rri)r(rNrMr‰rkÚlistitemrrrr^s ÿ  ÿ ÿzBody.list_itemc Cs@| |¡\}}}}| |||¡s*t d¡‚t ¡}|j|7_|dkrRd|d<n||d<|jj|j |d<|jj|j |d<|dkr°||d<|j   d ||f¡} |j| 7_|  | ¡¡\} } || 7}|jjd} |j|jj| d …|j ¡d|d | |||dkd œd \} } | | ¡| s6|j| d¡7_g|gfS)zEnumerated List Itemr—rr7Úenumtyper¦r§r[r­zrRrPr)r(r×rVrLreÚsequencer—ÚordinalZenumlistrérarkrŒÚnewline_offsetrrrrBsH  ÿÿ  þû  zBody.enumeratorNcCs8| ¡}d}|jjD]}||rq.qtdƒ‚|||jj|j|jj|j…}|dkr`d}n\|r¢z|jj| |¡r||}Wq¼t k ržtd|ƒ‚Yq¼Xn|dkr°d}n |dkr¼d}|sì|jj D]}|jj| |¡rÈqìqÈtd ƒ‚|dkrúd }n2z|jj ||ƒ}Wnt j k r*d }YnX||||fS) aA Analyze an enumerator and return the results. :Return: - the enumerator format ('period', 'parens', or 'rparen'), - the sequence used ('arabic', 'loweralpha', 'upperroman', etc.), - the text of the enumerator, stripped of formatting, and - the ordinal value of the enumerator ('a' -> 1, 'ii' -> 2, etc.; ``None`` is returned for invalid enumerator text). The enumerator format has already been determined by the regular expression match. If `expected_sequence` is given, that sequence is tried first. If not, we check for Roman numeral 1. This way, single-character Roman numerals (which are also alphabetical) can be matched. If no sequence has been matched, all sequences are checked in order. rzenumerator format not matchedrzunknown enumerator sequence: %srYr:ÚIr;zenumerator sequence not matchedr[N)rÓr=Úformatsr"rir­rÞÚsequenceregexpsr×ÚKeyErrorÚ sequencesÚ convertersrZInvalidRomanNumeralError)r(r×Zexpected_sequencerÓrkrer—rlrrrrf2sF  ÿÿ  zBody.parse_enumeratorcCs°|dkr dSz|j ¡}Wn tk r:|j ¡YdSX|j ¡|dd… ¡sZdS| |d||¡}|r¬|\}}z| |¡sŽ| |¡r”WdSWntk rªYnXdS)zç Check validity based on the ordinal value and the second line. Return true if the ordinal is valid and the second line is blank, indented, or starts with the next enumerator or an auto-enumerator. Nr[)rJrerQr~ÚstripÚmake_enumeratorr Ú TypeError)r(rlrkrereÚresultÚnext_enumeratorÚauto_enumeratorrrrrgis*   ÿ zBody.is_enumerated_list_itemcCsü|dkrd}n²|dkr t|ƒ}n | d¡rL|dkr6dSt|tdƒdƒ}n@| d¡r€zt |¡}WqŒtjk r|YdSXn td |ƒ‚| d ¡r |  ¡}n | d ¡r´|  ¡}n td |ƒ‚|j j |}|j ||jd }|j d|jd }||fS) zÒ Construct and return the next enumerated list item marker, and an auto-enumerator ("#" instead of the regular enumerator). Return ``None`` for invalid (out of range) ordinals. rr7r<éNr(r[rz!unknown enumerator sequence: "%s"rr1rú)ÚstrrÚchrr*rZtoRomanZ RomanErrorr"r rr1r=rir¦r§)r(rlrkrerBrirxryrrrru†s:    ÿ    ÿ ÿzBody.make_enumeratorc Cs’t ¡}|j|7_| |¡\}}||7}|jjd}|j|jj|d…|j ¡d|d|d\}}|  |¡|sˆ|j|  d¡7_g|gfS)zField list item.r[NÚ FieldListr]z Field list) rÚ field_listrNÚfieldrJr‰rsr>rRrPr) r(r×rVrLr~rrkrŒrmrrrrC«s   ü  zBody.field_markercCs¬| |¡}|j ¡\}}|j ¡}|j | ¡¡\}}}} t ¡} || _|| _ |  ||¡\} } | tj |df| žŽ7} tj d  |¡f| žŽ} | | 7} |r¤| ||| ¡| | fS)Nrr)Úparse_field_markerrJrLr›r`rÞrrr3rUr†Ú field_nameÚ field_bodyrÚparse_field_body)r(r×r‹ÚsrcÚsrclinerxrMrNr‰rkZ field_nodeZ name_nodesZ name_messagesr‚rrrr¼s  ÿ z Body.fieldcCs&| ¡dd…}|d| d¡…}|S)z6Extract & return field name from a field marker match.r[Nú:)ráÚrfind)r(r×rrrrr€ÍszBody.parse_field_markercCs|j|||ddS)Nr_)ri)r(rMrŒr;rrrrƒÓszBody.parse_field_bodyc CsDt ¡}|j ¡\|_|_z| |¡\}}Wn˜tk rÄ}zz|j  d|¡}|j |7_ |j  |  ¡¡\} } } }|  | | ¡} |j | 7_ |s¦|j | d¡7_ g|gfWY¢Sd}~XYnX|j |7_ ||7}|jjd} |j|jj| d…|j ¡d|d|d\}}| |¡|s:|j | d¡7_ g|gfS)úOption list item.zInvalid option list marker: %sz Option listNr[Ú OptionListr])rÚ option_listrJrLr3rUÚoption_list_itemrr-r„rNr`rÞrKrr‰rsr>rRrP)r(r×rVrLZ optionlistrarkr„rérMrNr‰rOrŒrmrrrrDÖs<ÿÿ     ü  zBody.option_markerc CsŒ|j ¡}| |¡}|j | ¡¡\}}}}|sD| |¡t d¡‚tj d|žŽ}t  d  |¡¡} t  d|| ¡} |r„|j ||| d| |fS)Nr—rrr_)r)rJrRÚparse_option_markerr`rÞrPrrhrÚ option_groupÚ descriptionrr‹ri) r(r×rŒÚoptionsrMrNr‰rkrrŽr‹rrrr‹õs"  ÿ   ÿÿzBody.option_list_itemc Csœg}| ¡ ¡ d¡}|D]z}| ¡}d}|d dd¡}t|ƒdkrZ||dd…<d}nft|dƒdkrÀ|d d¡r†|d d ¡r”|d d ¡rÀ|ddd…|ddd…g|dd…<d }t|ƒdkr |d d ¡r |d  d¡r d |dd…¡g|dd…<dt|ƒkr&dkr‚nnXt |¡}|t  |d|d¡7}t|ƒdkrv|tj |d|d|d7}|  |¡qt dt|ƒ|fƒ‚q|S)z¿ Return a list of `node.option` and `node.option_argument` objects, parsed from an option marker match. :Exception: `MarkupError` for invalid option markers. z, rúrú=r[Nr\ú-z--ú+rú)Ú delimiterz;wrong number of option tokens (=%s), should be 1 or 2: "%s") rár‘rýr_r rrrr@Ú option_stringZoption_argumentrcr) r(r×ZoptlistZ optionstringsZ optionstringÚtokensr•Zfirstoptr@rrrrŒsH    ÿ þ ý( ÿ  ÿ  ÿÿzBody.parse_option_markercCs0d |j ¡¡}|jt ||¡7_g|gfS)Nr)rrJÚget_text_blockrNrZ doctest_block)r(r×rVrLr–rrrrE/sz Body.doctestc Csæt ¡}|j|7_|j ¡}| ||¡\}}}||7}|j|7_|s|jjd} |j|jj| d…|j  ¡d|ddd\} }|  | ¡|s²|j|j j d|dd7_t |ƒrÜ|djdkrÒd|d_| |¡g|gfS)zFirst line of a line block.r[NÚ LineBlockrr]z%Line block ends without a blank line.r‚)rrFrNrJr›Úline_block_liner‰rsr>rRrPr-rœr_rNÚnest_line_block_lines) r(r×rVrLrfrxrUryrkrŒrRrrrrF7s4   ü   þ   zBody.line_blockc Cst|jj| ¡dd\}}}}d |¡}| ||¡\}} tj|df|žŽ} |j ¡dkrjt |  d¡ƒd| _ | | |fS)z(Return one line element of a line_block.T©Ú until_blankrrržr[) rJr`rÞrr†rrUrÝr‘r_rárN) r(r×rxrMrNr‰rkr—Ú text_nodesryrUrrrršQs ÿÿ  zBody.line_block_linecCsJtdt|ƒƒD],}t||ddƒdkr||dj||_q| |¡dS)Nr[rN)rUr_rÁrNÚnest_line_block_segment)r(rfr{rrrr›]szBody.nest_line_block_linescCsœdd„|Dƒ}t|ƒ}g}t ¡}|D]H}|j|kr@| |¡q&t|ƒrd| |¡| |¡t ¡}| |¡q&t|ƒrŒ| |¡| |¡||dd…<dS)NcSsg|] }|j‘qSr)rN)rÿÚitemrrrÚ dsz0Body.nest_line_block_segment..)ÚminrrFrNrcr_rŸ)r(rfÚindentsZleastZ new_itemsZ new_blockr rrrrŸcs        zBody.nest_line_block_segmentcCs| ||||jtj¡S)zTop border of a full table.)Ú table_topÚisolate_grid_tablerZGridTableParser©r(r×rVrLrrrrGvs þzBody.grid_table_topcCs| ||||jtj¡S)zTop border of a simple table.)r¤Úisolate_simple_tablerZSimpleTableParserr¦rrrrH|s þzBody.simple_table_topc CsT| ||¡\}}|j|7_|sJ|jjd|j ¡dd}|j|7_g|gfS)zTop border of a generic table.z Blank line required after table.r[r‚)ÚtablerNr-rœrJr›) r(r×rVrLÚisolate_functionÚ parser_classr÷rkrérrrr¤‚s þzBody.table_topc Cs¢|ƒ\}}}|r–z@|ƒ}| |¡}|j ¡t|ƒd}| ||¡} | g|} Wqštjk r’} z"|j|d | j ¡| j d|} W5d} ~ XYqšXn|} | |fS)zParse a table.r[rú)rŒN) ršrJr›r_Ú build_tablerZTableMarkupErrorÚmalformed_tablerrÐrŒ) r(r©rªrfryrkÚparserÚ tabledataÚ tableliner¨r÷Úerrrrrr¨Žs$  ÿ ÿÿz Body.tablec CsÎg}d}z|jjdd}WnLtjk rf}z,|j\}}}| |jjd||d¡d}W5d}~XYnX| ¡|  |j ¡t |d  ¡ƒ}t t |ƒƒD]J}||  ¡||<||ddkr˜d}|j t |ƒ|¡||d…=qäq˜|j |d¡snd}t t |ƒd ddƒD]D}|j ||¡r|j t |ƒ|d¡||dd…=qnq| | |¡¡g||fSt t |ƒƒD]H}t ||ƒ|ks¢||ddkrz| | |¡¡g||fSqz|||fS) Nr[T©Z flush_leftúUnexpected indentation.©r3rUrz+|rr\)rJr˜rÚUnexpectedIndentationErrorrÐrcr-r„Ú disconnectÚpad_double_widthÚdouble_width_pad_charr_rtrUr~Úgrid_table_top_patr×Úextendr¬) r(ryrkrfr°r„r…ÚwidthrYrrrr¥ sF  ÿ    $zBody.isolate_grid_tablecCs°|jj}|jj}t|ƒd}t|| ¡ƒ}|jj}d}d}|d}||krö||} || ƒ} | rìt|  ¡ƒ|kr¸|j ||¡| |||d…d¡} g| ||kp´||d ¡ fS|d7}|}|dksä||ksä||d ¡sì|} qb|d7}qD|r"d} |j ||¡|||d…}n$d} |j ||d¡||d…}| |d| ¡} g| | fS|j | |¡||| d…}|  |j ¡|g| |kp¬|| d ¡ fS)Nr[rz5Bottom/header table border does not match top border.r\z$ or no blank line after table bottomrzNo bottom table border found%s.) rJr‰r>r_rtÚsimple_table_border_patr×rer¬r¶r·)r(r­r•ÚlimitZtoplenZ pattern_matchÚfoundZfound_atrYrUr×ryrÞÚextrarfrrrr§ÆsR ÿ    ÿ  zBody.isolate_simple_tablecCsf| |jd¡d |¡}d}|j ¡t|ƒd}|rB|d|7}|jj|t  ||¡||d}|gS)NrrzMalformed table.r[r‚) Úreplacer·rrJr›r_r-r„rrƒ)r(rfÚdetailrŒr–ríÚ startliner„rrrr¬ñs  ÿzBody.malformed_tablecCsì|\}}}t ¡}|dkr.|ddg7<n|rD|ddg7<tjt|ƒd} || 7}|D].} tj| d} |r†d| jd<|d8}| | 7} q`|r¾t ¡} | | 7} |D]} | | | |¡7} q¨t ¡}| |7} |D]} || | |¡7}qÒ|S) NrÚclasseszcolwidths-autozcolwidths-given)Úcols)Úcolwidthr[Zstub) rr¨Útgroupr_ÚcolspecÚ attributesÚtheadÚbuild_table_rowÚtbody)r(r®r¯Z stub_columnsZwidthsZ colwidthsZheadrowsZbodyrowsr¨rÅrÄrÆrÈÚrowrÊrrrr«üs0    zBody.build_tablec Cszt ¡}|D]h}|dkrq |\}}}}i} |r6|| d<|rB|| d<tjf| Ž} || 7}d |¡r |j|||| dq |S)NÚmorerowsÚmorecolsrr_)rrËÚentryrri) r(Zrowdatar¯rËÚcellrÌrÍrŒZ cellblockrÇrÎrrrrÉs"    ÿzBody.build_table_rowa? ( _ # anonymous target | # *OR* (?!_) # no underscore at the beginning (?P`?) # optional open quote (?![ `]) # first char. not space or # backquote (?P # reference name .+? ) %(non_whitespace_escape_before)s (?P=quote) # close quote if open quote used ) (?%(simplename)s)_ | # *OR* ` # open backquote (?![ ]) # not space (?P.+?) # hyperlink phrase %(non_whitespace_escape_before)s `_ # close backquote, # reference mark ) $ # end of string aÛ ( (?![ ]) # first char. not space (?P.+?) # substitution text %(non_whitespace_escape_before)s \| # close delimiter ) ([ ]+|$) # followed by whitespace )r»r Ú substitutionc Cs"|j ¡\}}|j | ¡¡\}}}}| d¡}t|ƒ} t d |¡¡} || _ || _ | ddkr”| dd…} d| d<| r†| d  | ¡|j   | ¡nL| dkr¶d} d| d<|j  | ¡n*| t d|¡7} | d  | ¡|j  | ¡| rô|j  | | ¡n|j  | | ¡|r|j||| d | g|fS) Nr[rrrrr…rrr_)rJrLr`rÞrár‡rÚfootnoterr3rUrcr,Znote_autofootnoteZnote_symbol_footnoterZ note_footnoter rìri) r(r×r„r…rMrNrŒrkrr‹rÑrrrrÑYs6ÿ     z Body.footnotec Csª|j ¡\}}|j | ¡¡\}}}}| d¡}t|ƒ} t d |¡¡} || _ || _ | t  d|¡7} | d  | ¡|j  | ¡|j  | | ¡|r |j||| d| g|fS)Nr[rrr…r_)rJrLr`rÞrár‡rÚcitationrr3rUrrcr,Z note_citationr ri) r(r×r„r…rMrNrŒrkrr‹rÒrrrrÒxsÿ   z Body.citationc Cs|jjj}|j ¡}|jj| ¡ddd\}}}}|jd| ¡…d |¡}dd„|Dƒ}|d} d} |  | ¡} | rxq°| d7} z| || 7} Wqht k r¬t d ƒ‚YqhXqh|d| …=|dd |  ¡t | ƒdd…  ¡|d<| ||||  d ¡¡} | g|fS) NTF)rÚ strip_indentrcSsg|] }t|ƒ‘qSr©r©rÿrUrrrr¡sz)Body.hyperlink_target..rr[zmalformed hyperlink target.rúr‹)ÚexplicitrÌr»rJr›r`rÞrÝrr×rbrr_rtÚ make_targetrá) r(r×r&rxrfrNrŒrkÚ blocktextröÚ blockindexZ targetmatchr»rrrÚhyperlink_target‰s4  ÿÿ   , ÿzBody.hyperlink_targetcCs„| |||¡\}}|dkrTtj|dt|ƒd}||_| |d||¡|j |¡|S|dkr|t |d¡}| ||||¡|S|SdS)Nrùrrør)Ú parse_targetrr»r‡rÚ add_targetr,r )r(rfÚ block_textrxZ target_nameZ target_typer–r»rrrr×¢s  zBody.make_targetcCsp|rF|d ¡dd…dkrFd dd„|Dƒ¡}| |¡}|rFd|fStd |¡ƒ}d dd „|Dƒ¡}d |fS) zó Determine the type of reference of a target. :Return: A 2-tuple, one of: - 'refname' and the indirect reference name - 'refuri' and the URI - 'malformed' and a system_message node rNròrúcSsg|] }| ¡‘qSr)rtrÕrrrr¡¼sz%Body.parse_target..rùcss |]}d t|ƒ ¡¡VqdSrûrürþrrrrÁsÿz$Body.parse_target..r)rtrÚ is_referencer)r(rfrÝrxr rùZ ref_partsrrrrÛ±s   ÿzBody.parse_targetcCs4|jjj t|ƒ¡}|sdSt| d¡p0| d¡ƒS)NÚsimpleÚphrase)rÖrÌr r×r rrá)r(r r×rrrrÞÅs  ÿzBody.is_referencecCs„||_|r`tt|ƒƒ}|d |¡|rN|j |¡}|rB||d<n td|ƒ‚|j ||j ¡n |rl||d<d|d<|j  |¡dS)Nr…rzproblem with URI: %rr[r) rUr‡rrcr2r rr,r rNZnote_anonymous_target)r(Z targetnamerr»rxr‹r¾rrrrÜÌs    zBody.add_targetcCsÊ|jjj}|j ¡\}}|jj| ¡dd\}}}}|jd| ¡…d |¡} |  ¡t |d  ¡ƒ} d} |  | ¡} | r|qÀ| d7} z| dt ||   ¡ƒ} Wqltk r¼tdƒ‚YqlXql|d| …=|d  ¡d|  ¡t| ƒdd…|d<|ds|d=|d7}|r.|d  ¡s.| ¡q|  d ¡} t | ¡}||_||_|s~|jjd | t | | ¡||d }|g|fS|d  ¡|d<|d  t | ¡¡|j|||d |d\}}d}|dd…D]D}t|tjƒst|tjƒs|j ||7_ ||=n|d7}qÊ| !tj"¡D]X}| #|¡rt d| $¡  ¡¡}|jj%d|j&|t | | ¡||d }|g|fSqt|ƒdkr®|jjd| t | | ¡||d }|g|fS|j' (|| |j ¡|g|fS)NF©rÓrrr[rúz"malformed substitution definition.rr‹z.Substitution definition "%s" missing contents.r³r…ÚSubstitutionDefr]rz6Substitution definition contains illegal element <%s>:z.Substitution definition "%s" empty or invalid.))rÖrÌrÐrJrLr`rÞrÝrrµrr‘r×rtrbrr_rarárZsubstitution_definitionr3rUr-rœrƒrcr rsrZInlinerrNZtraverseÚElementÚ*disallowed_inside_substitution_definitionsÚpformatr„Útagnamer,Znote_substitution_def)r(r×r&r„r…rfrNrŒrkrØrörÙZ subdefmatchÚsubnameZsubstitution_noderéÚnew_abs_offsetrYr;rårrrÚsubstitution_defÞs¦  ÿÿ   ,     ý ÿþ  ÿ  ÿ ü ý ÿzBody.substitution_defcCs@|ds4t|tjƒr| d¡s4t|tjƒr8| d¡r8dSdSdS)NÚidsrrTF)rrr Úgetr)r(r;rrrrä#s ÿÿ þþz/Body.disallowed_inside_substitution_definitionscKsR| d¡}t ||jj|j¡\}}|j|7_|rD| ||||¡S| |¡SdS)z?Returns a 2-tuple: list of nodes, and a "blank finish" boolean.r[N) rár Ú directiver8r.r,rNÚ run_directiveÚunknown_directive)r(r×Úoption_presetsÚ type_nameZdirective_classryrrrrì+s ÿÿzBody.directivec CsÌt|ttfƒr"ddlm}||ƒ}|j ¡}|jj}|jj|  ¡dd\}} } } d  |jj ||jjd…¡} z|  || ||¡\} }}}WnZt k rä}z<|jjd|d  |j¡ft | | ¡|d}|g| fWY¢Sd }~XYnX||| ||||| ||jƒ }z | ¡}WnVtjjjk rb}z0|jj|j|j|d}|t | | ¡7}|g}W5d }~XYnXt|tƒs|td |ƒ‚tt|ƒƒD].}t||tjƒsˆtd ||||fƒ‚qˆ|| pÈ|j  ¡fS) aá Parse a directive then run its directive function. Parameters: - `directive`: The class implementing the directive. Must be a subclass of `rst.Directive`. - `match`: A regular expression match object which matched the first line of the directive. - `type_name`: The directive name, as used in the source text. - `option_presets`: A dictionary of preset options, defaults for the directive options. Currently, only an "alt" option is passed by substitution definitions (value: the substitution name), which may be used by an embedded image directive. Returns a 2-tuple: list of nodes, and a "blank finish" boolean. r)Úconvert_directive_function)Z strip_toprr[zError in "%s" directive: %s.rúr‚Nz+Directive "%s" must return a list of nodes.z6Directive "%s" returned non-Node object (index %s): %r)!rrrÚdocutils.parsers.rstrñrJr›r‰r`rÞrr>Úparse_directive_blockrr-r„rÐrrƒr<ÚdocutilsÚparsersZrstZDirectiveErrorZsystem_messager€rérlr=rUr_ÚNodeÚis_next_line_blank)r(rìr×rðrïrñrxZinitial_line_offsetrMrNr‰rkrÝÚ argumentsrÚcontentÚcontent_offsetrÀr„Zdirective_instancerwZmsg_noderYrrrrí7sv   ÿÿ   ÿÿÿ ÿ ý þ ÿÿ ÿÿÿzBody.run_directivecCsb|j}|j}|r,|d ¡s,| ¡|d7}|rF|d ¡sF| ¡q,|rª|jsZ|jsZ|rªt|ƒD]\}}| ¡sbq€qb|d7}|d|…} ||dd…} ||d} n |} |} g} |rÎ| ||| ¡\} } ni} | rú|jsú|jsú| ||d…} |} g} | r | d ¡s |  ¡| d7} qú|js0|jr>|  || ¡} ng} | rV|sVt dƒ‚| | | | fS)Nrr[rzno content permitted) Ú option_specÚ has_contentrtZ trim_startÚtrim_endÚrequired_argumentsÚoptional_argumentsÚ enumerateÚparse_directive_optionsÚparse_directive_argumentsr)r(rMr‰rìrïrûrürYrUÚ arg_blockrùrúrrørrrróss^  ÿþ ÿ  ÿ ÿ zBody.parse_directive_blockc Cs€| ¡}t|ƒD]6\}}t tjd|¡r||d…}|d|…}qLqg}|rx| ||¡\}} |rp| | ¡nt| ƒ‚||fS)NrC) rjrr’r×rDrÌÚparse_extension_optionsr'r) r(rïrûrrrYrUZ opt_blockÚsuccessr–rrrr¡s  ÿ zBody.parse_directive_optionscCsˆ|j}|j}d |¡}| ¡}t|ƒ|kr@td|t|ƒfƒ‚nDt|ƒ||kr„|jrl| d||d¡}ntd||t|ƒfƒ‚|S)Nrz$%s argument(s) required, %s suppliedr[z+maximum %s argument(s) allowed, %s supplied)rþrÿrrýr_rZfinal_argument_whitespace)r(rìrÚrequiredÚoptionalZarg_textrørrrr³s"   ÿÿÿzBody.parse_directive_argumentsc Cst ¡}|j|d|ddd\}}|t|ƒkr0dSzt ||¡}Wn®tk rx}zdd|jdfWY¢Sd}~XYnxtt fk r´}zddd   |j¡fWY¢Sd}~XYn<tj k rî}zdd d   |j¡fWY¢Sd}~XYnX|rþd |fSd SdS) aÇ Parse `datalines` for a field list containing extension options matching `option_spec`. :Parameters: - `option_spec`: a mapping of option name to conversion function, which should raise an exception on bad input. - `datalines`: a list of input strings. :Return: - Success value, 1 or 0. - An option dictionary on success, an error string on failure. rÚExtensionOptionsT)rGrk)rzinvalid option blockzunknown option: "%s"Nzinvalid option value: %srúzinvalid option data: %sr[)rzoption data incompletely parsed) rr~rsr_rZextract_extension_optionsrqrÐr|rvrZExtensionOptionError)r(rûZ datalinesr;rmrkrrÀrrrrÄs*þ  &(*zBody.parse_extension_optionsc CsT|j ¡}|jjddd\}}}}d |¡}|jjd|t ||¡|d}|g|fS)NrFrárzUnknown directive type "%s".r‚)rJr›r`rr-r„rrƒ) r(rðrxrMrNrŒrkr—r„rrrrîås ÿ   þzBody.unknown_directivecCs||j| ¡d… ¡s.|j ¡r.t ¡gdfS|j | ¡¡\}}}}|r`|d ¡s`| ¡qFd  |¡}t ||¡g|fS)Nr[rr) rÝrÞrtrJr÷rÚcommentr`rýr)r(r×rMrNrŒrkr—rrrr ïsÿÿ   z Body.commentaÍ \.\.[ ]+ # explicit markup start \[ ( # footnote label: [0-9]+ # manually numbered footnote | # *OR* \# # anonymous auto-numbered footnote | # *OR* \#%s # auto-number ed?) footnote label | # *OR* \* # auto-symbol footnote ) \] ([ ]+|$) # whitespace or end of line zÔ \.\.[ ]+ # explicit markup start \[(%s)\] # citation label ([ ]+|$) # whitespace or end of line zÙ \.\.[ ]+ # explicit markup start _ # target indicator (?![ ]|$) # first char. not space or EOL zß \.\.[ ]+ # explicit markup start \| # substitution indicator (?![ ]|$) # first char. not space or EOL aK \.\.[ ]+ # explicit markup start (%s) # directive name [ ]? # optional space :: # directive delimiter ([ ]+|$) # whitespace or end of line cCs0| |¡\}}|j|7_| |¡g|gfS©z3Footnotes, hyperlink targets, directives, comments.)Úexplicit_constructrNÚ explicit_list©r(r×rVrLr÷rkrrrrI& s zBody.explicit_markupc Csªg}|jjD]‚\}}| |j¡}|r z|||ƒWStk rŒ}z:|j ¡}d |j¡}|  |j j ||d¡WY¢qW5d}~XYq Xq |  |¡\} } | || fS)z>Determine which explicit construct this is, parse & return it.rúr‚N) rÖÚ constructsr×rÝrrJr›rrÐrcr-rœr ) r(r×ÚerrorsrÙr&Zexpmatchr„rxrír÷rkrrrr - s   zBody.explicit_constructcCsh|jjd}|j|jj|d…|j ¡d|jd||jjd\}}| |¡|sd|j| d¡7_dS)z‹ Create a nested state machine for a series of explicit markup constructs (including anonymous hyperlink targets). r[NÚExplicit)r?r;rGrkr5zExplicit markup) rJr‰rsr>rRrNr5rPr)r(rkrŒrmrrrr = s  û  zBody.explicit_listcCs0| |¡\}}|j|7_| |¡g|gfS©zAnonymous hyperlink targets.)Úanonymous_targetrNr r rrrrM s zBody.anonymousc Csj|j ¡}|jj| ¡dd\}}}}|jd| ¡…d |¡}dd„|Dƒ}| |||d¡}|g|fS)NTrœrcSsg|] }t|ƒ‘qSrrÔrÕrrrr¡Z sz)Body.anonymous_target..r)rJr›r`rÞrÝrr×) r(r×rxrfrNrŒrkrØr»rrrrT s  ÿÿ zBody.anonymous_targetcCs¶|jjr|jgdgfS|j ¡dkr0t d¡‚n‚t|j ¡ƒdkrr|jjd|j  ¡d}|j |7_ t d¡‚n@|jj }|jj dt  ||¡|j  ¡d}|j |7_ g|gfSdS) z,Section title overline or transition marker.ÚLineú::r—ézeUnexpected possible title overline or transition. Treating it as ordinary text because it's so short.r‚z'Unexpected section title or transition.N)rJr5rÝrtrrhr_r-rjr›rNrUrSrrƒ)r(r×rVrLrérØrrrrU^ s& ý  ýz Body.linecCs|jgdgfS)z%Titles, definition lists, paragraphs.r©rÝr¦rrrr—t sz Body.text)N)rr)rN)drrrr*rZ TableParserr·r$r=rirlÚkeysrorrZ sequencepatsr!r-r/r2rr0rsrprkr’r£r¤r¸Zsimple_table_top_patr»ÚpatsreÚescaper¦r§rÌÚinitial_transitionsrNrKrVrPrWrQrAr^rBrfrgrurCrr€rƒrDr‹rŒrErFršr›rŸrGrHr¤r¨r¥r§r¬r«rÉrÖrÃr6rÉrÑrÒrÚr×rÛrÞrÜrérärìrírórrrrîr rÅrrIr r rrrUr—rrrrrD/s`ýÿüü  ÿ    ÿ      þô  ÿ# # 7%)  &+ í í ô ô ø ÷Þ-E <.!  ò òÿü üÿ üÿ üÿú úÿÝ, rDc@sNeZdZdZej ¡Zded<dd„ejDƒZe dd¡dd „Z d d „Z d S) Ú RFC2822Bodyz˜ RFC2822 headers are only valid as the first constructs in documents. As soon as anything else appears, the `Body` state should take over. z[!-9;-~]+:( +|$)Úrfc2822cCsg|] }|df‘qS)rDr)rÿr‹rrrr¡‚ sÿzRFC2822Body.r)rrDc Cs˜tjdgd}|j|7_| |¡\}}||7}|jjd}|j|jj|d…|j ¡d|d|d\}}|  |¡|sŽ|j|  d¡7_g|gfS)úRFC2822-style field list item.r)rÂr[NÚ RFC2822Listr]zRFC2822-style field list) rr~rNÚ rfc2822_fieldrJr‰rsr>rRrPr) r(r×rVrLZ fieldlistrrkrŒrmrrrr† s$  ü   ÿzRFC2822Body.rfc2822c Cs~|jd|j d¡…}|jj| ¡dd\}}}}t ¡}|t ||¡7}t d  |¡¡}||7}|rv|j |||d||fS)Nr†Trœrr_) rÝÚfindrJr`rÞrrrr‚rri) r(r×r‹rMrNr‰rkZ fieldnodeZ fieldbodyrrrr˜ s ÿÿ ÿzRFC2822Body.rfc2822_fieldN) rrrr*rDrÌrjrÚinsertrrrrrrry s ÿ rc@sNeZdZdZddd„ZeZeZeZeZeZ eZ eZ eZ eZ eZeZeZeZdS)ÚSpecializedBodya¤ Superclass for second and subsequent compound element members. Compound elements are lists and list-like constructs. All transition methods are disabled (redefined as `invalid_input`). Override individual methods in subclasses to re-enable. For example, once an initial bullet list item, say, is recognized, the `BulletList` subclass takes over, with a "bullet_list" node as its container. Upon encountering the initial bullet list item, `Body.bullet` calls its ``self.nested_list_parse`` (`RSTState.nested_list_parse`), which starts up a nested parsing session with `BulletList` as the initial state. Only the ``bullet`` transition method is enabled in `BulletList`; as long as only bullet list items are encountered, they are parsed and inserted into the container. The first construct which is *not* a bullet list item triggers the `invalid_input` method, which ends the nested parse and closes the container. `BulletList` needs to recognize input that is invalid in the context of a bullet list, which means everything *other than* bullet list items, so it inherits the transition list created in `Body`. NcCs|j ¡t‚dS©z8Not a compound element member. Abort this state machine.N)rJr~rQr¦rrrÚ invalid_input¿ s zSpecializedBody.invalid_input)NNN)rrrr*r$rNrArBrCrDrErFrGrHrIrrUr—rrrrr"§ s r"c@seZdZdZdd„ZdS)r\z-Second and subsequent bullet_list list_items.cCsL|jd|jdkr| ¡| | ¡¡\}}|j|7_||_g|gfS)r[rrA)rÝrNr$r^rÞrk)r(r×rVrLrarkrrrrA× s zBulletList.bulletN)rrrr*rArrrrr\Ó sr\c@seZdZdZdd„ZdS)ÚDefinitionListz,Second and subsequent definition_list_items.cCs|jgdgfS)zDefinition lists.Ú Definitionrr¦rrrr—æ szDefinitionList.textN)rrrr*r—rrrrr%â sr%c@seZdZdZdd„ZdS)rcz1Second and subsequent enumerated_list list_items.c Cs¨| ||jd¡\}}}}||jks\|dkrN||jdks\|js\||jdks\| |||¡sd| ¡|dkrrd|_| | ¡¡\}} |j|7_| |_ ||_g|gfS)zEnumerated list item.rbrr[) rfrNrerrdrgr$r^rÞrk) r(r×rVrLrerkr—rlrarkrrrrBï s.ÿ  ÿ ÿþ ý üzEnumeratedList.enumeratorN)rrrr*rBrrrrrcë srcc@seZdZdZdd„ZdS)r}z(Second and subsequent field_list fields.cCs,| |¡\}}|j|7_||_g|gfS)zField list field.)rrNrk©r(r×rVrLrrkrrrrC szFieldList.field_markerN)rrrr*rCrrrrr} sr}c@seZdZdZdd„ZdS)r‰z4Second and subsequent option_list option_list_items.cCsNz| |¡\}}Wntk r.| ¡YnX|j|7_||_g|gfS)rˆ)r‹rr$rNrk)r(r×rVrLr‹rkrrrrD szOptionList.option_markerN)rrrr*rDrrrrr‰ sr‰c@s*eZdZdZejZejZdd„Zej Z dS)rz6Second and subsequent RFC2822-style field_list fields.cCs,| |¡\}}|j|7_||_gdgfS)rr)rrNrkr'rrrr% szRFC2822List.rfc2822N) rrrr*rrÌrrr"r$rXrrrrr s rc@seZdZdZdd„ZdS)rzz Parse field_list fields for extension options. No nested parsing is done (including inline markup parsing). cCsRg}t|ƒdgD]:}| ¡r*| |¡q|rd |¡}|t ||¡7}g}qdS)z5Override `Body.parse_field_body` for simpler parsing.rrN)rlrtrcrrr”)r(rMrŒr;r•rUr—rrrrƒ7 s  z!ExtensionOptions.parse_field_bodyN)rrrr*rƒrrrrr/ src@seZdZdZejZdd„ZdS)r™z,Second and subsequent lines of a line_block.cCsJ|j ¡}| ||¡\}}}|j|7_|jj|7_||_g|gfS)zNew line of line block.)rJr›ršrNrk)r(r×rVrLrxrUryrkrrrrFI s  zLineBlock.line_blockN)rrrr*r"r$rXrFrrrrr™C sr™c@s&eZdZdZdd„Zdd„ZejZdS)rz0Second and subsequent explicit markup construct.cCs,| |¡\}}|j|7_||_g|gfSr )r rNrkr rrrrIW szExplicit.explicit_markupcCs,| |¡\}}|j|7_||_g|gfSr)rrNrkr rrrr^ szExplicit.anonymousN) rrrr*rIrr"r$rXrrrrrS src@sBeZdZdZe dejej¡ddœZ ddgZ dd„Z d d „Z d S) râzG Parser for the contents of a substitution_definition element. z (%s)::( +|$)r)Úembedded_directiver—r(r—cCsB|j||jddd\}}|j|7_|j ¡s:||_t‚dS)Nr…r)Zalt)rìrNrJÚat_eofrkrQr rrrr(t s ÿ  z"SubstitutionDef.embedded_directivecCs|j ¡s|j ¡|_t‚dSr%)rJr)r÷rkrQr¦rrrr—| s  zSubstitutionDef.textN) rrrr*r’r£r6rÅr¤rÌrr(r—rrrrrâh sÿÿýrâc@szeZdZdZejdddœZddgZdd„Zd d „Zd d „Z d d„Z dd„Z dd„Z dd„Z dd„Ze d¡Zdd„ZdS)rzs Classifier of second line of a text block. Could be a paragraph, a definition list item, or a title. rUr)Ú underliner—)r*rD)r—rDcCsH| ||j ¡d¡\}}|j|7_|r>|j| ¡7_gdgfS)zEnd of paragraph.r[rD)r”rJr›rNrƒ)r(r×rVrLr”r˜rrrrXŽ s ÿz Text.blankcCs|r| d|d¡gSr%)rXrYrrrÚeof˜ szText.eofc Cs”t ¡}| |¡\}}||7}|j|7_|jjd}|j|jj|d…|j ¡d|d|dd\}}|  |¡|sŠ|j|  d¡7_gdgfS)úDefinition list item.r[Nr%r&)r?r;rGrkrozDefinition listrD) rZdefinition_listÚdefinition_list_itemrNrJr‰rsr>rRrPr) r(r×rVrLZdefinitionlistZdefinitionlistitemrkrŒrmrrrrN s"  ü  z Text.indentcCsX|j ¡}|d ¡}|j ¡}|d|}g}t|ƒt|ƒkr¶t|ƒdkr~|jjrr|jjd|d} |j | 7_ t   d¡‚n8|dd|jj } |jj dt | | ¡|d} | | ¡|jjs$|dd|jj } |j ¡\} } |jjdt | | ¡| | d } |j |7_ |j | 7_ g|gfS|d} g|d d …<| ||| |d |¡g|gfS) zSection title.rrrzfPossible title underline, too short for the title. Treating it as ordinary text because it's so short.r‚r—zTitle underline too short.zUnexpected section title.r³Nr[)rJr›r‘rÝrr_r5r-rjrNrrhrUrœrrƒrcrLrSrz)r(r×rVrLrxrvr*r3ryrérØr„r…rwrrrr*® sF     ý  ÿ   þ  zText.underlinec Csä|j ¡d}d}z|jjdd}WnBtjk rf}z"|j\}}} |jjd|| d}W5d}~XYnX|t|ƒ} |  | |¡\} } |j | 7_ |j |7_ | rÚz|j  ¡Wnt k rÆYnX|j |  ¡7_ g|gfS)z Paragraph.r[NTr±r²r³)rJr›r˜rr´rÐr-r„rlr”rNrerQrƒ) r(r×rVrLrÁrérfr°r„r…r•r”r˜rrrr—Ö s* ÿ z Text.textcCs„|j ¡\}}}}|r,|d ¡s,| ¡q|s8| ¡Sd |¡}t ||¡}|j |d¡\|_ |_ |g}|s€|  |  d¡¡|S)zReturn a list of nodes.rrr[z Literal block) rJrJrtrýÚquoted_literal_blockrrrƒrLr3rUrcr)r(rMrNrŒrkr–rƒr÷rrrrƒì sÿ    ÿzText.literal_blockcCsR|j ¡}|jj}t ¡}|j|jj|d…||dtfddœd}| |¡|j S)NFÚQuotedLiteralBlockrE)r?r;r5rh) rJrRr‰rrãrir>r/rPÚchildren)r(rRrŒZ parent_noderèrrrr.ý s ÿý zText.quoted_literal_blockc Cs¾|j ¡\}}}}t d |t|ƒ¡¡}|j ¡d}|j |¡\|_|_ |  ||¡\}} ||7}tj d | žŽ} || 7}|ddd…dkr¦| |j j d|dd7} |j||| d ||fS) Nrr[rrrrz`Blank line missing before literal block (after the "::")? Interpreted as a definition list item.r‚r_)r)rJrJrr-rrlr›rLr3rUÚtermr¥r-rjri) r(ZtermlinerMrNr‰rkÚitemnoderxZtermlistryr¥rrrr- s(ÿ ÿ ÿýzText.definition_list_itemz +: +c Cst|ƒdkst‚| |d|¡\}}t |d¡}|j |¡\|_|_|g}t t|ƒƒD]¬}||}t |tj ƒrô|j   |¡} t| ƒdkrš|d|7<nX| d ¡} t  t | d¡¡} |d| 7<| dd…D]} | t t| dƒ| ¡¡qÔqX|d|7<qX||fS)z9Return a definition_list's term and optional classifiers.r[rrTN)r_r=r†rr1rJrLr3rUrUrrÚclassifier_delimiterrýr‘rrrcÚ classifier) r(r•rxržryZ term_noderrYr;r¨r—Ztextnoderªrrrr1 s, ÿ    ÿz Text.termN)rrrr*rDrÌrrXr+rNr*r—rƒr.r-r’r£r3r1rrrrr‚ sÿ (  rc@s2eZdZdZdd„Zddd„ZeZeZeZeZ dS)ÚSpecializedTextz¬ Superclass for second and subsequent lines of Text-variants. All transition methods are disabled. Override individual methods in subclasses to re-enable. cCsgS)zIncomplete construct.rrYrrrr+B szSpecializedText.eofNcCst‚dSr#©rQr¦rrrr$F szSpecializedText.invalid_input)NNN) rrrr*r+r$rXrNr*r—rrrrr59 s r5c@s eZdZdZdd„Zdd„ZdS)r&z.Second line of potential definition_list_item.cCs|j d¡gS)zNot a definition.r\)rJr~rYrrrr+T s zDefinition.eofcCs,| |¡\}}|j|7_||_gdgfS)r,r%)r-rNrk)r(r×rVrLr2rkrrrrNY szDefinition.indentN)rrrr*r+rNrrrrr&P sr&c@sLeZdZdZdZdd„Zdd„Zdd„ZeZd d „Z dd d „Z dd d„Z dS)rzO Second line of over- & underlined section title or transition marker. r[cCsv|d ¡}|jjrd|j_nt|ƒdkr4| |¡|jrl|j ¡d}tj |dd}||_ |j |7_ d|_gS)z0Transition marker at end of section or document.rFrr[r%) rtr8r1r_Ústate_correctionÚeofcheckrJr›rÚ transitionrUrN)r(rVÚmarkerrxr9rrrr+j s    zLine.eofcCsd|j ¡\}}|d ¡}t|ƒdkr0| |¡tj|d}||_|d|_|j |7_ gdgfS)zTransition marker.rrr%r[rD) rJrLrtr_r7rr9r3rUrN)r(r×rVrLr„r…r:r9rrrrXy s     z Line.blankc Csv|j ¡d}|d}|j}d}z|j ¡}Wnxtk r¦|d|}t| ¡ƒdkrl| |||d¡n6|jj dt   ||¡|d} |j | 7_ gd gfYSYnXd |||f} | ¡}| ¡}|j d d |¡sH|d|d|}t| ¡ƒdkr| |||d¡n2|jj d t   | | ¡|d} |j | 7_ gd gfSnt||kr¼|d|d|}t| ¡ƒdkrŠ| |||d¡n2|jj d t   | | ¡|d} |j | 7_ gd gfS| ¡}g} t|ƒt|ƒkr6|d|d|}t| ¡ƒdkr| |||d¡n$|jjdt   | | ¡|d} |  | ¡|d|df} d|_| | ¡| | |d| ¡d|_gd gfS)z#Potential over- & underlined title.r[rrrrr\zIncomplete section title.r‚rDz%s %s %sr*z6Missing matching underline for section title overline.z$Title overline & underline mismatch.zTitle overline too short.)rJr›rÝrerQr_r‘Úshort_overliner-rSrrƒrNrWr×rrœrcr8rzrZ) r(r×rVrLrxÚoverlinervr*rØrér3ryrwrrrr—… sv  ý ý   ý  ý z Line.textcCsx|d}|d|jj}|j ¡d}t| ¡ƒdkrF| |||d¡|jjdt  ||¡|d}|j |7_ gdgfS)Nrrr[rz+Invalid section title or transition marker.r‚rD) rJrUr›r_r‘r;r-r„rrƒrN)r(r×rVrLr<rØrxrérrrr*Å s ýzLine.underlinecCs.|jjd|d}|j|7_| ||¡dS)Nz`Possible incomplete section title. Treating the overline as ordinary text because it's so short.r‚)r-rjrNr7)r(rVrØrxr•rérrrr;Ò s ýzLine.short_overlinecCs(|j |¡g|dd…<t dd¡‚dS)NrDr—)rJr~rZStateCorrection)r(rVr•rrrr7Ú s  zLine.state_correctionN)r[)r[) rrrr*r8r+rXr—rNr*r;r7rrrrra s > rc@s^eZdZdZdejddœZdZddd„Zdd „Z d d „Z d d „Z dd„Z dd„Z dd„ZdS)r/zƒ Nested parse handler for quoted (unindented) literal blocks. Special-purpose. Not for inclusion in `state_classes`. z(%(nonalphanum7bit)s)r)Úinitial_quotedr—FcCst |||¡g|_d|_dSr%)rCr)ryÚinitial_linenorIrrrr)ì szQuotedLiteralBlock.__init__cCs|r t‚n ||gfSdSr%r6r¦rrrrXñ szQuotedLiteralBlock.blankcCs†|rH|j |j¡\}}d |¡}t ||¡}||_||_|j|7_n*|j|j j d|j  ¡d7_|j  ¡|j|j 7_gS)Nrz#Literal block expected; none found.r‚)rJrLr>rrrƒr3rUrNr-rœr›r~ry)r(rVr„r…r—rƒrrrr+÷ s ÿ   þ  zQuotedLiteralBlock.eofcCs<|s tdƒ‚|j |jjd|j ¡d¡|j ¡t‚dS)Nz7QuotedLiteralBlock.indent: context should not be empty!r²r‚) r=ryrcr-r„rJr›r~rQr¦rrrrN s ÿÿ zQuotedLiteralBlock.indentcCsZ| d¡|jd}t t |¡tj¡}| d||j|jj f¡|j   ¡|_ |jg|gfS)z7Match arbitrary quote character on the first line only.r=rÚquoted) Zremove_transitionrÝr’r£rr¤Úadd_transitionr?rTrrJr›r>)r(r×rVrLÚquoter&rrrr= s  ÿ z!QuotedLiteralBlock.initial_quotedcCs| |j¡||gfS)z,Match consistent quotes on subsequent lines.)rcrÝr¦rrrr? s zQuotedLiteralBlock.quotedcCs4|r,|j |jjd|j ¡d¡|j ¡t‚dS)Nz#Inconsistent literal block quoting.r‚)ryrcr-r„rJr›r~rQr¦rrrr—" sÿÿ zQuotedLiteralBlock.textN)F)rrrr*rDrrÌrr)rXr+rNr=r?r—rrrrr/à sÿ   r/)T)Gr*Z __docformat__Úsysr’ÚtypesrrrôrrrrrZdocutils.statemachiner r Zdocutils.nodesr r‡r ròr rrrZdocutils.parsers.rst.languagesrZ_fallback_language_moduleZdocutils.utilsrrrrrrrrr r!r"Ú Exceptionr#r$r+rBrCr¡r6r*r-r/r2rDrr"r\r%rcr}r‰rrr™rrârr5r&rr/rFrrrrÚs˜b    'n [T.,  8K þ