m gEc@sdZdZdkZdkZdkZdklZdklZl Z l Z l Z dkl Z l Z dklZlZdklZdklZd klZlZlZd klZlZlZlZd klZ d e fd YZ!de fdYZ"de fdYZ#de fdYZ$de%fdYZ&dfdYZ'defdYZ(defdYZ)defdYZ*ddZ+d fd!YZ,e-d"dd#Z.e-d$dd%Z/d&Z0d'e*fd(YZ1d)e1fd*YZ2d+e1fd,YZ3d-e3fd.YZ4d/e3fd0YZ5d1e3fd2YZ6d3e3fd4YZ7d5e3fd6YZ8d7e3e2fd8YZ9d9e7fd:YZ:d;e3fd<YZ;d=e3fd>YZ<d?e1fd@YZ=dAe*fdBYZ>dCe>fdDYZ?dEe?fdFYZ@dGe?fdHYZAdIe*fdJYZBe1e4e5e6e7e8e;e:e<e>e@eAe=e2e9fZCdS(Ks This is the ``docutils.parsers.restructuredtext.states`` module, the core of the reStructuredText parser. It defines the following: :Classes: - `RSTStateMachine`: reStructuredText parser's entry point. - `NestedStateMachine`: recursive StateMachine. - `RSTState`: reStructuredText State superclass. - `Inliner`: For parsing inline markup. - `Body`: Generic classifier of the first line of a block. - `SpecializedBody`: Superclass for compound element members. - `BulletList`: Second and subsequent bullet_list list_items - `DefinitionList`: Second+ definition_list_items. - `EnumeratedList`: Second+ enumerated_list list_items. - `FieldList`: Second+ fields. - `OptionList`: Second+ option_list_items. - `RFC2822List`: Second+ RFC2822-style fields. - `ExtensionOptions`: Parses directive option fields. - `Explicit`: Second+ explicit markup constructs. - `SubstitutionDef`: For embedded directives in substitution definitions. - `Text`: Classifier of second line of a text block. - `SpecializedText`: Superclass for continuation lines of Text-variants. - `Definition`: Second line of potential definition_list_item. - `Line`: Second line of overlined section title or transition marker. - `Struct`: An auxiliary collection class. :Exception classes: - `MarkupError` - `ParserError` - `MarkupMismatch` :Functions: - `escape2null()`: Return a string, escape-backslashes converted to nulls. - `unescape()`: Return a string, nulls removed or restored to backslashes. :Attributes: - `state_classes`: set of State classes used with `RSTStateMachine`. Parser Overview =============== The reStructuredText parser is implemented as a recursive state machine, examining its input one line at a time. To understand how the parser works, please first become familiar with the `docutils.statemachine` module. In the description below, references are made to classes defined in this module; please see the individual classes for details. Parsing proceeds as follows: 1. The state machine examines each line of input, checking each of the transition patterns of the state `Body`, in order, looking for a match. The implicit transitions (blank lines and indentation) are checked before any others. The 'text' transition is a catch-all (matches anything). 2. The method associated with the matched transition pattern is called. A. Some transition methods are self-contained, appending elements to the document tree (`Body.doctest` parses a doctest block). The parser's current line index is advanced to the end of the element, and parsing continues with step 1. B. Other transition methods trigger the creation of a nested state machine, whose job is to parse a compound construct ('indent' does a block quote, 'bullet' does a bullet list, 'overline' does a section [first checking for a valid section header], etc.). - In the case of lists and explicit markup, a one-off state machine is created and run to parse contents of the first item. - A new state machine is created and its initial state is set to the appropriate specialized state (`BulletList` in the case of the 'bullet' transition; see `SpecializedBody` for more detail). This state machine is run to parse the compound element (or series of explicit markup elements), and returns as soon as a non-member element is encountered. For example, the `BulletList` state machine ends as soon as it encounters an element which is not a list item of that bullet list. The optional omission of inter-element blank lines is enabled by this nested state machine. - The current line index is advanced to the end of the elements parsed, and parsing continues with step 1. C. The result of the 'text' transition depends on the next line of text. The current state is changed to `Text`, under which the second line is examined. If the second line is: - Indented: The element is a definition list item, and parsing proceeds similarly to step 2.B, using the `DefinitionList` state. - A line of uniform punctuation characters: The element is a section header; again, parsing proceeds as in step 2.B, and `Body` is still used. - Anything else: The element is a paragraph, which is examined for inline markup and appended to the parent element. Processing continues with step 1. treStructuredTextN(s TupleType(snodess statemachinesutilss urischemes(sApplicationErrors DataError(sStateMachineWSsStateWS(sfully_normalize_name(swhitespace_normalize_name(s escape2nullsunescapes column_width(s directivess languagess tableparsersroles(sent MarkupErrorcBstZRS(N(t__name__t __module__(((t:/data/zmath/zope/lib/python/docutils/parsers/rst/states.pyRzstUnknownInterpretedRoleErrorcBstZRS(N(RR(((RR{st"InterpretedRoleNotImplementedErrorcBstZRS(N(RR(((RR|st ParserErrorcBstZRS(N(RR(((RR}stMarkupMismatchcBstZRS(N(RR(((RR~stStructcBstZdZdZRS(s3Stores data attributes for dotted-attribute access.cKs|ii|dS(N(tselft__dict__tupdatet keywordargs(R R ((Rt__init__s(RRt__doc__R(((RR s tRSTStateMachinecBs tZdZddedZRS(sy reStructuredText's master StateMachine. The entry point to reStructuredText parsing is the `run()` method. iicCsti|ii|_||_|d jo t }n|i |it d|d|i d|idgddddd||_||_|i|i|ii |_ ||_ti|||d |d }|gjp td d |_|_d S( s Parse `input_lines` and modify the `document` node in place. Extend `StateMachineWS.run()`: set up parse-global data and run the StateMachine. tdocumenttreportertlanguaget title_stylest section_levelitsection_bubble_up_kludgetinlinert input_sourcetsources.RSTStateMachine.run() results should be empty!N(t languagest get_languageRtsettingst language_codeR Rt match_titlesRtNonetInlinertinit_customizationsR Rtmemotattach_observert note_sourcetnodetStateMachineWStrunt input_linest input_offsettresultstAssertionError(R R(RR)RRR*((RR's*        (RRRRR'(((RRs tNestedStateMachinecBstZdZddZRS(sh StateMachine run from within other StateMachine runs, to parse nested document structures. icCs||_||_|i|_|i|ii|i|_|i|_||_t i |||}|gjp td|S(s Parse `input_lines` and populate a `docutils.nodes.document` instance. Extend `StateMachineWS.run()`: set up document-wide data. s1NestedStateMachine.run() results should be empty!N(RR R"RR#R$RRR%R&R'R(R)R*R+(R R(R)R"R%RR*((RR's      (RRRR'(((RR,s tRSTStatecBstZdZeZddZdZdZdZdZ de e dZ e hde e dZ d Z d Zd Zd Zd ZdZdZRS(s` reStructuredText State superclass. Contains methods used by all State subclasses. icCs2hdt<dd<|_ti|||dS(Nt state_classest initial_statetBody(R.R tnested_sm_kwargstStateWSRt state_machinetdebug(R R3R4((RRscCsYti||ii}||_|i|_|i|_|i|_|ii|_ dS(N( R2t runtime_initR R3R"RRRR%tparent(R R"((RR5s      cCs.y|ii|Wntj onXdS(sT Jump to input line `abs_line_offset`, ignoring jumps past the end. N(R R3t goto_linetabs_line_offsettEOFError(R R8((RR7s cCsH|iid|ii|||iifd|ii |dgfS(ss Override `StateWS.no_match` to generate a system message. This code should never be run. sjInternal error: no transition pattern match. State: "%s"; transitions: %s; context: %s; current line: %r.tlineN( R Rtseveret __class__Rt transitionstcontextR3R:tabs_line_numberR(R R>R=((Rtno_matchs(cCs ggfS(sCalled at beginning of file.N((R R>((Rtbofsc Cs|djo |i}n|djo |i}nt|}|d|i |}|i ||d|i d|d||i|i} |io5t||djo|i it||n| S(sg Create a new StateMachine rooted at `node` and run it over the input `block`. R4R"R%RiN(tstate_machine_classRR t nested_smtstate_machine_kwargsR1tlentblockt block_lengthR4R3R'R)R"R%RtunlinkR8t new_offsetR6t next_line( R RFR)R%RRBRDRGR3RI((Rt nested_parses       !c  Cs| djo |i} n| djo|ii} n|| d<| d|i| } |djo |}n|| i |_ x1|iD]#\} } t| i || | qW| i||d|id|d|| i |i }| i| i|fS(s 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. R/R4R"R%RN(RBRR RCRDR1tcopyR/R4R3tblank_finish_statet blank_finishtstatestextra_settingstitemstkeytvaluetsetattrR'RFR)R"R%RRHR8(R RFR)R%R/RNRMRPRRBRDRRRSR3((Rtnested_list_parses$         cCs1|i|||o|i|||ndS(s=Check for a valid subsection and create one if it checks out.N(R tcheck_subsectionRtstyletlinenotnew_subsectionttitletmessages(R RZRRWRXR[((Rtsection2scCs(|i}|i}|i}y|i|d}Wn]tj oQt ||ijo|i |dSq|i |i ||7_ dSnX||joM||_t |djo d|_n|iit |dtn||djodSn |i |i ||7_ dSdS(s 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. iiN(R R"RRtmyleveltindexRWtlevelt ValueErrorREtappendR6ttitle_inconsistentRRXRRR3t previous_lineR9(R RRWRXR_R]RR"((RRV7s,         cCs+|iidtid|d|}|S(NsTitle level inconsistent:tR:(R RR;tnodest literal_blockt sourcetextRXterror(R RgRXRh((RRb`s cCs?|i}|i} |id7_ti} |i| 7_|i||\}} ti |d|} t| i}| di|| | 7} | |7} | | 7} |ii| | |iid} |iid}|i|ii| d|d| dd}|i||i| jo tn| |_dS(s?Append new subsection to document tree. On return, check level.iRdtnamesR)R%RN(R R"RR]ReR\t section_nodeR6t inline_textRZRXt textnodesttitle_messagest titlenodetnormalize_nametastexttnameRaR[Rtnote_implicit_targetR3t line_offsettoffsetR8t absoffsetRKR(t newabsoffsetR7R9(R RZRXR[RlRqRuR"RvR]RjRtRnRm((RRYfs,        c Csdi|i}tid|oZt|djogdfSn0|ddjo|d i}n |d }d}n |}d}|i ||\}}ti|d |}||_|g||fS( sW Return a list (paragraph & messages) & a boolean: literal_block next? s s(?%(or_group)s)%(suffix)sN(t definitionRqtprefixtsuffixtpartst part_stringstpartttypet TupleTypeRat build_regexpRRwtor_grouptlocalstregexptcompileR{tUNICODE( RRRRRqRRRRR((RRs R cBsttZdZdZdZdZdZdZdei eZ dei eZ dZ d Z d Zd Zd Zd ZdZdeZdZdZde dddedddddgfdde deddddd ed!d"egfgfd#d$eed%gfgfZed&eed'eie d(e d)eie d*e d+eid,eeieiBd-eid.eeid/eie d0e d1eie d2e d3eie d4e d5eieed6eid7eid8ed9eeid:eid;eeid<eid=eei Zd>Zd?d@ZdAZ dBZ!dCZ"dDZ#dEZ$dFZ%dGZ&dHZ'dIZ(dJZ)dKZ*e+dLZ,dMZ-dNZ.dOZ/dPZ0dQZ1dRZ2dSZ3hdTe!<dUe"<dVe#<de'<de(<dWe*<dXe)<dYe,<dZe-        /     s'"([{s((?<=^)|(?<=[-/: \n%s]))s((?=$)|(?=[-/:.,;!? \n\x00%s]))s (?]s[_~*/=+a-zA-Z0-9]s-(?:%(urilast)s|%(uric)s(?=%(uri_end_delim)s))s"[-_!~*'{|}/#?^`&=+$%a-zA-Z0-9\x00]s %(emailc)s+(?:\.%(emailc)s+)* # name (?%s)(?P__?)t footnotelabels\[s(?P\]_)s[0-9]+s\#(%s)?s\*s(?P%s)Rs(?P(:%s:)?)s`(?!`)Rtemphasiss(\*)tstrongs(\*\*)tinterpreted_or_phrase_refs %(non_whitespace_escape_before)s ( ` (?P (?P:%(simplename)s:)? (?P__?)? ) ) %(end_string_suffix)s t embedded_uris ( (?:[ \n]+|^) # spaces or beginning of line/string < # open bracket %(non_whitespace_after)s ([^<>\x00]+) # anything but angle brackets & nulls %(non_whitespace_before)s > # close bracket w/o whitespace before ) $ # end of string tliterals(``)ttargets(`)tsubstitution_refs (\|_{0,2})temailt$Rs5 %(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 s] ) ) %(end_string_suffix)s Rs %(start_string_prefix)s ( (pep-(?P\d+)(.txt)?) # reference to source file | (PEP\s+(?P\d+)) # reference by name ) %(end_string_suffix)sRs{ %(start_string_prefix)s (RFC(-|\s+)?(?P\d+)) %(end_string_suffix)scCs|i}|i}|i}|djodSn||d}y;||}|ii||i i|jodSnWn)t j o dSnt j onXdS(s=Return 1 if inline markup start-string is 'quoted', 0 if not.iiN( RtstringRtendtprestartt poststartR topenersR^tcloserst IndexErrorR`(R RRRRRR((Rt quoted_starts      % icCs}|i} |id} |id} |i|o| | g| | gdfSn|i | | }|o|ido|t |i|id |} | |id}t | | |!d}| | ||| g| |g|idfSn|iid|id|} t | | | !d} t | | | !d}|i| || }| | |g| | | gdfS(NRRdis*Inline %s start-string without end-string.R:(RRRt matchstartRtmatchendR Rt end_patternR|tendmatchtunescapetrestore_backslashesR}ttextendt rawsourcet nodeclasstgroupRRRRXtmsgt problematictprb(R RRXRRRRRRRR}RRRR((Rt inline_objs$  4 cCsS|ii||i}ti||d|}|ii|}|i ||S(Ntrefid( R Rtset_idtmessageR6tmsgidReRRR}tprbidt add_backref(R R}RRRRR((RRs  cCs@|i|||iiti\}}}}}||||fS(N( R RRRXRRReRRRRt endstring(R RRXRRRRR((RRs0cCs@|i|||iiti\}}}}}||||fS(N( R RRRXRRReRRRRR(R RRXRRRRR((RRs0cCs|ii}|i}|id}|id}|id} |i d} d}| o| dd!} d}n-|i|o|| g||gfSn|i||}|o|ido||i}|i do| oe|iidd|} t|| |!d}|i||| }|| |g||| gfSn|i d dd!} d }n|i|id } t|||!d}|dd jo| oi|iid |d|} t|| |!d}|i||| }|| |g||| gfSn|i|| |||| t| Sqt|| |!d}|i|| | |\} }|| | |||fSn|iid d|} t|||!d}|i||| }|| |g||| gfS( NRtroleRdiiRsVMultiple roles in interpreted text (both prefix and suffix present; only one allowed).R:Rt_s=Mismatch: both interpreted text role %s and reference suffix.sLInline interpreted text or phrase reference start-string without end-string.( R RRRRRRRRRt rolestartRRtpositionRR|RRRRRXRRR}RRtescapedRt phrase_reft interpretedtnodelistR[(R RRXRRRRR}R[RRRRRRRRRR((RRsX      "  "  c Cs|iii|} | ot|| id }| i d}di |i } |i| } | o"ti| i dd| }ntd||p | }qnd}t|} ti||dt|}|g} |dd jo#|o| |de<d?e<d@dA<dBdC<dDdEe<dFd dcZ?d ddZ@d deZAdfZBeZCedgeidheDeEeiFdieidjeDeEeiFeiGBdkeidleDeEeiFeC_ dmZHdnZIdoZJdpZKdqZLdrZMdsZNdtZOduZPdvZQdwZRdxZSdyZTdzZUd{ZVd|ZWd}ZXeHeid~eEiYeiFeiGBfeIeideEiYeiFeiGBfeJeideiFfeOeideiFfeQeideEiYeiFeiGBfgeC_ZdZ[dZ\dZ]dZ^dZ_dZ`dZaRS(s: Generic classifier of the first line of a block. tparensRt(Rt)RiRitrparenRditperiodt.tarabict loweralphat upperalphat lowerromant upperromans[0-9]+s[a-z]s[A-Z]s [ivxlcdm]+s [IVXLCDM]+Rs\+-[-+]+-\+ *$s =+( +=+)+ *$s=+[ =]*$s[!-/:-@[-`{-~]tnonalphanum7bits[a-zA-Z]talphas [a-zA-Z0-9]talphanums [a-zA-Z0-9_-]t alphanumplussJ(%(arabic)s|%(loweralpha)s|%(upperalpha)s|%(lowerroman)s|%(upperroman)s|#)tenums%(alphanum)s%(alphanumplus)s*toptnames%(%(alpha)s%(alphanumplus)s*|<[^<>]+>)toptargs!(-|\+)%(alphanum)s( ?%(optarg)s)?tshortopts"(--|/)%(optname)s([ =]%(optarg)s)?tlongopts(%(shortopt)s|%(longopt)s)toptions(?P<%s>%s%s%s)tbullets [-+*]( +|$)t enumerators((%(parens)s|%(rparen)s|%(period)s)( +|$)t field_markers#:(?![: ])([^:\\]|\\.)*(?>>( +|$)t line_blocks\|( +|$)tgrid_table_toptsimple_table_toptexplicit_markups \.\.( +|$)Rs__( +|$)R:s(%(nonalphanum7bit)s)\1* *$R}c Cs|ii\}}}}|i||\}} |i |7_ |i | 7_ |p|i |i d7_ n||gfS(s Block quote.s Block quoteN(R R3t get_indentedtindentedtindentRsRNt block_quotet blockquoteR[R6RR>t next_state( R RR>R^RNR]R[RZRsR[((RR[7sc Csw|i||\}}}ti}|i |||g}|o&|i ||\}}||7}n||fS(N(R tcheck_attributionRZRstblockquote_linestattribution_linestattribution_offsetReR\R]RKR[tparse_attributiont attribution( R RZRsR]RdR[R`RbRa((RR\Bs  u(---?(?!-)|—) *(?=[^ \n])c Csd} d}d}xtt|dddD]f}||i }|o7|o0|i i ||d} | o |} nPq/|p d}q/q/W| ot|| djot|| dt|| di }xft| dt|D]G}||o6|t||t||i jo d} PqqWn| oW|| d}|i| idd|i|dd|| ||| dfSn|ddfSdS( s@ Check for an attribution in the last contiguous block of `indented`. * First line after last blank line must begin with "--" (etc.). * Every line after that must have consistent indentation. Return a 3-tuple: (block quote lines, attribution lines, attribution offset). iiiiiRRN(Rtblankt nonblank_seenR[trangeRERZtitstriptthis_line_blankR tattribution_patternRtlstriptjta_linest trim_leftRRs( R RZRsR[RhRmRnRfRjReR((RR_Qs6  ,6 cCshdi|i}|ii|}|i ||\}}t i |d|}||_||fS(Ns Rd(RwRZRyR}R R3R?RsRXRkRlR[ReRdR%R:(R RZRsR%R}R[RXRl((RRczs  c Csti}|i|7_|id|d<|i|i\}}||7}|i i d}|i|i i|d|i idd|ddd|\}}|i||p|i|id 7_ng|gfS( sBullet list item.iRPiR)R%R/t BulletListRNs Bullet listN(Ret bullet_listt bulletlistR R6RRt list_itemRRhRNR3RsRtRUR(R8tnew_line_offsetR7RR^( R RR>R^RNRrRhRtRt((RRPs    cCs|ii|o|ii|\}}}n|ii|\}}}}t i di |}|o|i |d|d|n||fS(Ns R)R%(R R3R:R[tget_known_indentedRZRsRNtget_first_known_indentedReRsRwtlistitemRK(R R[RNRZRsRw((RRsscCs|i|\}} }}|i|| |pti dnt i } |i | 7_ | djod| dR^R~RNRR{R}R}RwRtRR((RRQs8       3 cCs|i}d}x0|iiD]}||oPqqWtd|||ii|i |ii|i !}|djo d}n|oRy(|ii |i|o |}nWqtj otd|qXn/|djo d}n|djo d}n|pFxC|iiD]%}|ii |i|oPq"q"Wtd n|djo d }n:y|ii||}Wntij o d }nX||||fS( sA 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. Rdsenumerator format not matchedRsunknown enumerator sequence: %sRhRDtIREsenumerator sequence not matchediN(RRR}R RJtformatsR{RRRRR}texpected_sequencetsequenceregexpstKeyErrort sequencesR~t convertersR7tInvalidRomanNumeralErrorR(R RRR~R{R}R}R((RR|sD     +           cCs|djodSny|ii}Wn$tj o|iidSnX|ii|d ipdSn|i|d||}|oR|\}}y,|i|p|i|odSnWqtj oqXndS(s Check validity based on the ordinal value and the second line. Return true iff the ordinal is valid and the second line is blank, indented, or starts with the next enumerator or an auto-enumerator. iN(R~RR R3RJR9RcRitmake_enumeratorR}R{tresulttnext_enumeratortauto_enumeratorRt TypeError(R R~R}R{RJRRR((RRs(        cCse|djo d}n|djot|}n|ido3|djod Snt|tdd}nU|ido4yti |}Wqti j o d SqXnt d||i d o|i }n1|i d o|i}nt d||ii|}|i||id }|id|id }||fS( s 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. RRARGiR0iR7s!unknown enumerator sequence: "%s"RR9t N(R}RQtstrR~tendswithRtchrR1R7ttoRomant RomanErrorRRRR9R RJRR{RRRR(R R~R}R{RRQRR((RRs0     c Csti}|i|7_|i|\}}||7}|iid}|i |ii |d|ii dd|ddd|\}}|i||p|i|id7_ng|gfS( sField list item.iR)R%R/t FieldListRNs Field listN(Ret field_listR R6tfieldRRNR3RsRtRUR(R8RR7RR^( R RR>R^RNRRRtR((RRR=s    c Cs|i|} |ii} |ii|i\}}}}t i}| |_|i| | \}}|t i| d|7}t idi||} || 7}|o|i||| n||fS(NRds (R tparse_field_markerRRqR3R?RXRvRRZR[RsRNReRt field_nodeR:Rkt name_nodest name_messagest field_namet field_bodyRwtparse_field_body( R RRNR[RZRsRRRRXRRq((RRNs$   cCs'|id}||id }|S(s6Extract & return field name from a field marker match.it:N(RRRtrfind(R RR((RR]scCs|i|d|d|dS(NR)R%(R RKRZRtR%(R RZRtR%((RRcsc Csti}y|i|\} }Wntj o\} } |i i d| d| }|i|7_|ii|i\}}}}|i||\}} |i|7_|i| 7_|p|i|id7_ng|gfSnX|i|7_|| 7}|iid} |i|ii| d|iidd|ddd |\}}|i||p|i|id7_ng|gfS( sOption list item.sInvalid option list marker: %sR:s Option listiR)R%R/t OptionListRNN( Ret option_listt optionlistR toption_list_itemRRwRNRRRXRRhRR6R3RvRRZR[RsR\R]R[RR^RtRUR(R8RR7(R RR>R^RNR]R[RZRsR[RRXRwRtRRR((RRSfs2 $   c Cs|ii}|i|} |ii|i\}}}}|p |i |tidntid| }tidi|} tid|| }|o|i|d|d| n||fS(NR}Rds R)R%(R R3R8Rttparse_option_markerRtoptionsRvRRZR[RsRNR7RRRet option_groupt descriptionRwRRK( R RRNR[RZRsRRtRRR((RRs$   c Cs"g}|iiid}x|D]}|i}d}|did}t |djo||d*d}nt |ddjog|di do|di d p|di d o*|dd |ddg|d*d }nt |djoF|di d o2|d i d odi |dg|d)ndt |jo djnoyti|}|ti|d|d7}t |djo(|ti|d|dd|7}n|i|q(tdt ||f|iidq(W|S(s Return a list of `node.option` and `node.option_argument` objects, parsed from an option marker match. :Exception: `MarkupError` for invalid option markers. s, Rit=iit-s--t+Rdtt delimiters;wrong number of option tokens (=%s), should be 1 or 2: "%s"N(toptlistRRRyRt optionstringst optionstringttokensRtfirstoptRERRRwReROt option_stringtoption_argumentRaRR R3R?( R RRRRRRRRO((RRs4   T  ;$cCs@di|ii}|iti||7_g|gfS(Ns ( RwR R3tget_text_blockRzR6Ret doctest_blockR^(R RR>R^Rz((RRTsc CsSti} |i| 7_|ii}|i||\} }}| | 7} |i|7_|pe|ii d}|i|ii|d|iidd| dddd\}}|i|n|p2|i|iidd |iid7_nt| o6| did jod| d_n|i| ng|gfS( sFirst line of a line block.iR)R%R/t LineBlockRNis%Line block ends without a blank line.R:N(ReRURFR R6R3R?RXtline_block_lineRR:R[RNRsRtRUR(R8RtR7RRRER[Rtnest_line_block_linesR^( R RR>R^RNR[RXRtRtR:RF((RRUs,    c Cs|ii|idd\}}}}di |}|i ||\} }ti|d| } |iidjo t|idd| _n| ||fS(s(Return one line element of a line_block.t until_blankiu RdRN(R R3RvRRRZR[RsRNRwR}RkRXt text_nodesR[ReR:RRyRER( R RRXRNR[RZRsR}R[RR:((RRs cCsaxMtdt|D]6}||idjo||di||_qqW|i|dS(Ni(RgRERFR^R[RR tnest_line_block_segment(R RFR^((RRs  cCsg}|D]}||iq ~}t|}g}ti }xs|D]k}|i|jo|i |qIt |o*|i||i |ti }n|i |qIWt |o|i||i |n||(dS(N(t_[1]RFtitemR[tindentstmintleastt new_itemsReRUt new_blockRaRER R(R RFRRRRRR((RRs"$       cCs|i||||itiS(sTop border of a full table.N(R t table_topRR>R^tisolate_grid_tablet tableparsertGridTableParser(R RR>R^((RRVscCs|i||||itiS(sTop border of a simple table.N(R RRR>R^tisolate_simple_tableRtSimpleTableParser(R RR>R^((RRW sc Css|i||\}}|i|7_|p8|iidd|i i d}|i|7_ng|gfS(sTop border of a generic table.s Blank line required after table.R:iN( R ttabletisolate_functiont parser_classRRNR6RRR3R?RR^( R RR>R^RRRNRR((RRs c Cs|\} }}| oyX|}|i| } |i i t | d}|i | |} | g|}Wqtij o+}|i| di|i|}qXn|}||fS(sParse a table.iRN(RRFR[RNRtparserRt tabledataR R3R?REt tablelinet build_tableRRRtTableMarkupErrortdetailtmalformed_tableRwtargs( R RRRNRRRR[RRRRF((RRs +c CsLg}d}y|iidd}WnUtij oF}|i \}}}|i |i idd|d|d}nX|i|i|it|di}xott|D][}||i||<||ddjo,d}|iit||||3PqqW|ii|dpd}xtt|d ddD]K}|ii||o.|iit||d||d3PqYqYW|i|i|g||fSnxmtt|D]Y}t|||jp||ddjo'|i|i|g||fSqqW|||fS( Nit flush_leftsUnexpected indentation.RR:is+|ii(R[RNR R3RRFRtUnexpectedIndentationErrortinstanceRRRXRaRRht disconnecttpad_double_widthtdouble_width_pad_charRERitwidthRgRhRctgrid_table_top_patRtextendR( R RNRRhR[RRXRRF((RR.sH     ,cCsB|ii}|ii}t|d} t||i}|i i } d} d} |d}x|| jo||} | | }|ot| i|jo^|ii|||i|||d!d}g||| jp||di fSn| d7} |} | djp#|| jp||di o |}PqSn|d7}qcW| o/d}|ii| |||| d!}n)d}|ii||d||}|i|d|}g|| fS|ii|||||d!}|i|i|g|| jp||di fS(Niis5Bottom/header table border does not match top border.is$ or no blank line after table bottomRdsNo bottom table border found%s.(R R3RsRR(RxREtlimitRittoplentsimple_table_border_patRt pattern_matchtfoundRtfound_atRhR:RJRR[RtextraRFRR(R RFRRhRRR[RxRRRRR:RR((RRTsH       - 0  cCs|i|iddi|}d}|iit |d}|o|d|7}n|i i |ti||d|}|gS(NRds sMalformed table.iR:(RFtreplaceR RRwRzRR3R?RERXRRRhReRf(R RFRRXRhRRz((RRs cCs|\}} }ti} tidt|} | | 7} xL|D]D}ti d|}|od|i d<|d8}n| |7} qDW| oAti } | | 7} x(| D]} | |i| |7} qWnti}| |7} x$|D]} ||i| |7}qW| S(Ntcolstcolwidthitstub(Rt colwidthstheadrowstbodyrowsReRttgroupRERtcolspect stub_columnst attributesttheadtrowR tbuild_table_rowRttbody(R RRRRRRRRRRRRR((RRs.       c Csti} x|D]}|djoqn|\}}}}h} |o|| d`?) # 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 t substitutions ( (?![ ]) # first char. not space (?P.+?) # substitution text %(non_whitespace_escape_before)s \| # close delimiter ) ([ ]+|$) # followed by whitespace c Cs|ii}|ii|i\}}}}|i d}t |} tidi|}||_| ddjoD| d} d|d<| o|di| n|ii|ni| djo$d} d|d<|ii|n8|ti d|7}|di| |ii|| o|ii||n|ii|||o|i|d |d |n|g|fS( Nis iRRRiRRdR)R%(R R3R?RXRvRRRZR[RtRNRRRoRqRetfootnoteRwR:RaRtnote_autofootnotetnote_symbol_footnotet note_footnoteRRRK( R RRNR[RZRRRXRtRq((RRs2$      c Cs|ii}|ii|i\}}}}|i d}t |} tidi|}||_|ti d|7}|di| |ii||ii|||o|i|d|d|n|g|fS(Nis RdRiR)R%(R R3R?RXRvRRRZR[RtRNRRRoRqRetcitationRwR:RaRt note_citationRRK( R RRNR[RZRRRXRtRq((RRs$  cCsn|iii}|ii} |ii|i dddd\}}} }|i|i di|} g} |D]} | t| qy~ }|d}d}xa|i |}|oPn|d7}y|||7}Wqtj otd| qXqW||4|dd|i t|di|d<|i|| | |id}|g|fS( NRit strip_indentis smalformed hyperlink target.RRq(R texplicitRRR R3R?RXRvRRRFR[RtRNRRwt blocktextRR:RRt blockindext targetmatchRRRERit make_targetR(R RRNRR[RR R R R RRXRtR:RF((Rthyperlink_targets,0 '  0cCs|i|||\}}|djoUti|ddt |}||_ |i |d|||i i||SnB|djo0ti|d}|i |||||Sn|SdS(NRRdR(R t parse_targetRFt block_textRXt target_typeRzReRRotindirect_reference_namet add_targett target_nameRtnote_indirect_target(R RFRRXRRRRz((RR (s   cCs|os|diddjoXdig}|D]}||iq3~}|i|}|od|fSqzndig}|D]}|di|i q~}dt |fS(s 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 iRRRRdRN( RFRiRwRR:RR t is_referenceRRR(R RFRRXRRRR:((RR7s "09cCsP|iiiit|}|pdSnt|idp |idS(Ntsimpletphrase( R RRRRRRRR(R RR((RRIscCs||_|ott|}|di||o;|i i |}|o||d|i||| \} } | o| otdqn|o|i|| } n| o| otd n| | | |fS( NR5iiRR6iis@no arguments permitted; blank line required before content blocksno content permitted(ii(R5RtgetattrR4Rt argument_spect option_spect content_specRZRit trim_startRsttrim_endRgRERht arg_blockR6R7R tparse_directive_optionsR/Rtparse_directive_arguments(R RZRsR4R/R:RhR;R7R6R?R5RR<((RR3sL      c Cs|i}xNtt|D]4}||d djo||}|| }PqqWg}|o@|i ||\}}|o|i |qt|n||fS(NiR(R/RLRRgRER?Rht opt_blockR tparse_extension_optionsR;tsuccessRzR R( R R/R;R?RBRDRhRzR((RR@s     cCs|\}}}di|}|i}t ||jo t d|t |fnat |||joI|o|id||d}qt d||t |fn|S(Ns s$%s argument(s) required, %s suppliedis+maximum %s argument(s) allowed, %s supplied( R:trequiredtoptionaltlast_whitespaceRwR?targ_textRR5RERR(R R:R?RER5RHRGRF((RRA#s  $cCsti}|i|d|dddd\}}|t|jod Snyt i ||}Wnt j o}dd|idfSngttfj o#}ddd i|ifSn3t ij o#}dd d i|ifSnX|od|fSndSd S(s 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. iR/tExtensionOptionsRNisinvalid option blocksunknown option: "%s"sinvalid option value: %sRsinvalid option data: %ssoption data incompletely parsedN(isinvalid option block(isoption data incompletely parsed(ReRR%R RUt datalinesRRNRERtextract_extension_optionsR;RRRRR`RRwtExtensionOptionError(R R;RJR%RNRRR((RRC3s"  c Csz|ii}|iiddd\}}}}di |}|i i d|ti||d|}|g|fS(NiRs sUnknown directive type "%s".R:(R R3R?RXRvRZR[RtRNRwR}RRhR*ReRf( R R*RNRhR[RZR}RXRt((RR0Ts $cCs|i|ii o'|iiotigdfSn|ii |i\}}}}x(|o |di o|iqiWdi|}ti||g|fS(Niis (RRRRiR R3R8RetcommentRvRZR[RtRNR>RwR}(R RRNR[RZR}Rt((RRM^s+$s \.\.[ ]+ # 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 s \.\.[ ]+ # explicit markup start \[(%s)\] # citation label ([ ]+|$) # whitespace or end of line s \.\.[ ]+ # explicit markup start _ # target indicator (?![ ]|$) # first char. not space or EOL s \.\.[ ]+ # explicit markup start \| # substitution indicator (?![ ]|$) # first char. not space or EOL sK \.\.[ ]+ # explicit markup start (%s) # directive name [ ]? # optional space :: # directive delimiter ([ ]+|$) # whitespace or end of line cCs>|i|\}}|i|7_|i|g|gfS(s3Footnotes, hyperlink targets, directives, comments.N(R texplicit_constructRRRNR6t explicit_listR^(R RR>R^RNR((RRXs  c Csg}x|iiD]x\} }|i|i}|oSy| ||SWqt j o/\}}|i |i i|d|PqXqqW|i|\}}|||fS(s>Determine which explicit construct this is, parse & return it.R:N(terrorsR Rt constructsRR RRtexpmatchRRRXRaRRRMRRN( R RRNRPRR RRRXRR((RRNs c Cs|iid}|i|ii|d|iidd|iddd|d|ii \}}|i ||p|i|i d7_nd S( s Create a nested state machine for a series of explicit markup constructs (including anonymous hyperlink targets). iR)R%R/tExplicitRNRsExplicit markupN( R R3RsRtRUR(R8R6RNRRR7R(R RNRRt((RROs cCs>|i|\}}|i|7_|i|g|gfS(sAnonymous hyperlink targets.N(R tanonymous_targetRRRNR6ROR^(R RR>R^RNR((RRs  c Cs|ii}|ii|idd\} }}}|i |i di | }g}| D]} |t| qd~} |i| ||d}|g|fS(NRis Rd(R R3R?RXRvRRRFR[RtRNRRwR RR:RR R( R RRNR[RR RRXRtR:RF((RRTs 'cCs|iio|igdgfSn|iidjotidnt|iidjoC|i i dd|ii }|i |7_ tidnY|ii}|i idti||d|ii }|i |7_ g|gfSdS( s,Section title overline or transition marker.tLines::R}iseUnexpected possible title overline or transition. Treating it as ordinary text because it's so short.R:s'Unexpected section title or transition.N(R R3RRRRiRRRERRR?RR6R:R R;ReRfR^(R RR>R^R R((RR:s     cCs|igdgfS(s%Titles, definition lists, paragraphs.RN(RR(R RR>R^((RR}s( sbullets enumerators field_markers option_markersdoctests line_blocksgrid_table_topssimple_table_topsexplicit_markups anonymousslinestext(bRRRRt TableParserRR RJRtkeysRRt sequencepatsRR4R6R:R7R8RRR}R{RRtsimple_table_top_patRtpatsR{R"RRRtinitial_transitionsR[R\RkR_RcRPRsRQRR|RRRRRRRRSRRRTRURRRRVRWRRRRRRRRtvarsR R/RRRR R RRRR'R$R,R.R3R@RARCR0RMR(RQRXRNRORRTR:R}(((RR0s   u69  %     H~   )   # 7  %       *        & +   "& (        C  - +   ! ,     t RFC2822BodycBsstZdZeiiZdedR^RNRRRaRt((RR^s   c Cs|i|iid }|ii|idd\}}}}t i }|t i||7}t idi|}||7}|o|i|d|d|n||fS(NRRis R)R%(RRtfindRqR R3RvRRZR[RsRNReRt fieldnodeRRRwt fieldbodyRK( R RRNRdR[RqRsReRZ((RRb s  (srfc2822sBody( RRRR0RRLRR[RqtinsertR^Rb(((RR]s  * tSpecializedBodycBsntZdZeeedZeZeZeZeZeZ eZ eZ eZ eZ eZeZeZeZRS(s 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`. cCs|iitdS(s8Not a compound element member. Abort this state machine.N(R R3RcR9(R RR>R^((Rt invalid_input, s (RRRRRhR[RPRQRRRSRTRURVRWRXRR:R}(((RRg s RpcBstZdZdZRS(s-Second and subsequent bullet_list list_items.cCsi|id|idjo|in|i|i\}}|i|7_||_g|gfS(sBullet list item.iRPN( RRR R6RhRsRRwRNR^(R RR>R^RNRw((RRPD s (RRRRP(((RRp@ s tDefinitionListcBstZdZdZRS(s,Second and subsequent definition_list_items.cCs|igdgfS(sDefinition lists.t DefinitionN(RR(R RR>R^((RR}S s(RRRR}(((RRiO s RycBstZdZdZRS(s1Second and subsequent enumerated_list list_items.c Cs|i||id\}}}}||ijpV|djo2||idjp2|ip(||i djp|i ||| o|i n|djo d|_n|i |i \} }|i| 7_||_||_ g|gfS(sEnumerated list item.RxRiN(R R|RR6R{R}R}R~RRzRRhRsRRwRNR^( R RR>R^R~RNR{R}R}Rw((RRQ\ s%f    (RRRRQ(((RRyX s RcBstZdZdZRS(s(Second and subsequent field_list fields.cCs:|i|\}}|i|7_||_g|gfS(sField list field.N(R RRRNR6R^(R RR>R^RNR((RRRt s  (RRRRR(((RRp s RcBstZdZdZRS(s4Second and subsequent option_list option_list_items.cCsfy|i|\}}Wn%tj o\}}|inX|i|7_||_g|gfS(sOption list item.N( R RRRNRRRXRhR6R^(R RR>R^RNRXRR((RRS s (RRRRS(((RR| s R`cBs2tZdZeiZeiZdZeiZ RS(s6Second and subsequent RFC2822-style field_list fields.cCs:|i|\}}|i|7_||_gdgfS(sRFC2822-style field list item.R`N(R RbRRRNR6(R RR>R^RNR((RR^ s  ( RRRR]RR[R^RgRhRe(((RR` s    RIcBstZdZdZRS(sz Parse field_list fields for extension options. No nested parsing is done (including inline markup parsing). cCs|g}xot|dgD]Z}|io|i|q|o/di|}|t i ||7}g}qqWdS(s5Override `Body.parse_field_body` for simpler parsing.Rds N( RxtlistRZR:RiRaRwR}R%ReR(R RZRtR%RxR}R:((RR s (RRRR(((RRI s RcBs tZdZeiZdZRS(s,Second and subsequent lines of a line_block.cCsa|ii}|i||\}}}|i |7_ |i i |7_ ||_g|gfS(sNew line of line block.N( R R3R?RXRRR:R[RNR6R^(R RR>R^RNR[RXR:((RRU s (RRRRgRhReRU(((RR s  RScBs)tZdZdZdZeiZRS(s0Second and subsequent explicit markup construct.cCs:|i|\}}|i|7_||_g|gfS(s3Footnotes, hyperlink targets, directives, comments.N(R RNRRRNR6R^(R RR>R^RNR((RRX s  cCs:|i|\}}|i|7_||_g|gfS(sAnonymous hyperlink targets.N(R RTRRRNR6R^(R RR>R^RNR((RR s  (RRRRXRRgRhRe(((RRS s   RcBsZtZdZhdeideiei<ddR^RNR((RRl s   cCs0|iip|ii|_ntdS(N(R R3RnR8RNR9(R RR>R^((RR} s( RRRR{RR R(RRR[RlR}(((RR s   RcBstZdZhdeid<ddR3R?R~R6Rf(R RR>R^R~R((RRe s %cCs"|o|id|dngS(N(R>R ReR(R R>((Rteof sc Csti}|i|\}}||7}|i|7_|i i d}|i |i i |d|i idd|ddd|dd\}}|i||p|i|id 7_ngd gfS( sDefinition list item.iR)R%R/RiRNRMRjsDefinition listR0N(Retdefinition_listtdefinitionlistR tdefinition_list_itemR>tdefinitionlistitemRNR6R3RsRtRUR(R8RR7R( R RR>R^RNRRtRrRt((RR[ s    c Cs|ii} |di}|ii} |d| }g}t |t | jot | djoK|iio+|iidd| } |i| 7_ntidq |dd|ii}|iidti||d| } |i| n|iipn|dd|ii}|iidti||d| } |i|7_|i| 7_g|gfSn| d}g|(|i|||| d |g|gfS( sSection title.is isfPossible title underline, too short for the title. Treating it as ordinary text because it's so short.R:R}sTitle underline too short.sUnexpected section title.iN(R R3R?RXR>RyRZRRRoRR[t column_widthRERRRRR6RRR:R RReRfRaR;R^RWR\( R RR>R^RWRZR[R RRXRRo((RRo s8       c Cs|iid}d} y|iidd} WnHti j o9}|i \} }} |iidd|d| } nX|t| }|i||\} }|i| 7_|i| 7_|o@y|iiWntj onX|i|i7_ng|gfS(s Paragraph.iRsUnexpected indentation.RR:N(R R3R?t startlineRRRRFRRRRRRXRRhR>RkRxRR~R6RJR9RfR^( R RR>R^RvRR~RxRRXRRFR((RR}= s( cCs|ii\}}}}x(|o |di o|iqW|p|i Sndi |}t i ||}|d|_|g}|p|i|idn|S(sReturn a list of nodes.is is Literal blockN(R R3RYRZR[RtRNRiR>tquoted_literal_blockRwRzReRfR:RRaR(R RNR[RZRfRtRRz((RRfS s  c Cs|ii}|ii}ti}|i|ii |d|d|dddhdt f<dd<}|i ||i S( NR)R%RiRDR.R/tQuotedLiteralBlock(R R3R8RsRtReR#t parent_nodeRKR(RxR R7tchildren(R R RtRyR8((RRwc s  ! c Cs|ii\}}}}tidi |t |} |ii d} | | _|i|| \}}| |7} tid|}| |7} |dddjo$||iidd|d7}n|i|d |d || |fS( Ns iRdiis::s`Blank line missing before literal block (after the "::")? Interpreted as a definition list item.R:R)R%(R R3RYRZR[RsRNReRsRwttermlineRkRtR?RXR:ttermttermlistR[RRRRK( R R{RNRR}R[RZRsR[RtRX((RRso s"   s +: +c Cs6t|djpt|i|d|\}}ti }|g} xt t|D]}||}t|tio|ii|i} t| djo| dc|7((RRp scCs tdS(s8Not a compound element member. Abort this state machine.N(R9(R RR>R^((RRh s( RRRRpRRhReR[RoR}(((RR s  RjcBs tZdZdZdZRS(s.Second line of potential definition_list_item.cCs|iidgS(sNot a definition.iN(R R3Rc(R R>((RRp scCs:|i|\}}|i|7_||_gdgfS(sDefinition list item.RiN(R RsR>RtRNR6(R RR>R^RNRt((RR[ s  (RRRRpR[(((RRj s  RUcBsVtZdZdZdZdZdZeZdZddZ ddZ RS(sO Second line of over- & underlined section title or transition marker. icCs|di}|iiod|i_n%t|djo|i|n|ioE|i i d}t i d|d}||_|i|7_nd|_gS(s0Transition marker at end of section or document.iiiRN(R>RitmarkerR R"RREtstate_correctionteofcheckR3R?RXRet transitionR:R6(R R>RRXR((RRp s    cCs~|iid}|di}t|djo|i|nt i d|}||_ |i |7_ gdgfS(sTransition marker.iiiRR0N( R R3R?RXR>RiRRERReRR:R6(R RR>R^RRXR((RRe s c CsN|iid} |d}|i}d} y|ii } Wnt j o|d|}t |idjo|i||| dq|iidti||d| } |i| 7_gd gfSnXd ||| f} |i}| i} |id di| p|d|d| }t |idjo|i||| dqL|iid ti| | d| } |i| 7_gd gfSn|| jo|d|d| }t |idjo|i||| dqL|iid ti| | d| } |i| 7_gd gfSn|i}g}t|t |jo|d|d| }t |idjo|i||| dq|iidti| | d| } |i| n|d| df}d|_|i|i| || d|d|_gd gfS(s#Potential over- & underlined title.iiRds iisIncomplete section title.R:R0s%s %s %sRos6Missing matching underline for section title overline.s$Title overline & underline mismatch.sTitle overline too short.N( R R3R?RXR>toverlineRRRZRoRJR9R RERytshort_overlineRR;ReRfRR6RR=R[RuRRaRWRR\Rl( R RR>R^RWRZR[R RRRXRRo((RR} s`           # cCs|d}|d|ii}|iid}t|i djo|i |||dn|i i dt i||d|}|i|7_gdgfS(Nis iis+Invalid section title or transition marker.R:R0(R>RR R3R:R R?RXRERyRRRhReRfRR6(R RR>R^R RRXR((RRo! s  cCs;|iidd|}|i|7_|i||dS(Ns`Possible incomplete section title. Treating the overline as ordinary text because it's so short.R:( R RRRXRR6RR>Rx(R R>R RXRxR((RR- s  cCs-|ii|g|(tidddS(NR0R}(R R3RcRxR>RtStateCorrection(R R>Rx((RR4 s( RRRRRpReR}R[RoRR(((RRU s   : RxcBsutZdZhddei<ddR9R^(R RR>R^((RReK s cCs|o@di|}ti||}|i|_|i|7_n8|i|i i dd|i i 7_|i i |i|i7_gS(Ns s#Literal block expected; none found.R:(R>RwR}ReRfR RR:R6RRR3R?RcR[(R R>R}Rf((RRpQ s  cCsS|p td|ii|iidd|ii|ii t dS(Ns7QuotedLiteralBlock.indent: context should not be empty!sUnexpected indentation.R:( R>R+R R[RaRRhR3R?RcR9(R RR>R^((RR[_ s  cCsy|id|id}titi|}|i d||i |i i f|i i|_|ig|gfS(s7Match arbitrary quote character on the first line only.RitquotedN(R tremove_transitionRRtquoteR{RR"R tadd_transitionRR<RR3R?RR^(R RR>R^RR ((RRh s   cCs|i|i||gfS(s,Match consistent quotes on subsequent lines.N(R>RaRRR^(R RR>R^((RRs scCsM|o<|ii|iidd|ii|iint dS(Ns#Inconsistent literal block quoting.R:( R>R R[RaRRhR3R?RcR9(R RR>R^((RR}x s (sinitial_quotedstext(RRRR0RZRR[RReRpR[RRR}(((RRx: s     (DRt __docformat__tsysR{R7ttypesRtdocutilsReRRR Rt DataErrortdocutils.statemachineR&R2tdocutils.nodestfully_normalize_nameRoRtdocutils.utilsRRRutdocutils.parsers.rstR+RRRtdocutils.parsers.rst.languagestent_fallback_language_moduleRRRRt ExceptionRR RR,R-RR R1R4R6R:R0R]RgRpRiRyRRR`RIRRSRRRRjRURxR.(8RpR RjRRRiR4RRIRR]R0R2RR R`RRRR{RR+RR6ReRRRRRRRR.RSRRxR:RRRuRRUR RoRRR&R,RyRRgR7RRRR-((Rt?gsj       '  .,  xG