V!\c@sdZdZddlZddlZddlmZmZddlmZm Z m Z ddlm Z m Z ddl mZmZddlmZdd lmZddlZdd lmZmZmZmZdd lmZdd lmZmZmZdd lm Z m!Z!m"Z"ddlm#Z#de fdYZ$de fdYZ%de fdYZ&de fdYZ'de(fdYZ)dfdYZ*defdYZ+defdYZ,defd YZ-e.d!Z/d"fd#YZ0e1d$d%d&Z2e1d'd%d(Z3d)Z4d*e-fd+YZ5d,e5fd-YZ6d.e5fd/YZ7d0e7fd1YZ8d2e7fd3YZ9d4e7fd5YZ:d6e7fd7YZ;d8e7fd9YZ<d:e7e6fd;YZ=d<e;fd=YZ>d>e7fd?YZ?d@e7fdAYZ@dBe5fdCYZAdDe-fdEYZBdFeBfdGYZCdHeCfdIYZDdJeCfdKYZEdLe-fdMYZFe5e8e9e:e;e<e?e>e@eBeDeEeAe6e=fZGdS(Ns This is the ``docutils.parsers.rst.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. treStructuredTextiN(t FunctionTypet MethodType(tnodest statemachinetutils(tApplicationErrort DataError(tStateMachineWStStateWS(tfully_normalize_name(twhitespace_normalize_name(t directivest languagest tableparsertroles(ten(t escape2nulltunescapet column_width(tpunctuation_charstromant urischemes(tsplit_escaped_whitespacet MarkupErrorcBseZRS((t__name__t __module__(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRzstUnknownInterpretedRoleErrorcBseZRS((RR(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR{st"InterpretedRoleNotImplementedErrorcBseZRS((RR(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR|st ParserErrorcBseZRS((RR(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR}stMarkupMismatchcBseZRS((RR(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR~stStructcBseZdZdZRS(s3Stores data attributes for dotted-attribute access.cKs|jj|dS(N(t__dict__tupdate(tselft keywordargs((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyt__init__s(RRt__doc__R$(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRstRSTStateMachinecBs eZdZdeddZRS(sy reStructuredText's master StateMachine. The entry point to reStructuredText parsing is the `run()` method. icCstj|jj|_||_|d kr9t}n|j|jt d|d|j d|jdgdddt d||_ ||_ |j|j|j j |_ ||_tj|||d |d }|gkstd 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(R t get_languagetsettingst language_codeR)t match_titlestNonetInlinertinit_customizationsRR(tFalsetmemoR'tattach_observert note_sourcetnodeRtruntAssertionError(R"t input_linesR't input_offsetR3R-tresults((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR<s*          N(RRR%tTrueR4R<(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR&stNestedStateMachinecBseZdZedZRS(sh StateMachine run from within other StateMachine runs, to parse nested document structures. cCs||_||_|j|_|j|jj|j|_|j|_||_tj |||}|gkst d|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!( R3R8R'R9R:R(R)R;RR<R=(R"R>R?R8R;R3R@((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR<s      (RRR%RAR<(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRBstRSTStatecBseZdZeZgZedZdZdZ dZ dZ edddZ diedddZdZd Zd Zd Zd Zd ZdZRS(s` reStructuredText State superclass. Contains methods used by all State subclasses. cCs.itd6dd6|_tj|||dS(Nt state_classestBodyt initial_state(RDtnested_sm_kwargsR R$(R"t state_machinetdebug((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR$s  cCstj||jj}||_|j|_|j|_|j|_|jj|_t |jds||jj |j_ ndS(Ntget_source_and_line( R t runtime_initRHR8R(R-R'R;tparentthasattrRJ(R"R8((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRKs      cCs,y|jj|Wntk r'nXdS(sT Jump to input line `abs_line_offset`, ignoring jumps past the end. N(RHt goto_linetEOFError(R"tabs_line_offset((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRNs cCs9|jjd|jj|||jjf|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.N(R(tseveret __class__RRHtlineR4(R"tcontextt transitions((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pytno_matchs  cCs ggfS(sCalled at beginning of file.((R"RT((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pytbofsc CsJd}|dkr(|j}|d7}n|dkrJ|j}|d7}nt|}d} |dkry|jj} Wqtk rqXn| s|d|j|} n| j||d|j d|d||dkr|jj | n | j | j } |j rFt||dkrF|jjt||n| S( sg Create a new StateMachine rooted at `node` and run it over the input `block`. iiiRIR8R;R3N(R4t nested_smRGtlentnested_sm_cachetpopt IndexErrorRIR<R8tappendtunlinkRPRLRHt next_line( R"tblockR?R;R3tstate_machine_clasststate_machine_kwargst use_defaultt block_lengthRHt new_offset((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyt nested_parses4               c  Cs| dkr|j} n| dkr6|jj} n|| d<| d|j| } |dkrj|}n|| j|_x1|jD]#\} } t| j|| | qW| j ||d|j d|d|| j|j}| j | j |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. RFRIR8R;R3N( R4RXRGtcopyRItstatest blank_finishtitemstsetattrR<R8R^RP(R"R`R?R;RFRitblank_finish_statetextra_settingsR3RaRbRHtkeytvalue((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pytnested_list_parse&s"          cCs/|j|||r+|j|||ndS(s=Check for a valid subsection and create one if it checks out.N(tcheck_subsectiontnew_subsection(R"ttitleR/tstyletlinenotmessages((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pytsectionDscCs|j}|j}|j}y|j|d}WnVtk rt||jkrh|j|dS|j|j||7_dSnX||kr||_t|dkrt |_ n|j j t|dtn||dkrdS|j|j||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(R8R*R+tindext ValueErrorRYR]RLttitle_inconsistentR4RAR,RHt previous_lineRO(R"R/RtRuR8R*tmyleveltlevel((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRqIs*         cCs+|jjdtjd|d|}|S(NsTitle level inconsistent:tRS(R(RQRt literal_block(R"t sourcetextRuterror((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRzrs  cCs=|j}|j}|jd7_tj}|j|7_|j||\}}tj|d|} t| j} |dj | || 7}||7}||7}|j j |||j j d} |j jd} |j|j j| d| d|dt} |j| |j|kr0tn||_dS(s?Append new subsection to document tree. On return, check level.iR~tnamesR?R;R3N(R8R+RRwRLt inline_textRstnormalize_nametastextR]R'tnote_implicit_targetRHt line_offsetRPRfR>RARNRO(R"RsRuRvR8R|t section_nodet textnodesttitle_messagest titlenodetnametoffsett absoffsett newabsoffset((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRrxs,        c Csdj|j}tjd|ryt|dkrCgdfS|ddkrf|d j}n |d }d}n |}d}|j||\}}tj|d |}|jj |\|_ |_ |g||fS( sW Return a list (paragraph & messages) & a boolean: literal_block next? s s(?}t|tkrP|jt|dq|j|qWdj|}dt} |rtj| tj S| SdS(s! Build, compile and return a regular expression based on `definition`. :Parameter: `definition`: a 4-tuple (group name, prefix, suffix, parts), where "parts" is a list of regular expressions and/or regular expression definitions to be joined into an or-group. t|s.%(prefix)s(?P<%(name)s>%(or_group)s)%(suffix)sN( ttypettupleR]t build_regexpR4RtlocalsRtcompiletUNICODE( t definitionRRtprefixtsuffixtpartst part_stringstparttor_grouptregexp((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRs  R5cBsneZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d eZd ZdZdZedZdZdZdZdZdZdZdZdZdZdZdZedZ dZ!dZ"dZ#d Z$d!Z%d"Z&i ed#6ed$6ed%6ed&6ed'6ed(6ed)6e d*6e!d+6Z'RS(,s9 Parse inline markup; call the `parse()` method. cCs g|_dS(N(timplicit_dispatch(R"((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR$s cCs't|dtr!d}d}n2dtjtjf}dtjtjtjf}tj}|j t |j d|ddd|j d d d d d gfdd|d|j ddddd|j dd|j gfgfdd|j |j dgfgf}||_||_||_tdt|dtj|jd|tjdtj|jd|tjdtjd |tjtjBd!tjd"|tjtjBd#tj|jd$|tjd%tj|jd&|tjd'tj|jd(|tjd)tj|j|d*tjtjBd+tjd,|jd-|tjtjBd.tjd/|tjtjBd0tjd1|tjtjB |_|jj|jj|jf|jr|jj|jj |j!fn|j"r#|jj|jj#|j$fndS(2Ntcharacter_level_inline_markupu (^|(?%s)(?P__?)t footnotelabels\[s(?P\]_)s[0-9]+s\#(%s)?s\*s(?P%s)t backquotes(?P(:%s:)?)s`(?!`)tinitialtemphasiss(\*)tstrongs(\*\*)tinterpreted_or_phrase_refs %(non_unescaped_whitespace_escape_before)s ( ` (?P (?P:%(simplename)s:)? (?P__?)? ) ) %(end_string_suffix)s t embedded_links ( (?:[ \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 tliterals(``)ttargets(`)tsubstitution_refs (\|_{0,2})temailt$turis5 %(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 tpeps %(start_string_prefix)s ( (pep-(?P\d+)(.txt)?) # reference to source file | (PEP\s+(?P\d+)) # reference by name ) %(end_string_suffix)strfcs{ %(start_string_prefix)s (RFC(-|\s+)?(?P\d+)) %(end_string_suffix)s(%tgetattrR7Rtopenerst delimiterstclosing_delimiterstclosersRRgR!tvarsRRtnon_whitespace_aftert simplenametstart_string_prefixtend_string_suffixRRRRRtnon_whitespace_escape_beforeRtVERBOSEtnon_whitespace_beforet email_patterntpatternsRR]Rtstandalone_uritpep_referencesRt pep_referencetrfc_referencesRt rfc_reference(R"R1RRtargsR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR6s                      cCsg|j|_|j|_|j|_||_|jjj}|j}t|}g}g} g} x|r*||} | r&| j } || dp| dp| dp| d} | || |\}}}}| j || |7} |r'||j dj | |7}||7}g} q'qfPqfWdj | |}|r]||j ||7}n|| fS(s 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. RRtrefendtfnendR~( R(R'R)RLRRRtdispatchRt groupdictR]timplicit_inlineR(R"RRuR8RLtpattern_searchRt remainingt processedt unprocessedRvtmatchtgroupstmethodtbeforetinlinest sysmessages((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRds<               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 (?-ss\_itrefurisproblem with embedded link: %rt__t anonymousR(RRRRRRtendswithRRRRRtindirect_reference_nameRRt adjust_urit referencedRR4t referenceR R't note_refnameR]tnote_indirect_targettnote_explicit_targetRL(R"RtafterRRRRt aliastexttunderscore_escapedt aliastypetaliasRt alias_partsR Rt node_list((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRsd               cCs+|jjj|}|r#d|S|SdS(Nsmailto:(RRR(R"RR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR\sc Cstj||j||j\}}|rV||||||\}}|||fS|jjd|d|} |j||| g|| gfSdS(Ns#Unknown interpreted text role "%s".RS(RRR)R(RR( R"RRRRutrole_fnRvRt messages2R((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRcs   cCsF|j|||jjtjdt\}}}}}||||fS(NR(RRRRRA(R"RRuRRRRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRpsc Cs|j|||jjtj\}}}}}|rt|dtjrt|dksdt|d}t|j} |dj | |j j ||j n||||fS(NiiR( RRRRt isinstanceRYR=RRR]R'RRL( R"RRuRRRRRRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pytinline_internal_targetvs* c Cs|j|||jjtj\}}}}}t|dkr|d}t|tjr|j} |jj || |ddkrtj d| |fd} |ddkrd| d 6ed?6d@dA6dBdC6dDedE6d dF6Z!dZ"dGZ#dHZ$ejdIejZ%dJZ&dKZ'dLZ(dMZ)dNZ*dOZ+ddPZ-dQZ.dRZ/dSZ0dTZ1dUZ2dVZ3dWZ4dXZ5dYZ6dZZ7d[Z8d\Z9d]Z:d^Z;d_Z<d`Z=daZ>dbZ?dcZ@ddZAd d deZBd ddfZCdgZDeZEedhejdieFeGejHejBdjejdkeFeGejHejBdlejdmeFeGejHejBeE_!dnZIdoZJdpZKdqZLdrZMdsZNdtZOduZPdvZQdwZRdxZSdyZTdzZUd{ZVd|ZWd}ZXd~ZYeIejdeGjZejHejBfeJejdeGjZejHejBfeKejdejHejBfePejdejHejBfeRejdeGjZejHejBfgeE_[dZ\dZ]dZ^dZ_dZ`dZadZbRS(s: Generic classifier of the first line of a block. Rt(Rt)RiRitparensR~itrparent.tperiodtarabict 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)u[-+*•‣⁃]( +|$)tbullets((%(parens)s|%(rparen)s|%(period)s)( +|$)t enumerators#:(?![: ])([^:\\]|\\.)*(?>>( +|$)tdoctests\|( +|$)t line_blocktgrid_table_toptsimple_table_tops \.\.( +|$)texplicit_markups__( +|$)Rs(%(nonalphanum7bit)s)\1* *$RSRc Csj|jj\}}}}|j||}|j|7_|s]|j|jd7_n||gfS(s Block quote.s Block quote(RHt get_indentedt block_quoteRLR( R"RRTt next_statetindentedtindentRRitelements((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRzs c Csg}x|r|j||\}}}}}tj}|j||||j||r|j||\} } || 7}|| 7}n|}x)|r|d r|d}|d7}qWq W|S(Nii(tsplit_attributionRR|RfR]tparse_attribution( R"R~RRtblockquote_linestattribution_linestattribution_offsettnew_line_offsett blockquotet attributionRv((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR|s  !     u(---?(?!-)|—) *(?=[^ \n])c Csd}t}xtt|D]}||j}|r|r||dkr|jj|}|r|j||\}} |r|||!} | j|j dd| j| dd|| | |||||fSqnt }q|}qW|ddddfSdS(s 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). iRRN( R4R7trangeRYRtattribution_patternRtcheck_attributiont trim_leftRRA( R"R~Rtblankt nonblank_seentiRSRtattribution_endRta_lines((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRs(      cCsd}|d}xt|dt|D]q}||j}|sJPn|dkrut|t|j}q*t|t|j|kr*dSq*W|d7}||pdfS(st Check attribution shape. Return the index past the end of the attribution, and the indent. iiN(NN(R4RRYRtlstrip(R"R~tattribution_startRRRS((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRs   " cCs}dj|j}|jj|}|j||\}}tj|d|}|jj|\|_|_ ||fS(Ns R~( RRRHRRRRRJR/RS(R"R~RRRuRRvR;((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRs c Cstj}|jj\|_|_|j|7_|jd|d<|j|j \}}||7}|jj d}|j |jj |d|jj dd|ddd|\}}|j||s|j|jd 7_ng|gfS( sBullet list item.iRriR?R;RFt BulletListRis Bullet list(Rt bullet_listRHRJR/RSRLRt list_itemRRRpR>RPRNR( R"RRTR}t bulletlistRRiRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRrs     cCs|jj|r.|jj|\}}}n|jj|\}}}}tjdj|}|r|j|d|d|n||fS(Ns R?R;(RHRStget_known_indentedtget_first_known_indentedRRRRf(R"RR~RRitlistitem((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRs cCs|j|\}}}}|j|||sBtjdntj}|j|7_|dkrvd|dRPRNR(R"RRTR}RtsequenceRtordinaltenumlistRRRiRtnewline_offset((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRss>           cCs|j}d}x.|jjD]}||rPqqWtd|||jj|j|jj|j!}|dkrd}n}|ry&|jj|j|r|}nWqt k rtd|qXn*|dkrd}n|dkrd}n|sIx@|jj D]#}|jj|j|rPqqWtd n|dkr^d }n7y|jj ||}Wnt j k rd }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. R~senumerator format not matchedR)sunknown enumerator sequence: %sRRftIRgsenumerator sequence not matchediN(RRltformatsRRRRtsequenceregexpsRtKeyErrort sequencest convertersRtInvalidRomanNumeralErrorR4(R"Rtexpected_sequenceRRRRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR!sB              cCs|dkrdSy|jj}Wntk rD|jjdSX|jj|d jsfdS|j|d||}|r|\}}y&|j|s|j|rdSWqtk rqXndS(s 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. iN( R4RHR_ROR{tstriptmake_enumeratorRAt TypeError(R"RRRR_tresulttnext_enumeratortauto_enumerator((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRXs(      cCsO|dkrd}n|dkr0t|}n|jdrl|dkrOd St|tdd}nM|jdrytj|}Wqtjk rd SXntd||j d r|j }n.|j d r|j }ntd||j j |}|j||jd }|jd|jd }||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. R)RcRiiRSiRs!unknown enumerator sequence: "%s"R:R[R N(tstrRR4tchrRTRttoRomant RomanErrorRRAR:R[RlRRR(R"RRRRsRRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRus2      c Cstj}|j|7_|j|\}}||7}|jjd}|j|jj|d|jjdd|ddd|\}}|j ||s|j|j d7_ng|gfS(sField list item.iR?R;RFt FieldListRis Field list( Rt field_listRLtfieldRHRRpR>RPRNR( R"RRTR}RRRiRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRts    cCs|j|}|jj\}}|jj}|jj|j\}}}} tj} || _|| _ |j ||\} } | tj |d| 7} tj dj || } | | 7} |r|j||| n| | fS(NR~s (tparse_field_markerRHRJRRRRRR/RSRt field_namet field_bodyRtparse_field_body(R"RRtsrctsrclineRuR~RRRit field_nodet name_nodest name_messagesR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRs$    cCs'|jd}||jd }|S(s6Extract & return field name from a field marker match.it:(Rtrfind(R"RR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRscCs|j|d|d|dS(NR?R;(Rf(R"R~RR;((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRsc Cstj}|jj\|_|_y|j|\}}Wntk r}|jj d|}|j |7_ |jj |j \} } } }|j | | } |j | 7_ |s|j |jd7_ ng|gfSX|j |7_ ||7}|jjd} |j|jj| d|jjdd|ddd|\}}|j||s|j |jd7_ ng|gfS( sOption list item.uInvalid option list marker: %ss Option listiR?R;RFt OptionListRi(Rt option_listRHRJR/RStoption_list_itemRR(RRLRRR|RRRpR>RPRN(R"RRTR}t optionlistRRiRRR~RRRRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRus4   $   c Cs|jj}|j|}|jj|j\}}}}|sg|j|tjdntj d|}tj dj |} tj d|| } |r|j |d|d| n| |fS(NRR~s R?R;(RHRPtparse_option_markerRRRNRRRt option_groupt descriptionRRRf( R"RRtoptionsR~RRRiRRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRs$    c Csg}|jjjd}x|D]}|j}d}|djdd}t|dkr{||d*d}nyt|ddkr|djdr|djd s|djd r|dd |ddg|d*d }nt|dkrI|djd rI|d jd rIdj|dg|d)ndt|kofdknrtj|}|tj |d|d7}t|dkr|tj |d|dd|7}n|j |q(t dt||fq(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, R it=iit-s--t+R~tt delimiters;wrong number of option tokens (=%s), should be 1 or 2: "%s"( RRR RYRARRRRqt option_stringtoption_argumentR]R( R"Rtoptlistt optionstringst optionstringttokensRtfirstoptRq((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRs:      %" cCs@dj|jj}|jtj||7_g|gfS(Ns (RRHtget_text_blockRLRt doctest_block(R"RRTR}R((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRvsc CsBtj}|j|7_|jj}|j||\}}}||7}|j|7_|s|jjd} |j|jj| d|jj dd|dddd\} }|j | n|s|j|j j dd |d7_nt |r5|djd kr%d|d_n|j|ng|gfS( sFirst line of a line block.iR?R;RFt LineBlockRiis%Line block ends without a blank line.RSN(RRwRLRHRtline_block_lineRRpR>RPRNR(RRYRR4tnest_line_block_lines( R"RRTR}R`RuRSRvRiRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRw&s.    c Cs|jj|jdt\}}}}dj|}|j||\}} tj|d|} |jj dkrt |j dd| _ n| | |fS(s(Return one line element of a line_block.t until_blanku R~Ri( RHRRRARRRRSRRRYRR( R"RRuR~RRRiRt text_nodesRvRS((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR@scCshxTtdt|D]=}t||dddkr||dj||_qqW|j|dS(NiR(RRYRR4Rtnest_line_block_segment(R"R`Rx((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRLscCsg|D]}|j^q}t|}g}tj}xo|D]g}|j|krf|j|qAt|r|j||j|tj}n|j|qAWt|r|j||j|n||(dS(N(RtminRRwR]RYR(R"R`titemtindentstleastt new_itemst new_block((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRRs         cCs|j||||jtjS(sTop border of a full table.(t table_toptisolate_grid_tableRtGridTableParser(R"RRTR}((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRxescCs|j||||jtjS(sTop border of a simple table.(Rtisolate_simple_tableRtSimpleTableParser(R"RRTR}((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRyksc Csq|j||\}}|j|7_|sd|jjdd|jjd}|j|7_ng|gfS(sTop border of a generic table.s Blank line required after table.RSi(ttableRLR(RRHR( R"RRTR}tisolate_functiont parser_classRRiR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRqs c Cs|\}}}|ryX|}|j|}|jjt|d}|j||} | g|} Wqtjk r} |j|dj| j d| j |} qXn|} | |fS(sParse a table.iR R( RRHRRYt build_tableRtTableMarkupErrortmalformed_tableRRR( R"RRR`RvRitparsert tabledatat tablelineRRterr((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR}s c Cs>g}d}y|jjdt}WnStjk rz}|j\}}}|j|jjdd|d|d}nX|j |j |j t |dj }xmtt |D]Y}||j ||<||ddkrd}|jjt ||||3PqqW|jj|dsd}xtt |d ddD]I}|jj||rT|jjt ||d||d3PqTqTW|j|j|g||fSnxgtt |D]S}t |||ks ||ddkr|j|j|g||fSqW|||fS( Nit flush_leftsUnexpected indentation.R/RSis+|ii(RHRRARtUnexpectedIndentationErrorRR]R(Rt disconnecttpad_double_widthtdouble_width_pad_charRYRRR{tgrid_table_top_patRtextendR( R"RvRiR`RRRtwidthR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRsB  # *cCs1|jj}|jj}t|d}t||j}|jj}d}d}|d}xq||krS||} || } | rFt| j|kr|jj|||j |||d!d} g| ||kp||dj fS|d7}|}|dks9||ks9||dj rF|} PqFn|d7}qcW|rd} |jj|||||d!}n(d} |jj||d||}|j |d| } g| | fS|jj| |||| d!}|j |j |g| |kp-|| dj fS(Niis5Bottom/header table border does not match top border.is$ or no blank line after table bottomR~sNo bottom table border found%s.( RHRR>RYRtsimple_table_border_patRR4R_RRR(R"RRtlimitttoplent pattern_matchtfoundtfound_atRRSRRvRtextraR`((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRsJ      ( - cCs|j|jddj|}d}|jjt|d}|r\|d|7}n|jj|tj ||d||}|gS(NR~s sMalformed table.iRS( treplaceRRRHRRYR(RRR(R"R`tdetailRRRt startlineR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRs cCsO|\}}}tj}|dkr=|dcdg7`?) # 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|jj\}}|jj|j\}}}}|jd}t|} tjdj|} || _ || _ | ddkr| d} d| d<| r| dj | n|j j | nf| dkrd} d| d<|j j| n7| tjd|7} | dj | |j j| | rQ|j j| | n|j j| | |r|j|d |d | n| g|fS( Nis iR)R*RR+R~R?R;(RHRJRRRRRtfootnoteRR/RSR]R'tnote_autofootnotetnote_symbol_footnoteR4t note_footnoteRRRf( R"RRRR~RRRiR4RR$((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR$Hs4$       c Cs|jj\}}|jj|j\}}}}|jd}t|} tjdj|} || _ || _ | tj d|7} | dj | |j j| |j j| | |r|j|d|d| n| g|fS(Nis R~RR?R;(RHRJRRRRRtcitationRR/RSR4R]R't note_citationRRf( R"RRRR~RRRiR4RR(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR(gs$   cCsd|jjj}|jj}|jj|jdtdt\}}}}|j |j dj |}g|D]} t | ^qu}|d} d} x_tr|j | } | rPn| d7} y| || 7} Wqt k rtdqXqW|| 4|dd| jt| dj|d<|j|||| jd} | g|fS( NRt strip_indents iismalformed hyperlink target.R R(texplicitRRRHRRRRAR7RRRRR\RRYRt make_targetR(R"RRKRuR`RRRit blocktextRSRt blockindext targetmatchR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pythyperlink_targetxs, '     0cCs|j|||\}}|dkrxtj|ddt|}||_|j|d|||jj||S|dkrtj|d}|j|||||S|SdS(NR R~R (t parse_targetRRRRt add_targetR'R(R"R`t block_textRut target_namet target_typeRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR,s   cCs|rj|djddkrjdjg|D]}|j^q-}|j|}|rjd|fSntdj|}djd|D}d|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 iRR R css*|] }djt|jVqdS(R~N(RRR (R R((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pys sR (RRt is_referenceR(R"R`R3RuRSRR t ref_parts((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR1s (   cCsJ|jjjjt|}|s(dSt|jdpF|jdS(Ntsimpletphrase(R+RRRR R4RR(R"RR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR6s cCs||_|rtt|}|dj||rp|jj|}|r]||d|jj fS( s 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. i(tconvert_directive_functiont strip_topis isError in "%s" directive: %s.R RSs+Directive "%s" must return a list of nodes.s6Directive "%s" returned non-Node object (index %s): %r(!R!RRtdocutils.parsers.rstRQRHRRRRRR>tparse_directive_blockRR(RRRRR<tdocutilstparserstrsttDirectiveErrortsystem_messageR}RtlistR=RRYtNodetis_next_line_blank(R"RKRRORNRQRutinitial_line_offsetR~RRRiR3t argumentsRtcontenttcontent_offsetR Rtdirective_instanceRtmsg_nodeR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRL%sH      cCs|j}|j}|r@|dj r@|j|d7}nx%|rg|dj rg|jqCW|r|js|js|rx4t|D]\}}|jsPqqW|d7}|| } ||d} ||d} n|} |} g} |r|j||| \} } ni} | rX|jp7|j rX| ||} |} g} nx/| r| dj r| j| d7} q[W|js|jr|j || } ng} | r| rt dn| | | | fS(Niiisno content permitted( t option_spect has_contentRt trim_startttrim_endtrequired_argumentstoptional_argumentst enumeratetparse_directive_optionstparse_directive_argumentsR(R"R~RRKRNRcRdRRSt arg_blockR_R`RR^((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRTasN            c Cs|j}xQt|D]=\}}tjtjd|r||}|| }PqqWg}|r|j||\}} |r|j| qt| n||fS(NRt( RgRiRRRERtparse_extension_optionsR!R( R"RNRcRlRRRSt opt_blocktsuccessR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRjs    cCs|j}|j}dj|}|j}t||kr^td|t|fn_t|||kr|jr|jd||d}qtd||t|fn|S(Ns s$%s argument(s) required, %s suppliedis+maximum %s argument(s) allowed, %s supplied(RgRhRR RYRtfinal_argument_whitespaceR4(R"RKRltrequiredtoptionaltarg_textR^((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRks    cCstj}|j|d|dddt\}}|t|krId Sytj||}Wntk r}dd|jdfSt t fk r}dddj |jfStj k r}dd dj |jfSX|rd |fSdSd 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. iRFtExtensionOptionsRisinvalid option blocksunknown option: "%s"sinvalid option value: %sR sinvalid option data: %sisoption data incompletely parsedN(isinvalid option block(isoption data incompletely parsed( RRRpRARYRtextract_extension_optionsRRRyRRtExtensionOptionError(R"Rct datalinesR;RRiRR ((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRms"  c Csz|jj}|jjddt\}}}}dj|}|jjd|tj||d|}|g|fS(NiR*s sUnknown directive type "%s".RS( RHRRR7RR(RRR( R"RORuR~RRRiRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRMs$ cCs|j|jj r<|jjr<tjgdfS|jj|j\}}}}x%|r|dj r|jqcWdj |}tj||g|fS(Niis ( RRRRHR\RtcommentRRfR(R"RR~RRRiR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRxs$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>|j|\}}|j|7_|j|g|gfS(s3Footnotes, hyperlink targets, directives, comments.(texplicit_constructRLt explicit_list(R"RRTR}RRi((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRz s c Csg}x|jjD]\}}|j|j}|ry|||SWqtk r}|jj}dj|j}|j |j j |d|PqXqqW|j |\} } | || fS(s>Determine which explicit construct this is, parse & return it.R RS( R+t constructsRRRRHRRRR]R(RRx( R"RterrorsRRKtexpmatchRRuRRRi((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRy s c Cs|jjd}|j|jj|d|jjdd|jddd|d|jj\}}|j||s|j|jd7_nd S( s Create a nested state machine for a series of explicit markup constructs (including anonymous hyperlink targets). iR?R;RFtExplicitRiR3sExplicit markupN( RHRRpR>RPRLR3RNR(R"RiRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRz+ s cCs>|j|\}}|j|7_|j|g|gfS(sAnonymous hyperlink targets.(tanonymous_targetRLRz(R"RRTR}RRi((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR; s c Cs|jj}|jj|jdt\}}}}|j|j dj|}g|D]}t|^q`}|j|||d} | g|fS(NRs R~( RHRRRRARRRR,( R"RRuR`RRRiR-RSR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRB s cCs|jjr|jgdgfS|jjdkrFtjdnt|jjdkr|jjdd|jj }|j |7_ tjdnX|jj }|jj dt j||d|jj }|j |7_ g|gfSdS( s,Section title overline or transition marker.tLines::RiseUnexpected possible title overline or transition. Treating it as ordinary text because it's so short.RSs'Unexpected section title or transition.N(RHR3RRRRRYR(RRRLRSRQRR(R"RRTR}RR-((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRSL s"    cCs|jgdgfS(s%Titles, definition lists, paragraphs.R-(R(R"RRTR}((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRb s( sbullets enumerators field_markers option_markersdoctests line_blocksgrid_table_topssimple_table_topsexplicit_markups anonymousslinestextN(cRRR%Rt TableParserRRRlRtkeysRRt sequencepatsRBRWRYR\RRZRRRRRRRtsimple_table_top_patRtpatsRtescapeRRRtinitial_transitionsRR|RRRRRrRRsR4RRRRtRRRRuRRRvRwRRRRxRyRRRRRRRR+RR5RR$R(R0R,R1R6R2RHRARKRLRTRjRkRmRMRxRR{RzRyRzRRRSR(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyREs,  ""(     %    ,        #    # 7  %       )        & +              D  < .   ! &     t RFC2822BodycBskeZdZejjZdedRPRNR( R"RRTR}t fieldlistRRiRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRt s    c Cs|j|jjd }|jj|jdt\}}}}tj}|tj||7}tj dj |}||7}|r|j |d|d|n||fS(NRRs R?R;( RtfindRHRRRARRRRRRf( R"RRR~RRRit fieldnodet fieldbody((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s   (srfc2822sBody( RRR%RERRgRRtinsertRR(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRg s  tSpecializedBodycBsneZdZddddZeZeZeZeZeZ 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|jjtdS(s8Not a compound element member. Abort this state machine.N(RHR{RO(R"RRTR}((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyt invalid_input s N(RRR%R4RRRrRsRtRuRvRwRxRyRzRRSR(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR sRcBseZdZdZRS(s-Second and subsequent bullet_list list_items.cCsg|jd|jdkr'|jn|j|j\}}|j|7_||_g|gfS(sBullet list item.iRr(RRLRRRRi(R"RRTR}RRi((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRr s   (RRR%Rr(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR stDefinitionListcBseZdZdZRS(s,Second and subsequent definition_list_items.cCs|jgdgfS(sDefinition lists.t Definition(R(R"RRTR}((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s(RRR%R(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR sRcBseZdZdZRS(s1Second and subsequent enumerated_list list_items.c Cs|j||jd\}}}}||jks|dkro||jdks|js||jdks|j||| r|jn|dkrd|_n|j|j\}} |j|7_| |_ ||_g|gfS(sEnumerated list item.RR)i( RRLRR*RRRRRRi( R"RRTR}RRRRRRi((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRs s      (RRR%Rs(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR sRcBseZdZdZRS(s(Second and subsequent field_list fields.cCs:|j|\}}|j|7_||_g|gfS(sField list field.(RRLRi(R"RRTR}RRi((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRt s (RRR%Rt(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR sRcBseZdZdZRS(s4Second and subsequent option_list option_list_items.cCs\y|j|\}}Wntk r6|jnX|j|7_||_g|gfS(sOption list item.(RRRRLRi(R"RRTR}RRi((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRu s  (RRR%Ru(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR sRcBs2eZdZejZejZdZejZ RS(s6Second and subsequent RFC2822-style field_list fields.cCs:|j|\}}|j|7_||_gdgfS(sRFC2822-style field list item.R(RRLRi(R"RRTR}RRi((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s ( RRR%RRRRRRR(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s    RtcBseZdZdZRS(sz Parse field_list fields for extension options. No nested parsing is done (including inline markup parsing). cCsxg}xkt|dgD]V}|jr<|j|q|rdj|}|tj||7}g}qqWdS(s5Override `Body.parse_field_body` for simpler parsing.R~s N(RZRR]RRR(R"R~RR;RRSR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR% s (RRR%R(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRt sRcBs eZdZejZdZRS(s,Second and subsequent lines of a line_block.cCsa|jj}|j||\}}}|j|7_|jj|7_||_g|gfS(sNew line of line block.(RHRRRLRi(R"RRTR}RuRSRvRi((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRw7 s  (RRR%RRRRw(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR1 s R~cBs)eZdZdZdZejZRS(s0Second and subsequent explicit markup construct.cCs:|j|\}}|j|7_||_g|gfS(s3Footnotes, hyperlink targets, directives, comments.(RyRLRi(R"RRTR}RRi((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRzE s cCs:|j|\}}|j|7_||_g|gfS(sAnonymous hyperlink targets.(RRLRi(R"RRTR}RRi((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRL s (RRR%RzRRRR(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR~A s  R<cBsVeZdZiejdejejd6dd6ZddgZ dZ dZ RS(sG Parser for the contents of a substitution_definition element. s (%s)::( +|$)tembedded_directiveR~RcCsZ|j|d|jdd\}}|j|7_|jjsP||_ntdS(NtaltRi(RKRLRHtat_eofRiRO(R"RRTR}RRi((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRb s   cCs.|jjs$|jj|_ntdS(N(RHRR\RiRO(R"RRTR}((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRj s( RRR%RRR5RRRRRR(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR<V s    R-cBseZdZiejdd6dd6ZddgZdZdZdZd Z d Z d Z d Z d Z ejdZdZRS(ss Classifier of second line of a text block. Could be a paragraph, a definition list item, or a title. RSt underlineR~RREcCs_|j||jjd\}}|j|7_|rR|j|j7_ngdgfS(sEnd of paragraph.iRE(RRHRRLR(R"RRTR}RR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR| s cCs |r|jd|dngS(N(RR4(R"RT((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyteof sc Cstj}|j|\}}||7}|j|7_|jjd}|j|jj|d|jjdd|ddd|dd\}}|j ||s|j|j d 7_ngd gfS( sDefinition list item.iR?R;RFRRiRlRsDefinition listRE( Rtdefinition_listtdefinition_list_itemRLRHRRpR>RPRNR( R"RRTR}tdefinitionlisttdefinitionlistitemRiRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s    cCs|jj}|dj}|jj}|d|}g}t|t|krt|dkr|jjr|jjdd|} |j | 7_ nt j dq|dd|jj } |jj dtj| | d|} |j| n|jjs|dd|jj } |jj\} } |jjdtj| | d | d| } |j |7_ |j | 7_ g|gfS|d} g|(|j||| |d |g|gfS( sSection title.is isfPossible title underline, too short for the title. Treating it as ordinary text because it's so short.RSRsTitle underline too short.sUnexpected section title.R/i(RHRRRRRYR3R(RRLRRRSRRRR]RJRQRw(R"RRTR}RuRsRR/RvRR-RRRt((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s<        c Cs|jjd}d}y|jjdt}WnFtjk rz}|j\}}} |jj dd|d| }nX|t |} |j | |\} } |j | 7_ |j |7_ | ry|jj Wntk rnX|j |j7_ ng|gfS(s Paragraph.iRsUnexpected indentation.R/RSN(RHRR4RRARRRR(RRZRRLR_ROR( R"RRTR}R RR`RRRRRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s& cCs|jj\}}}}x%|rB|dj rB|jqW|sS|jSdj|}tj||}|d|_|g}|s|j |j dn|S(sReturn a list of nodes.is is Literal block( RHR{RRftquoted_literal_blockRRRRSR]R(R"R~RRRiRRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s   c Cs}|jj}|jj}tj}|j|jj|d|d|dtditfd6dd6}|j ||j S(NR?R;R3RbRDtQuotedLiteralBlockRF( RHRPRRR@RfR>R7RRNtchildren(R"RPRt parent_nodeRG((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s     c Cs|jj\}}}}tjdj|t|}|jjd}|jj|\|_|_ |j ||\}} ||7}tj d| } || 7}|dddkr| |j j dd|d7} n|j|d |d | ||fS( Ns iR~iis::s`Blank line missing before literal block (after the "::")? Interpreted as a definition list item.RSR?R;(RHR{RRRRZRRJR/RSttermRR(RRf( R"ttermlineR~RRRititemnodeRuttermlistRvR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s   s +: +c Csat|dkst|j|d|\}}tj}|jj|\|_|_t |d|_ |g}xt t|D]}||}t |tj rC|jj|j } t| dkr|dc|7|jjd}|d}|j}d}y|jj}Wntk r|d|}t|jdkr|j|||dq|jj dt j ||d|} |j | 7_ gd gfSnXd |||f} |j}|j}|j d dj|s|d|d|}t|jdkra|j|||dq@|jj d t j | | d|} |j | 7_ gd gfSn||kr@|d|d|}t|jdkr|j|||dq@|jj d t j | | d|} |j | 7_ gd gfSn|j}g} t|t|kr|d|d|}t|jdkr|j|||dq|jjdt j | | d|} | j| n|d|df} d|_|j|j| | |d| d|_gd gfS(s#Potential over- & underlined title.iiR~s iisIncomplete section title.RSREs%s %s %sRs6Missing matching underline for section title overline.s$Title overline & underline mismatch.sTitle overline too short.(RHRRR_RORYRtshort_overlineR(RQRRRLRURRRR]RRwR( R"RRTR}RutoverlineRsRR-RR/RvRt((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRr sn                # cCs|d}|d|jj}|jjd}t|jdkrb|j|||dn|jjdtj ||d|}|j |7_ gdgfS(Nis iis+Invalid section title or transition marker.RSRE( RHRSRRYRRR(RRRRL(R"RRTR}RR-RuR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s   cCs;|jjdd|}|j|7_|j||dS(Ns`Possible incomplete section title. Treating the overline as ordinary text because it's so short.RS(R(RRLR(R"RTR-RuRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s   cCs-|jj|g|(tjdddS(NRER(RHR{RtStateCorrection(R"RTR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s( RRR%RRRRRRRR(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyRN s  > RcBsqeZdZidejd6dd6Zd ZedZdZ dZ dZ d Z d Z d ZRS( s Nested parse handler for quoted (unindented) literal blocks. Special-purpose. Not for inclusion in `state_classes`. s(%(nonalphanum7bit)s)tinitial_quotedR~RcCs)tj|||g|_d|_dS(N(RCR$RvR4tinitial_lineno(R"RHRI((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR$ s cCs |rtn ||gfSdS(N(RO(R"RRTR}((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s cCs|rf|jj|j\}}dj|}tj||}||_||_|j|7_n7|j|j j dd|jj 7_|jj |j|j 7_gS(Ns s#Literal block expected; none found.RS(RHRJRRRRR/RSRLR(RRR{Rv(R"RTRRRR((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s    cCsT|std|jj|jjdd|jj|jjtdS(Ns7QuotedLiteralBlock.indent: context should not be empty!sUnexpected indentation.RS( R=RvR]R(RRHRR{RO(R"RRTR}((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s   cCs|jd|jd}tjtj|tj}|jd||j|jj f|j j |_ |jg|gfS(s7Match arbitrary quote character on the first line only.Ritquoted( tremove_transitionRRRRRtadd_transitionRRRRRHRR(R"RRTR}tquoteRK((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s   cCs|j|j||gfS(s,Match consistent quotes on subsequent lines.(R]R(R"RRTR}((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR scCsK|rA|jj|jjdd|jj|jjntdS(Ns#Inconsistent literal block quoting.RS(RvR]R(RRHRR{RO(R"RRTR}((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s  (sinitial_quotedstext(RRR%RERRRR7R$RRRRRR(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pyR s     (HR%t __docformat__tsysRttypesRRRURRRRRtdocutils.statemachineRR tdocutils.nodesR RR RSR R RRtdocutils.parsers.rst.languagesRt_fallback_language_moduletdocutils.utilsRRRRRRRRRRRt ExceptionRRR&RBRCRARR5RTRWRYR\RERRRRRRRRRtRR~R<R-RRRRRD(((s?/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/states.pytest   "' J N.,  K