403Webshell
Server IP : 127.0.0.1  /  Your IP : 216.73.216.109
Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64
User : SERVERWEB ( 0)
PHP Version : 8.1.10
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : OFF |  Perl : OFF |  Python : OFF |  Sudo : OFF |  Pkexec : OFF
Directory :  C:/cygwin64/lib/python3.9/site-packages/docutils/parsers/rst/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : C:/cygwin64/lib/python3.9/site-packages/docutils/parsers/rst/__pycache__/states.cpython-39.pyc
a

OԼa��@s�dZdZddlZddlZddlmZmZddlmZm	Z	m
Z
ddlmZmZddl
mZmZddlmZdd	lmZddlZdd
lmZmZmZmZddlmZdd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�de*�Z+Gdd�de�Z,Gdd�de�Z-Gdd �d e�Z.dSd"d#�Z/Gd$d%�d%e*�Z0e1d&�d'fd(d)�Z2e1d*�d'fd+d,�Z3d-d.�Z4Gd/d0�d0e.�Z5Gd1d2�d2e5�Z6Gd3d4�d4e5�Z7Gd5d6�d6e7�Z8Gd7d8�d8e7�Z9Gd9d:�d:e7�Z:Gd;d<�d<e7�Z;Gd=d>�d>e7�Z<Gd?d@�d@e7e6�Z=GdAdB�dBe;�Z>GdCdD�dDe7�Z?GdEdF�dFe7�Z@GdGdH�dHe5�ZAGdIdJ�dJe.�ZBGdKdL�dLeB�ZCGdMdN�dNeC�ZDGdOdP�dPeC�ZEGdQdR�dRe.�ZFe5e8e9e:e;e<e?e>e@eBeDeEeAe6e=fZGdS)Ta�
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.
ZreStructuredText�N)�FunctionType�
MethodType)�nodes�statemachine�utils)�ApplicationError�	DataError)�StateMachineWS�StateWS)�fully_normalize_name)�whitespace_normalize_name)�
directives�	languages�tableparser�roles)�en)�escape2null�unescape�column_width)�punctuation_chars�roman�
urischemes)�split_escaped_whitespacec@seZdZdS)�MarkupErrorN��__name__�
__module__�__qualname__�rr�?/usr/lib/python3.9/site-packages/docutils/parsers/rst/states.pyrz�rc@seZdZdS)�UnknownInterpretedRoleErrorNrrrrrr!{r r!c@seZdZdS)�"InterpretedRoleNotImplementedErrorNrrrrrr"|r r"c@seZdZdS)�ParserErrorNrrrrrr#}r r#c@seZdZdS)�MarkupMismatchNrrrrrr$~r r$c@seZdZdZdd�ZdS)�Structz3Stores data attributes for dotted-attribute access.cKs|j�|�dS�N)�__dict__�update)�selfZkeywordargsrrr�__init__�szStruct.__init__N)rrr�__doc__r*rrrrr%�sr%c@seZdZdZddd�ZdS)�RSTStateMachinezy
    reStructuredText's master StateMachine.

    The entry point to reStructuredText parsing is the `run()` method.
    rTNc	Cs�t�|jj|j�|_||_|dur(t�}|�|j�t	||j|jgdd|d�|_
||_|�|j
�|j
j|_||_tj||||dd�}|gks�Jd��d|_|_
dS)z�
        Parse `input_lines` and modify the `document` node in place.

        Extend `StateMachineWS.run()`: set up parse-global data and
        run the StateMachine.
        NrF)�document�reporter�language�title_styles�
section_level�section_bubble_up_kludge�inliner�source)Zinput_sourcez.RSTStateMachine.run() results should be empty!)rZget_language�settingsZ
language_coder.r/�match_titles�Inliner�init_customizationsr%�memor-�attach_observer�note_source�noder	�run)r)�input_linesr-�input_offsetr6r3�resultsrrrr=�s0
��

�zRSTStateMachine.run)rTN�rrrr+r=rrrrr,�s�r,c@seZdZdZddd�ZdS)�NestedStateMachinezh
    StateMachine run from within other StateMachine runs, to parse nested
    document structures.
    TcCsZ||_||_|j|_|�|jj�|j|_|j|_||_t�	|||�}|gksVJd��|S)z�
        Parse `input_lines` and populate a `docutils.nodes.document` instance.

        Extend `StateMachineWS.run()`: set up document-wide data.
        z1NestedStateMachine.run() results should be empty!)
r6r9r-r:r;r.r/r<r	r=)r)r>r?r9r<r6r@rrrr=�szNestedStateMachine.runN)TrArrrrrB�srBc@s�eZdZdZeZgZd dd�Zdd�Zdd�Z	d	d
�Z
dd�Zd!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_initrJr9r.r3r-r<�parent�hasattrrL)r)r9rrrrM�s

zRSTState.runtime_initcCs(z|j�|�Wnty"Yn0dS)zT
        Jump to input line `abs_line_offset`, ignoring jumps past the end.
        N)rJ�	goto_line�EOFError)r)�abs_line_offsetrrrrP�szRSTState.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.bofNcCs�d}|dur|j}|d7}|dur0|j}|d7}t|�}d}	|dkrfz|j��}	WntydYn0|	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�r9r<r6)�	nested_smrH�len�nested_sm_cache�pop�
IndexErrorrKr=r9�append�unlinkrRrNrJ�	next_line)r)�blockr?r<r6�state_machine_class�state_machine_kwargsZuse_defaultZblock_lengthrJZ
new_offsetrrr�nested_parses8��zRSTState.nested_parsecCs�|	dur|j}	|
dur |j��}
||
d<|	fd|ji|
��}|durH|}||j|_|��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�items�setattrr=r9rdrR)r)rfr?r<rGrk�blank_finish_state�extra_settingsr6rgrhrJ�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)�titler4�style�lineno�messagesrrr�sectionDszRSTState.sectionc	Cs�|j}|j}|j}z|�|�d}WnLtypt|�|jkrP|�|�YdS|j|�||�7_YdSYn0||kr�||_t|�dkr�d|_	|j
�t|�d�t�||dkr�dS|j|�||�7_dSdS)a�
        Check for a valid subsection header.  Return True or 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[TFr\N)
r9r0r1�index�
ValueErrorr_rcrN�title_inconsistentr2rJ�
previous_linerQ)r)r4rvrwr9r0�mylevel�levelrrrrsIs*
zRSTState.check_subsectioncCs|jjdt�d|�|d�}|S)NzTitle level inconsistent:��rU)r.rSr�
literal_block)r)Z
sourcetextrw�errorrrrr|rs
�zRSTState.title_inconsistentcCs�|j}|j}|jd7_t��}|j|7_|�||�\}}tj|dg|�R�}	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<r6)r9r1rryrN�inline_textru�normalize_name�astextrcr-Znote_implicit_targetrJ�line_offsetrRrir>rPrQ)r)rurwrxr9r~Zsection_node�	textnodesZtitle_messagesZ	titlenode�name�offsetZ	absoffsetZnewabsoffsetrrrrtxs.�

zRSTState.new_subsectionc	Cs�d�|���}t�d|�r^t|�dkr.gdfS|ddvrL|dd���}n|dd�}d}n|}d	}|�||�\}}tj|d
g|�R�}|j�	|�\|_
|_|g||fS)zW
        Return a list (paragraph & messages) & a boolean: literal_block next?
        �
z(?<!\\)(\\\\)*::$r\r[���z 
N���rr�)�join�rstrip�re�searchr_r�r�	paragraphrJrLr4rU)	r)�linesrw�data�text�literalnextr�rx�prrrr��szRSTState.paragraphcCs"|j�|||j|j�\}}||fS)zX
        Return 2 lists: nodes (text and inline elements), and system_messages.
        )r3�parser9rN)r)r�rwrrxrrrr��s
�zRSTState.inline_textcCs"|j��d}|jjd||d�S)Nr[z2%s ends without a blank line; unexpected unindent.r�)rJ�abs_line_numberr.�warning)r)Z	node_namerwrrr�unindent_warning�s��zRSTState.unindent_warning)F)FNN)rrrr+rBr^r`r*rMrPrXrZrirrryrsr|rtr�r�r�rrrrrC�s0

	
�
'�
)rCTc
Csn|\}}}}g}|D]*}t|t�r4|�t|d��q|�|�qd�|�}dt�}	|rft�|	tj�S|	SdS)a!
    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.
    N�|z.%(prefix)s(?P<%(name)s>%(or_group)s)%(suffix)s)	�
isinstance�tuplerc�build_regexpr��localsr��compile�UNICODE)
�
definitionr�r��prefix�suffix�parts�part_strings�partZor_groupZregexprrrr��s


r�c
@seZdZdZdd�Zdd�Zdd�ZdZd	Zd
Z	dZ
dZd
ZdZ
dZde�ZdZdZdd�Zd=dd�Zdd�Zdd�Zdd�Zdd�Zd>d!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd?d/d0�Z d1d2�Z!d3d4�Z"d5d6�Z#d7Z$d8d9�Z%d:d;�Z&eeeeeeee e!d<�	Z'd S)@r7z9
    Parse inline markup; call the `parse()` method.
    cCs
g|_dSr&)�implicit_dispatch)r)rrrr*�szInliner.__init__cCs.t|dd�rd}d}n$dtjtjf}dtjtjtjf}t���}|�t	|j
��d|ddd|jgd	�fd
d|d|jdd
ddd|jdd|jgfgfdd|j|jdgfgf}||_
||_||_tt|�t�|jd|tj�t�|jd|tj�t�d|tjtjB�t�d|tjtjB�t�|jd|tj�t�|jd|tj�t�|jd|tj�t�|j|dtjtjB�t�d|jd|tjtjB�t�d |tjtjB�t�d!|tjtjB�d"�|_|j�|jj|jf�|j�r|j�|jj|j f�|j!�r*|j�|jj"|j#f�dS)#NZcharacter_level_inline_markupFz
(^|(?<!))r�z(^|(?<=\s|[%s%s]))z($|(?=\s|[%s%s%s]))Zinitial_inline�start)z\*\*z\*(?!\*)�``�_`z\|(?!\|)�wholez(?P<refname>%s)(?P<refend>__?)�
footnotelabelz\[z(?P<fnend>\]_)�[0-9]+z\#(%s)?z\*z(?P<citationlabel>%s)�	backquotez(?P<role>(:%s:)?)z`(?!`)z(\*)z(\*\*)a
              %(non_unescaped_whitespace_escape_before)s
              (
                `
                (?P<suffix>
                  (?P<role>:%(simplename)s:)?
                  (?P<refend>__?)?
                )
              )
              %(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<whole>
                  (?P<absolute>           # absolute URI
                    (?P<scheme>             # 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>              # email address
                    z]
                  )
                )
                %(end_string_suffix)s
                a
                %(start_string_prefix)s
                (
                  (pep-(?P<pepnum1>\d+)(.txt)?) # reference to source file
                |
                  (PEP\s+(?P<pepnum2>\d+))      # reference by name
                )
                %(end_string_suffix)sz{
                %(start_string_prefix)s
                (RFC(-|\s+)?(?P<rfcnum>\d+))
                %(end_string_suffix)s)�initial�emphasis�strong�interpreted_or_phrase_ref�
embedded_link�literal�target�substitution_ref�email�uri�pep�rfc)$�getattrrZopenersZ
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)r5r�r��argsr�rrrr8�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.

        :text: source string
        :lineno: absolute line number (cf. statemachine.get_source_and_line())
        r�r��refendZfnendr�)
r.r-r/rNr�r�r��dispatchr�	groupdictrc�implicit_inliner�)r)r�rwr9rNZpattern_searchr��	remainingZ	processedZunprocessedrx�match�groups�method�before�inlines�sysmessagesrrrr�fsF
���
�z
Inliner.parsez(?<!\s)z
(?<![\s\x00])z(?<!(?<!\x00)[\s\x00])z(?!\s)z$(?:(?!_)\w)+(?:[-._+:](?:(?!_)\w)+)*z%[-_.!~*'()[\];/:@&=+$,%a-zA-Z0-9\x00]z[>]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
          (?<!\x00)@                      # at
          %(emailc)s+(?:\.%(emailc)s*)*   # host
          %(uri_end)s                     # final URI char
          cCsX|j}|��}|dkrdS||d}z||��}WntyJYdS0t�||�S)z�Test if inline markup start-string is 'quoted'.

        'Quoted' in this context means the start-string is enclosed in a pair
        of matching opening/closing delimiters (not necessarily quotes)
        or at the end of the match.
        rFr[T)�stringr��endrbrZmatch_chars)r)r�r�r�ZprestartZ	poststartrrr�quoted_start�szInliner.quoted_startFcCs,|j}|�d�}|�d�}|�|�rB|d|�g||d�gdfS|�||d��}	|	r�|	�d�r�|	jd|	�d��}
|r�t|
d�}
||	�d�}t|||�d�}|||
�}
|d|�|
g||d�g|	�d�fS|jjd|j	|d�}t|||�d�}
|�
|
|
|�}|d|�|g||d�|gdfS)Nr�r�r[Tz*Inline %s start-string without end-string.r�)r�r�r�r�r�r�groupr.r�r�problematic)r)r�rw�end_patternZ	nodeclass�restore_backslashesr��
matchstart�matchend�endmatchr��textend�	rawsourcer<�msg�prbrrr�
inline_obj�s2




���zInliner.inline_objcCs:|j�||j�}tj|||d�}|j�|�}|�|�|S)N)Zrefid)r-�set_idrNrr�Zadd_backref)r)r�r��messageZmsgidr�Zprbidrrrr��s

zInliner.problematiccCs,|�|||jjtj�\}}}}}||||fSr&)r�r�r�r�r)r�rwr�r�r�r��	endstringrrrr��s�zInliner.emphasiscCs,|�|||jjtj�\}}}}}||||fSr&)r�r�r�rr�rrrr��s�zInliner.strongcCsb|jj}|j}|�d�}|�d�}|�d�}|�d�}d}	|rP|dd�}d}	n&|�|�rv|d|�g||d�gfS|�||d��}
|
�r|
�d��r||
��}|
�d��r|�r|jj	d|d�}t
|||�d	�}
|�|
|
|�}|d|�|g||d�|gfS|
�d
�dd�}d
}	|
jd|
�d��}t
|||�d	�}|dd�dk�r�|�r�|jj	d|	|d�}t
|||�d	�}
|�|
|
|�}|d|�|g||d�|gfS|�|d|�||d�||�St
|||�d	�}|�
||||�\}}|d|�|||d�|fS|jj	d
|d�}t
|||�d	�}
|�|
|
|�}|d|�|g||d�|gfS)Nr��roler�r[r�r�zVMultiple roles in interpreted text (both prefix and suffix present; only one allowed).r�Tr��_z=Mismatch: both interpreted text role %s and reference suffix.zLInline interpreted text or phrase reference start-string without end-string.)r�r�r�r�r�r�r�r�r.r�rr��
phrase_ref�interpreted)r)r�rwr�r�r�r�Z	rolestartr�Zpositionr�r�r�r�r��escapedr��nodelistrxrrrr��sp




� �� �
���z!Inliner.interpreted_or_phrase_refNcCsp|jj�|�}|�rJ|d|�d��}t|�}t|d�}|�d�}	t|	d�}
|
�d�}|	�d�r�|s�|jj�|	�s�d}t	t|	dd���}
t
j|�d�|
d	�}tt|	dd���|_
njd
}t|�d��}d�dd
�|D��}
|�t|
��}
|
�d��r|
dd�d}
t
j|�d�|
d�}d|_|	�s2td|	��|�sd|
}t|�}|
}n|}t|�}d}t|d�}t	|�}t
j||t|�d�}||d_|g}|dd�dk�r�|�r�|dk�r�|
|d<|j�|�n"|�r�|d
k�r�|
|d<nd|d<nx|�rP|d�|�|dk�r,|
|d<|j�|�|j�|�n|
|d<|j�||j�|�|�n||d<|j�|�|||gfS)NrTr\z\_r�r�r�r[��refnamer�� css|]}d�|���VqdS�r�N)r��split��.0r�rrr�	<genexpr>8s�z%Inliner.phrase_ref.<locals>.<genexpr>�����refurizproblem with embedded link: %r�r��__r�r��	anonymousr�)r�r�r�r�rr��endswithr�r�r�rr�r�indirect_reference_namerr��
adjust_uriZ
referencedr�	referencer�r-�note_refnamerc�note_indirect_target�note_explicit_targetrN)r)r�Zafterr�r�r�r�Z	unescapedZrawtextZ	aliastextZrawaliastextZunderscore_escapedZ	aliastype�aliasr�Zalias_partsr�r�	node_listrrrr�#s�



��
��
�



zInliner.phrase_refcCs"|jj�|�}|rd|S|SdS)N�mailto:)r�r�r�)r)r�r�rrrrnszInliner.adjust_uric
Csnt�||j||j�\}}|r<||||||�\}}|||fS|jjd||d�}	|�|||	�g||	gfSdS)Nz#Unknown interpreted text role "%s".r�)rr�r/r.r�r�)
r)r�r�r�rwZrole_fnrxrZ	messages2r�rrrr�us���zInliner.interpretedcCs0|j|||jjtjdd�\}}}}}||||fS)NT)r�)r�r�r�rr�rrrr��s
�zInliner.literalc
Cs�|�|||jjtj�\}}}}}|rvt|dtj�rvt|�dksDJ�|d}t|���}	|d�|	�|j	�
||j�||||fS)Nrr[r�)r�r�r�rr�r_r�r�rcr-rrN)
r)r�rwr�r�r�r�r�r�r�rrr�inline_internal_target�s�zInliner.inline_internal_targetcCs�|�|||jjtj�\}}}}}t|�dkr�|d}t|tj�r�|��}	|j�	||	�|dd�dkr�t�
d|	|fd�}
|dd�dkr�d|
d	<nt|	�|
d
<|j�|
�|
|7}
|
g}||||fS)Nr[rr�r�z|%s%sr�r�r�r�r�)
r�r�r�r�substitution_referencer_r�r�r-Znote_substitution_refrr�r)r)r�rwr�r�r�r�r�Zsubref_nodeZsubref_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|dkr�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�*r�r�)r�r�r�r�r�rZcitation_reference�Textr-Znote_citation_ref�footnote_referenceZnote_autofootnote_refZnote_symbol_footnote_refZnote_footnote_refrZget_trim_footnote_ref_spacer5r�)	r)r�rw�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�r�rr[r�r�)r�r�rrrr�r-rr�r�r�)
r)r�rwr�Z
referencenamer�Z
referencenoder�r�r�rrrr�s
�



zInliner.referencecCs|j||dd�S)Nr[)r�)r)r)r�rwrrr�anonymous_reference�szInliner.anonymous_referencecCsl|�d�r|�d���tjvrd|�d�r.d}nd}|�d�}|t|�}tjt|d�||d�}|gSt�dS)N�schemer�r	r�r�Tr�)r��lowerrZschemesrrrr$)r)r�rwZ	addschemer�r�rrrrr��s
�

�zInliner.standalone_uricCsz|�d�}|�d�r(tt|�d���}n"|�d�rFtt|�d���}nt�|jjj|jjj|}t	j
t|d�||d�gS)Nrzpep-Zpepnum1ZPEPZpepnum2Tr�)r��
startswith�intrr$r-r5Zpep_base_urlZpep_file_url_templaterr)r)r�rwr�Zpepnum�refrrrr��s


�zInliner.pep_referencez
rfc%d.htmlcCsX|�d�}|�d�r<tt|�d���}|jjj|j|}nt�t	j
t|d�||d�gS)NrZRFC�rfcnumTr�)r�rrrr-r5Zrfc_base_url�rfc_urlr$rr)r)r�rwr�rrrrrr��s

zInliner.rfc_referencec	Cs�|sgS|jD]j\}}|�|�}|rz@|�|d|���|�|||�|�||��d�|�WStyvYq0qt�|�gS)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.
        N)r�r�r�r�r�r$rr)r)r�rw�patternr�r�rrrr�s
��
zInliner.implicit_inline)	rz**�`r�r�z]_r�r�r�)F)N)F)(rrrr+r*r8r�r�r�Z&non_unescaped_whitespace_escape_beforer�r�ZuricZ
uri_end_delimZurilastr�Zuri_endZemailcr�r�r�r�r�r�r�r�rr�r�r
rrrrr�r�rr�r�r�rrrrr7�s^6
�
4
K
#
	�r7�ar[cCst|�|Sr&��ord��sZ_zerorrr�_loweralpha_to_int&sr!�AcCst|�|Sr&rrrrr�_upperalpha_to_int)sr#cCst�|���Sr&)r�	fromRoman�upper)r rrr�_lowerroman_to_int,sr&c
@speZdZdZejjZe�Zeddddd�eddddd�edd	ddd�d
�e_	ej	�
�e_gd�e_dd
dddd�e_
eeeeejd�e_ie_ejD]"Ze�ej
edej�eje<q�e�d�Ze�d�Ze�d�ZiZded<ded<ded<ded<dej
ed<deed <d!eed"<d#eed$<d%eed&<d'eed(<ejD]:Zd)ee�ej	ej �ede�ej	ej!�fee<�qJd*d+ed,d-ed.d/eed0d1d2edd3�Z"d3Z#d4d5�Z$d6d7�Z%e�d8ej�Z&d9d:�Z'd;d<�Z(d=d>�Z)d?d@�Z*dAdB�Z+dCdD�Z,d�dFdG�Z-dHdI�Z.dJdK�Z/dLdM�Z0dNdO�Z1dPdQ�Z2dRdS�Z3dTdU�Z4dVdW�Z5dXdY�Z6dZd[�Z7d\d]�Z8d^d_�Z9d`da�Z:dbdc�Z;ddde�Z<dfdg�Z=dhdi�Z>djdk�Z?dldm�Z@dndo�ZAd�dpdq�ZBd�drds�ZCdtdu�ZDe�ZEee�dveFeG�ejHejB�e�dweFeG�ejHejB�e�dxeFeG�ejHejB�dy�eE_"dzd{�ZId|d}�ZJd~d�ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWd�d��ZXd�d��ZYeIe�d�eGjZejHejB�feJe�d�eGjZejHejB�feKe�d�ejHejB�fePe�d�ejHejB�feRe�d�eGjZejHejB�fgeE_[d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��ZbdES)�rDz:
    Generic classifier of the first line of a block.
    �(�)r[r�)r�r�r�r�r�r�.)ZparensZrparenZperiod)�arabicZ
loweralphaZ
upperalpha�
lowerroman�
upperromanr�z[a-z]z[A-Z]z
[ivxlcdm]+z
[IVXLCDM]+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*Zoptnamez%(%(alpha)s%(alphanumplus)s*|<[^<>]+>)Zoptargz!(-|\+)%(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"%(option)s(, %(option)s)*(  +| ?$)z	>>>( +|$)z\|( +|$)z
\.\.( +|$)z__( +|$)z(%(nonalphanum7bit)s)\1* *$)�bullet�
enumerator�field_marker�
option_marker�doctest�
line_block�grid_table_top�simple_table_top�explicit_markupr�rUr�c	CsN|j��\}}}}|�||�}|j|7_|sD|j|�d�7_||gfS)zBlock quote.zBlock quote)rJ�get_indented�block_quoterNr�)	r)r�rV�
next_state�indented�indentr�rk�elementsrrrr=�s�
zBody.indentcCs�g}|r�tjd�|�d�}|j�|d�\|_|_|�||�\}}}}}|�|||�|�	|�|r�|�
|||�\}	}
||	7}||
7}|}|r|ds|dd�}|d7}q�q|S)Nr��r�r[r)rr:r�rJrLr4rU�split_attributionrirc�parse_attribution)r)r<r�r>Z
blockquoteZblockquote_linesZattribution_linesZattribution_offset�new_line_offset�attributionrxrrrr:�s0�

�
�zBody.block_quoteu(---?(?!-)|—) *(?=[^ \n])cCs�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, attribution lines,
        attribution offset, remaining indented lines, remaining lines offset).
        NFr[)r�)r�T)�ranger_r��attribution_patternr��check_attributionZ	trim_leftr�)r)r<r��blankZ
nonblank_seen�irUr�Zattribution_endr=Za_linesrrrr@�s,��zBody.split_attributioncCs�d}|d}t|dt|��D]T}||��}|s6q||durTt|�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)rDr_r��lstrip)r)r<Zattribution_startr=rHrUrrrrF�szBody.check_attributioncCsVd�|���}d|}|�||�\}}tj|dg|�R�}|j�|�\|_|_||fS)Nr�r[r�)	r�r�r�rrCrJrLr4rU)r)r<r�r�rwr�rxr<rrrrA�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.rr0r[N�
BulletList�r?r<rGrkzBullet list)rZbullet_listrJrLr4rUrNr��	list_itemr�r�rrr>rRrPr�)	r)r�rVr;Z
bulletlistrHrkr�rBrrrr0�s&��

zBody.bulletcCsd|jj|d�r$|j�|�\}}}n|j�|�\}}}}t�d�|��}|r\|j|||d�||fS)Nr��r?r<)rJrUZget_known_indented�get_first_known_indentedrrMr�ri)r)r=r<r�rk�listitemrrrrMs
�

�
�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�rr*�enumtyper�r�r[r�z<Enumerated list start value not ordinal-1: "%s" (ordinal %s)N�EnumeratedList)�lastordinal�formatr
)r?r<rGrkrozEnumerated list)�parse_enumerator�is_enumerated_list_itemr�TransitionCorrectionrZenumerated_listrNr.�
formatinfor�r�r.�inforMr�rJr�rrr>rRrPr�)r)r�rVr;rT�sequencer��ordinalZenumlistr�rPrkr��newline_offsetrrrr1sF

����

zBody.enumeratorNcCs4|��}d}|jjD]}||rq.qtd��|||jj|j|jj|j�}|dkr`d}nZ|r�z|jj|�|�r||}Wq�t	y�td|��Yq�0n|dkr�d}n|dkr�d}|s�|jj
D]}|jj|�|�r�q�q�td	��|dkr�d
}n0z|jj||�}Wntj
�y&d}Yn0||||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.
        r�zenumerator format not matchedrzunknown enumerator sequence: %srHr+�Ir,zenumerator sequence not matchedr[N)r�r.�formatsr#rXr�r��sequenceregexpsr��KeyError�	sequences�
convertersrZInvalidRomanNumeralError)r)r�Zexpected_sequencer�rZrTr�r[rrrrU5sF��
zBody.parse_enumeratorcCs�|durdSz|j��}Wnty8|j��YdS0|j��|dd���sXdS|�|d||�}|r�|\}}z|�|�s�|�|�r�WdSWnty�Yn0dS)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)r[rZrTre�result�next_enumerator�auto_enumeratorrrrrVls*


�
zBody.is_enumerated_list_itemcCs�|dkrd}n�|dkr t|�}n�|�d�rL|dkr6dSt|td�d�}n>|�d�r~zt�|�}Wq�tjyzYdS0ntd	|��|�d
�r�|�	�}n |�d�r�|�
�}ntd	|��|jj|}|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.
        rr*r-�Nrr[rz!unknown enumerator sequence: "%s"rr%r�)�strr�chrrrZtoRomanZ
RomanErrorr#rrr%r.rXr�r�)r)r[rZrTr1rXrgrhrrrrd�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�	FieldListrLz
Field list)r�
field_listrN�fieldrJr�rrr>rRrPr�)	r)r�rVr;rmrnrkr�r\rrrr2�s�

zBody.field_markercCs�|�|�}|j��\}}|j��}|j�|���\}}}}	t��}
||
_||
_	|�
||�\}}|
tj|dg|�R�7}
tjd�
|�g|�R�}
|
|
7}
|r�|�|||
�|
|	fS)Nr�r�)�parse_field_markerrJrLr�rOr�rrnr4rUr��
field_name�
field_bodyr��parse_field_body)r)r�r��src�srclinerwr<r=r�rkZ
field_nodeZ
name_nodesZ
name_messagesrqrrrrn�s

�
z
Body.fieldcCs&|��dd�}|d|�d��}|S)z6Extract & return field name from a field marker match.r[N�:)r��rfind)r)r�rnrrrro�szBody.parse_field_markercCs|j|||d�dS)NrN)ri)r)r<r�r<rrrrr�szBody.parse_field_bodyc
CsBt��}|j��\|_|_z|�|�\}}Wn�ty�}z~|j�	d|�}|j
|7_
|j�|���\}	}
}}|�
|	|�}|j
|7_
|s�|j
|�d�7_
g|gfWYd}~Sd}~00|j
|7_
||7}|jjd}
|j|jj|
d�|j��d|d|d�\}}|�|�|�s8|j
|�d�7_
g|gfS)�Option list item.zInvalid option list marker: %szOption listNr[�
OptionListrL)rZoption_listrJrLr4rU�option_list_itemrr.r�rNrOr�r:r�r�rrr>rRrP)r)r�rVr;Z
optionlistrPrkr�r�r<r=r�r>r�r\rrrr3�s:��
 �

zBody.option_markercCs�|j��}|�|�}|j�|���\}}}}|sD|�|�t�d��tj	dg|�R�}t�
d�|��}	t�d||	�}
|r�|j
|||	d�|
|fS)Nr�r�r�rN)rJrR�parse_option_markerrOr�rPrrWr�option_group�descriptionr�ryri)r)r�r��optionsr<r=r�rkr{r|ryrrrry�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|�dk�r
|d�d��r
|d
�d��r
d�|dd��g|dd�<dt|�k�r&dk�r�nnXt�|�}|t�	|d|d�7}t|�dk�rv|tj
|d|d|d�7}|�|�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��<r��>)�	delimiterz;wrong number of option tokens (=%s), should be 1 or 2: "%s")
r�r�r�r_rrr�rr/�
option_stringZoption_argumentrcr)	r)r�ZoptlistZ
optionstringsZoptionstring�tokensr�Zfirstoptr/rrrrz	sH
���(� 
�
��zBody.parse_option_markercCs0d�|j���}|jt�||�7_g|gfS)Nr�)r�rJ�get_text_blockrNrZ
doctest_block)r)r�rVr;r�rrrr42szBody.doctestcCs�t��}|j|7_|j��}|�||�\}}}||7}|j|7_|s�|jjd}	|j|jj|	d�|j�	�d|ddd�\}
}|�
|
�|s�|j|jjd|dd�7_t
|�r�|djdur�d|d_|�|�g|gfS)zFirst line of a line block.r[N�	LineBlockrrLz%Line block ends without a blank line.r�)rr5rNrJr��line_block_liner�rrr>rRrPr.r�r_r=�nest_line_block_lines)r)r�rVr;rfrwrUrxrkr�rBrrrr5:s2
�

�


zBody.line_blockcCsv|jj|��dd�\}}}}d�|�}|�||�\}}	tj|dg|�R�}
|j��dkrlt	|�
d��d|
_|
|	|fS)z(Return one line element of a line_block.T��until_blankr�r�r�r[)rJrOr�r�r�rrUr�r�r_r�r=)r)r�rwr<r=r�rkr��
text_nodesrxrUrrrr�Ts��

zBody.line_block_linecCsJtdt|��D],}t||dd�dur||dj||_q|�|�dS)Nr[r=)rDr_r�r=�nest_line_block_segment)r)rfrzrrrr�`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)r=)r��itemrrr�
<listcomp>gr z0Body.nest_line_block_segment.<locals>.<listcomp>)�minrr5r=rcr_r�)r)rf�indentsZleastZ	new_itemsZ	new_blockr�rrrr�fs 




zBody.nest_line_block_segmentcCs|�||||jtj�S)zTop border of a full table.)�	table_top�isolate_grid_tablerZGridTableParser�r)r�rVr;rrrr6ys
�zBody.grid_table_topcCs|�||||jtj�S)zTop border of a simple table.)r��isolate_simple_tablerZSimpleTableParserr�rrrr7s
�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�rVr;�isolate_function�parser_classr�rkr�rrrr��s�zBody.table_topc
Cs�|�\}}}|r�z@|�}|�|�}|j��t|�d}|�||�}	|	g|}
Wq�tjy�}z*|j|d�|j	�|j
d�|}
WYd}~q�d}~00n|}
|
|fS)zParse a table.r[r�)r�N)r�rJr�r_�build_tablerZTableMarkupError�malformed_tabler�r�r�)r)r�r�rfrxrk�parser�	tabledata�	tableliner�r��errrrrr��s$
���z
Body.tablec	
Cs�g}d}z|jjdd�}WnNtjyh}z4|j\}}}|�|jjd||d��d}WYd}~n
d}~00|��|�	|j
�t|d���}t
t|��D]J}||��||<||ddvr�d}|j�t|�|�||d�=q�q�|j�|d��spd}t
t|�d	dd�D]D}|j�||��r|j�t|�|d�||dd�=�qp�q|�|�|��g||fSt
t|��D]H}t||�|k�s�||ddv�r||�|�|��g||fS�q||||fS)
Nr[T�Z
flush_left�Unexpected indentation.�r4rUrz+|r�r\)rJr�r�UnexpectedIndentationErrorr�rcr.r��
disconnect�pad_double_width�double_width_pad_charr_rcrDr}�grid_table_top_patr��extendr�)	r)rxrkrfr�rsrt�widthrHrrrr��sD�


$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||k�p�||d��fS)Nr[rz5Bottom/header table border does not match top border.r\z$ or no blank line after table bottomr�zNo bottom table border found%s.)rJr�r>r_rc�simple_table_border_patr�rer�r�r�)r)r�r��limitZtoplenZ
pattern_match�foundZfound_atrHrUr�rxr�Zextrarfrrrr��sN�  
�zBody.isolate_simple_tablecCsf|�|jd�d�|�}d}|j��t|�d}|rB|d|7}|jj|t�	||�||d�}|gS)Nr�r�zMalformed table.r[r�)
�replacer�r�rJr�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)Zcols)�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_tablecCs~t��}|D]l}|durq|\}}}}i}	|r6||	d<|rB||	d<tjfi|	��}
||
7}d�|�r|j||||
d�q|S)N�morerows�morecolsr�rN)rr��entryr�ri)r)Zrowdatar�r�Zcellr�r�r�Z	cellblockr�r�rrrr�s"
�zBody.build_table_rowa?
                            (
                              _               # anonymous target
                            |               # *OR*
                              (?!_)           # no underscore at the beginning
                              (?P<quote>`?)   # optional open quote
                              (?![ `])        # first char. not space or
                                              # backquote
                              (?P<name>       # reference name
                                .+?
                              )
                              %(non_whitespace_escape_before)s
                              (?P=quote)      # close quote if open quote used
                            )
                            (?<!(?<!\x00):) # no unescaped colon at end
                            %(non_whitespace_escape_before)s
                            [ ]?            # optional space
                            :               # end of reference name
                            ([ ]+|$)        # followed by whitespace
                            a�
                               (
                                 (?P<simple>%(simplename)s)_
                               |                  # *OR*
                                 `                  # open backquote
                                 (?![ ])            # not space
                                 (?P<phrase>.+?)    # hyperlink phrase
                                 %(non_whitespace_escape_before)s
                                 `_                 # close backquote,
                                                    # reference mark
                               )
                               $                  # end of string
                               a�
                                  (
                                    (?![ ])          # first char. not space
                                    (?P<name>.+?)    # substitution text
                                    %(non_whitespace_escape_before)s
                                    \|               # close delimiter
                                  )
                                  ([ ]+|$)           # followed by whitespace
                                  )r�r�substitutioncCs"|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[r�rrr
r�rr�rN)rJrLrOr�r�r�r�footnoter�r4rUrcr-Znote_autofootnoteZnote_symbol_footnoterZ
note_footnoterr�ri)r)r�rsrtr<r=r�rkrr�r�rrrr�\s6�

z
Body.footnotecCs�|j��\}}|j�|���\}}}}|�d�}t|�}	t�d�|��}
||
_	||
_
|
t�d|�7}
|
d�|	�|j
�|
�|j
�|
|
�|r�|j|||
d�|
g|fS)Nr[r�r�r�rN)rJrLrOr�r�r�r�citationr�r4rUrrcr-Z
note_citationrri)r)r�rsrtr<r=r�rkrr�r�rrrr�{s�

z
Body.citationc
Cs|jjj}|j��}|jj|��ddd�\}}}}|jd|���d�|�}dd�|D�}|d}	d}
|�	|	�}|rxq�|
d7}
z|	||
7}	Wqht
y�td	��Yqh0qh|d|
�=|dd
|��t|	�dd��
�|d<|�||||�d��}|g|fS)NTF)r��strip_indentr�cSsg|]}t|��qSr�r�r�rUrrrr��r z)Body.hyperlink_target.<locals>.<listcomp>rr[zmalformed hyperlink target.r�r�)�explicitr�r�rJr�rOr�r�r�r�rbrr_rc�make_targetr�)
r)r�rrwrfr=r�rk�	blocktextr��
blockindexZtargetmatchr�rrr�hyperlink_target�s0


��


,
�zBody.hyperlink_targetcCs�|�|||�\}}|dkrTtj|dt|�d�}||_|�|d||�|j�|�|S|dkr|t�|d�}|�||||�|S|SdS)Nr�r�r�r�)�parse_targetrr�r�r�
add_targetr-r)r)rf�
block_textrwZtarget_nameZtarget_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
        r�Nr�r�cSsg|]}|���qSr)rcr�rrrr��r z%Body.parse_target.<locals>.<listcomp>r�css |]}d�t|����VqdSr�)r�rr�r�rrrr��s�z$Body.parse_target.<locals>.<genexpr>r�)rcr��is_referencer)r)rfr�rwrr�Z	ref_partsrrrr��s


�zBody.parse_targetcCs4|jjj�t|��}|sdSt|�d�p0|�d��S)N�simple�phrase)r�r�rr�rrr�)r)rr�rrrr��s
�zBody.is_referencecCs�||_|r`tt|��}|d�|�|rN|j�|�}|rB||d<ntd|��|j�||j	�n |rl||d<d|d<|j�
|�dS)Nr�r�zproblem with URI: %rr[r�)rUr�rrcr3rrr-rrNZnote_anonymous_target)r)Z
targetnamer�r�rwr�r�rrrr��s
zBody.add_targetcCs�|jjj}|j��\}}|jj|��dd�\}}}}|jd|���d�|�}	|�	�t
|d���}
d}|�|
�}|r|q�|d7}z|
dt
||�
��}
Wqlty�td��Yql0ql|d|�=|d�
�d|��t|
�dd�|d<|d�s|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|fS�qt|�dk�r�|jjd|
t�|	|	�||d�}|g|fS|j'�(||
|j �|g|fS)NF�r�r�rr[r�z"malformed substitution definition.r�r�z.Substitution definition "%s" missing contents.r�r��SubstitutionDefrLr�z6Substitution definition contains illegal element <%s>:z.Substitution definition "%s" empty or invalid.))r�r�r�rJrLrOr�r�r�r�rr�r�rcrbrr_rar�rZsubstitution_definitionr4rUr.r�r�rcrrrr�ZInlinerrN�findall�Element�*disallowed_inside_substitution_definitions�pformatr�Ztagnamer-Znote_substitution_def)r)r�rrsrtrfr=r�rkr�r�r�ZsubdefmatchZsubnameZsubstitution_noder��new_abs_offsetrHr<r�rrr�substitution_def�s�
��


,



�
��

���
�
�zBody.substitution_defcCs@|ds4t|tj�r|�d�s4t|tj�r8|�d�r8dSdSdS)NZidsr�r
TF)r�rr�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
�	directiver9r/r-rN�
run_directive�unknown_directive)r)r��option_presets�	type_nameZdirective_classrxrrrr�.s
��zBody.directivec
Cs�t|ttf�r"ddlm}||�}|j��}|jj}|jj|�	�dd�\}}	}
}d�
|jj||jjd��}z|�||
||�\}
}}}WnXt
y�}z@|jjd|d�
|j�ft�||�|d�}|g|fWYd	}~Sd	}~00|||
|||||||j�	}z|��}WnXtjjj�yb}z8|jj|j|j|d�}|t�||�7}|g}WYd	}~n
d	}~00t|t��s|Jd
|��tt|��D].}t||tj��s�Jd||||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_topr�r[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) r�rr�docutils.parsers.rstr�rJr�r�rOr�r�r>�parse_directive_blockrr.r�r�rr�r=�docutils�parsersZrstZDirectiveErrorZsystem_messagerr��listrDr_ZNode�is_next_line_blank)r)r�r�r�r�r�rwZinitial_line_offsetr<r=r�rkr��	argumentsr}�content�content_offsetr�r�Zdirective_instancerfZmsg_noderHrrrr�:sb
��

���
�� 

������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�|j�s0|j�r>|�	||	�}
ng}
|
�rV|�sVt
d��|
||
|fS)Nrr[r�zno content permitted)�option_spec�has_contentrcZ
trim_start�trim_end�required_arguments�optional_arguments�	enumerate�parse_directive_options�parse_directive_argumentsr)r)r<r�r�r�r�r�rHrU�	arg_blockr�r�r}r�rrrr�vsX

���

�
�zBody.parse_directive_blockc
Cs�|��}t|�D]6\}}t�tjd|�r||d�}|d|�}qLqg}|rx|�||�\}}	|rp|�|	�nt|	��||fS)Nr2)	rjr�r�r�rDr��parse_extension_optionsr(r)
r)r�r�r�r}rHrUZ	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)Nr�z$%s argument(s) required, %s suppliedr[z+maximum %s argument(s) allowed, %s supplied)r�r�r�r�r_rZfinal_argument_whitespace)r)r�r��requiredZoptionalZarg_textr�rrrr��s"

���zBody.parse_directive_argumentsc
Cst��}|j|d|ddd�\}}|t|�kr0dSzt�||�}Wn�tyv}zdd|jdfWYd}~Sd}~0tt	fy�}z ddd	�
|j�fWYd}~Sd}~0tj�y�}z dd
d	�
|j�fWYd}~Sd}~00|�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)rrmrrr_rZextract_extension_optionsr`r�r{rer�ZExtensionOptionError)r)r�Z	datalinesr<r\rkr}r�rrrr��s$�
&(*zBody.parse_extension_optionsc	CsT|j��}|jjddd�\}}}}d�|�}|jjd|t�||�|d�}|g|fS)NrFr�r�zUnknown directive type "%s".r�)rJr�rOr�r.r�rr�)	r)r�rwr<r=r�rkr�r�rrrr��s
�

�zBody.unknown_directivecCs�|j��rP|j|��d�}|��s2t��gdfS|�d�rP|jj	�
�gdfS|j�|���\}}}}|r�|d��s�|��qhd�
|�}t�||�g|fS)NTzend of inclusion from "r�r�)rJr�r�r�rcr�commentrr-Zinclude_lograrOr�r�)r)r�Zfirst_comment_liner<r=r�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�rVr;r�rkrrrr8.	s
zBody.explicit_markupcCs�g}|jjD]�\}}|�|j�}|rz|||�WSty�}zF|j��}d�|j�}|�	|j
j||d��WYd}~q�WYd}~qd}~00q|�|�\}	}
|	||
fS)z>Determine which explicit construct this is, parse & return it.r�r�N)
r��
constructsr�r�rrJr�r�r�rcr.r�r�)r)r��errorsr�rZexpmatchr�rwr�r�rkrrrr�5	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<rGrkr6zExplicit markup)	rJr�rrr>rRrNr6rPr�)r)rkr�r\rrrr�E	s�

zBody.explicit_listcCs0|�|�\}}|j|7_|�|�g|gfS�zAnonymous hyperlink targets.)�anonymous_targetrNr�r�rrrr�U	s
zBody.anonymousc	Csj|j��}|jj|��dd�\}}}}|jd|���d�|�}dd�|D�}|�|||d�}|g|fS)NTr�r�cSsg|]}t|��qSrr�r�rrrr�b	r z)Body.anonymous_target.<locals>.<listcomp>r�)rJr�rOr�r�r�r�)	r)r�rwrfr=r�rkr�r�rrrr�\	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)rJr6r�rcrrWr_r.rYr�rNrUrSrr�)r)r�rVr;r�r�rrrrUf	s&�
�z	Body.linecCs|jgdgfS)z%Titles, definition lists, paragraphs.r�r�r�rrrr�|	sz	Body.text)N)r�r)rN)crrrr+rZTableParserr�r%r.rX�keysr^raZsequencepatsrr!r#r&rr$rbr_rZr�r�r�r�Zsimple_table_top_patr��patsrT�escaper�r�r��initial_transitionsr=r:rEr@rFrAr0rMr1rUrVrdr2rnrorrr3ryrzr4r5r�r�r�r6r7r�r�r�r�r�r�r�r�r�r7r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r8r�r�r�r�rUr�rrrrrD0sT�
��
�


�
��

�#
#
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.<listcomp>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�RFC2822ListrLzRFC2822-style field list)rrmrN�
rfc2822_fieldrJr�rrr>rRrPr�)	r)r�rVr;Z	fieldlistrnrkr�r\rrrr�	s"�


�zRFC2822Body.rfc2822c	Cs~|jd|j�d��}|jj|��dd�\}}}}t��}|t�||�7}t�d�	|��}||7}|rv|j
|||d�||fS)NruTr�r�rN)r��findrJrOr�rrnrprqr�ri)	r)r�r�r<r=r�rkZ	fieldnodeZ	fieldbodyrrrr�	s��
�zRFC2822Body.rfc2822_fieldN)rrrr+rDr�rjr�insertrrrrrrr�	s
�rc@sNeZdZdZddd�ZeZeZeZeZeZ	eZ
eZeZ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r=r0r1r2r3r4r5r6r7r8r�rUr�rrrrr
�	s
r
c@seZdZdZdd�ZdS)rKz-Second and subsequent bullet_list list_items.cCsL|jd|jdkr|��|�|���\}}|j|7_||_g|gfS)rJrr0)r�rNrrMr�rk)r)r�rVr;rPrkrrrr0�	szBulletList.bulletN)rrrr+r0rrrrrK�	srKc@seZdZdZdd�ZdS)�DefinitionListz,Second and subsequent definition_list_items.cCs|jgdgfS)zDefinition lists.�
Definitionr�r�rrrr��	szDefinitionList.textN)rrrr+r�rrrrr
�	sr
c@seZdZdZdd�ZdS)rRz1Second and subsequent enumerated_list list_items.c
Cs�|�||jd�\}}}}||jks\|dkrN||jdks\|js\||jdks\|�|||�sd|��|dkrrd|_|�|���\}}	|j|7_|	|_	||_g|gfS)zEnumerated list item.rQrr[)
rUrNrTr
rSrVrrMr�rk)
r)r�rVr;rTrZr�r[rPrkrrrr1�	s,
�
�����zEnumeratedList.enumeratorN)rrrr+r1rrrrrR�	srRc@seZdZdZdd�ZdS)rlz(Second and subsequent field_list fields.cCs,|�|�\}}|j|7_||_g|gfS)zField list field.)rnrNrk�r)r�rVr;rnrkrrrr2
szFieldList.field_markerN)rrrr+r2rrrrrl
srlc@seZdZdZdd�ZdS)rxz4Second and subsequent option_list option_list_items.cCsLz|�|�\}}Wnty,|��Yn0|j|7_||_g|gfS)rw)ryrrrNrk)r)r�rVr;ryrkrrrr3
szOptionList.option_markerN)rrrr+r3rrrrrx
srxc@s*eZdZdZejZejZdd�Zej	Z
dS)rz6Second and subsequent RFC2822-style field_list fields.cCs,|�|�\}}|j|7_||_gdgfS)rr)rrNrkrrrrr-
szRFC2822List.rfc2822N)rrrr+rr�rrr
rrGrrrrr&
s
rc@seZdZdZdd�ZdS)r�zz
    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.r�r�N)r�rcrcr�rr�)r)r<r�r<r�rUr�rrrrr?
s
z!ExtensionOptions.parse_field_bodyN)rrrr+rrrrrrr�7
sr�c@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�rVr;rwrUrxrkrrrr5Q
s
zLineBlock.line_blockN)rrrr+r
rrGr5rrrrr�K
sr�c@s&eZdZdZdd�Zdd�ZejZdS)r�z0Second and subsequent explicit markup construct.cCs,|�|�\}}|j|7_||_g|gfSr�)r�rNrkr�rrrr8_
szExplicit.explicit_markupcCs,|�|�\}}|j|7_||_g|gfSr�)r�rNrkr�rrrr�f
szExplicit.anonymousN)	rrrr+r8r�r
rrGrrrrr�[
sr�c@sBeZdZdZe�dejej�dd�Z	ddgZ
dd�Zd	d
�ZdS)r�zG
    Parser for the contents of a substitution_definition element.
    z(%s)::( +|$)r�)�embedded_directiver�rr�cCsB|j||jddd�\}}|j|7_|j��s:||_t�dS)Nr�r)Zalt)r�rNrJ�at_eofrkrQr�rrrr|
s�

z"SubstitutionDef.embedded_directivecCs|j��s|j��|_t�dSr&)rJrr�rkrQr�rrrr��
s
zSubstitutionDef.textN)
rrrr+r�r�r7r�r�r�rrr�rrrrr�p
s���r�c@szeZdZdZejddd�ZddgZdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�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�)rrD)r�rDcCsH|�||j��d�\}}|j|7_|r>|j|��7_gdgfS)zEnd of paragraph.r[rD)r�rJr�rNr�)r)r�rVr;r�r�rrrrG�
s�z
Text.blankcCs|r|�d|d�gSr&)rGrYrrr�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<rGrkrnzDefinition listrD)rZdefinition_list�definition_list_itemrNrJr�rrr>rRrPr�)	r)r�rVr;ZdefinitionlistZdefinitionlistitemrkr�r\rrrr=�
s�

zText.indentcCsX|j��}|d��}|j��}|d|}g}t|�t|�kr�t|�dkr~|jjrr|jjd|d�}	|j	|	7_	t
�d��n8|dd|jj}
|jj
dt�|
|
�|d�}	|�|	�|jj�s$|dd|jj}
|j��\}}|jjdt�|
|
�||d	�}	|j	|7_	|j	|	7_	g|gfS|d}
g|d
d
�<|�|||
|d|�g|gfS)zSection title.rr�r�zfPossible 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_r6r.rYrNrrWrUr�rr�rcrLrSry)r)r�rVr;rwrurr4rxr�r�rsrtrvrrrr�
sB

��


�
zText.underlinec

Cs�|j��d}d}z|jjdd�}WnDtjyh}z*|j\}}}	|jjd||	d�}WYd}~n
d}~00|t|�}
|�	|
|�\}}|j
|7_
|j
|7_
|r�z|j��Wnty�Yn0|j
|�
�7_
g|gfS)z
Paragraph.r[NTr�r�r�)rJr�r�rr�r�r.r�r�r�rNrerQr�)
r)r�rVr;r�r�rfr�rsrtr�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.r�r�r[z
Literal block)
rJr9rcr��quoted_literal_blockr�rr�rLr4rUrcr�)r)r<r=r�rkr�r�r�rrrr��
s�


�zText.literal_blockcCsR|j��}|jj}t��}|j|jj|d�||dtfdd�d�}|�|�|j	S)NF�QuotedLiteralBlockrE)r?r<r6rh)
rJrRr�rr�rir>rrPZchildren)r)rRr�Zparent_noder�rrrrs
��
zText.quoted_literal_blockcCs�|j��\}}}}t�d�|t|���}|j��d}|j�|�\|_|_	|�
||�\}}	||7}tjdg|	�R�}
||
7}|ddd�dkr�|
|jj
d|dd�7}
|j|||
d	�||fS)
Nr�r[r�rr�r�z`Blank line missing before literal block (after the "::")? Interpreted as a definition list item.r�rN)rJr9rrr�r�r�rLr4rU�termr�r.rYri)r)Ztermliner<r=r�rk�itemnoderwZtermlistrxr�rrrrs(�
�
��zText.definition_list_itemz +: +c
	Cst|�dksJ�|�|d|�\}}t�|d�}|j�|�\|_|_|g}tt|��D]�}||}t	|tj
�r�|j�|�}	t|	�dkr�|d|7<q�|	d�
�}
t�
|
�}|d|7<|	dd�D]}|�t�t|d�|��q�qX|d|7<qX||fS)z9Return a definition_list's term and optional classifiers.r[rr�NT)r_r�rrrJrLr4rUrDr�r�classifier_delimiterr�r�rcZ
classifierr)
r)r�rwr�rxZ	term_noderrHr<r�r�Ztextnoder�rrrr's,
�
�z	Text.termN)rrrr+rDr�rrGrr=rr�r�rrr�r�rrrrrrr�
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.rrYrrrrJszSpecializedText.eofNcCst�dSr�rQr�rrrrNszSpecializedText.invalid_input)NNN)
rrrr+rrrGr=rr�rrrrrAs
rc@s eZdZdZdd�Zdd�ZdS)rz.Second line of potential definition_list_item.cCs|j�d�gS)zNot a definition.r\)rJr}rYrrrr\szDefinition.eofcCs,|�|�\}}|j|7_||_gdgfS)rr
)rrNrk)r)r�rVr;rrkrrrr=aszDefinition.indentN)rrrr+rr=rrrrrXsrc@sLeZdZdZdZdd�Zdd�Zdd�ZeZd	d
�Z	ddd�Z
dd
d�ZdS)r�zO
    Second line of over- & underlined section title or transition marker.
    r[cCs�|d��}|jjrd|j_nt|�dkr4|�|�|jrv|j��\}}tj	|dd�}||_
|d|_|j|7_d|_gS)z0Transition marker at end of section or document.rFr�r?r[)
rcr9r2r_�state_correction�eofcheckrJrLr�
transitionr4rUrN)r)rV�markerrsrtrrrrrrs


zLine.eofcCsd|j��\}}|d��}t|�dkr0|�|�tj|d�}||_|d|_|j	|7_	gdgfS)zTransition marker.rr�r?r[rD)
rJrLrcr_rrrr4rUrN)r)r�rVr;rsrtr rrrrrG�s

z
Line.blankc
	Cst|j��d}|d}|j}d}z|j��}Wnvty�|d|}t|���dkrj|�|||d�n6|jj	dt
�||�|d�}	|j|	7_gd	gfYSYn0d
|||f}
|��}|��}|j
dd�|��sF|d|d|}t|���dk�r|�|||d�n2|jj	dt
�|
|
�|d�}	|j|	7_gd	gfSnt||k�r�|d|d|}t|���dk�r�|�|||d�n2|jj	d
t
�|
|
�|d�}	|j|	7_gd	gfS|��}g}t|�t|�k�r4|d|d|}t|���dk�r|�|||d�n$|jjdt
�|
|
�|d�}	|�|	�|d|df}d|_|�|��|
||d|�d|_gd	gfS)z#Potential over- & underlined title.r[rr�r�r�r\zIncomplete section title.r�rDz%s
%s
%srz6Missing matching underline for section title overline.z$Title overline & underline mismatch.zTitle overline too short.)rJr�r�rerQr_r��short_overliner.rSrr�rNrWr�rr�rcrryrI)
r)r�rVr;rw�overlinerurr�r�r4rxrvrrrr��sv
�
�

�

�
z	Line.textcCsx|d}|d|jj}|j��d}t|���dkrF|�|||d�|jjdt�	||�|d�}|j
|7_
gdgfS)Nrr�r[r�z+Invalid section title or transition marker.r�rD)rJrUr�r_r�r!r.r�rr�rN)r)r�rVr;r"r�rwr�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.rYrNr)r)rVr�rwr�r�rrrr!�s�zLine.short_overlinecCs(|j�|�g|dd�<t�dd��dS)NrDr�)rJr}rZStateCorrection)r)rVr�rrrr�szLine.state_correctionN)r[)r[)rrrr+rrrGr�r=rr!rrrrrr�is>
r�c@s^eZdZdZdejdd�ZdZddd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�ZdS)rz�
    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*rx�initial_linenorIrrrr*�szQuotedLiteralBlock.__init__cCs|r
t�n
||gfSdSr&rr�rrrrG�szQuotedLiteralBlock.blankcCs�|rH|j�|j�\}}d�|�}t�||�}||_||_|j|7_n*|j|j	j
d|j��d�7_|j��|j|j
7_gS)Nr�z#Literal block expected; none found.r�)rJrLr$r�rr�r4rUrNr.r�r�r}rx)r)rVrsrtr�r�rrrrs �
�

zQuotedLiteralBlock.eofcCs<|sJd��|j�|jjd|j��d��|j��t�dS)Nz7QuotedLiteralBlock.indent: context should not be empty!r�r��rxrcr.r�rJr�r}rQr�rrrr=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�Zadd_transitionr&rTrrJr�r$)r)r�rVr;�quoterrrrr#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�r%r�rrrr�-s��
zQuotedLiteralBlock.textN)F)rrrr+rDrr�rr*rGrr=r#r&r�rrrrr�s�
	r)T)Hr+Z
__docformat__�sysr��typesrrr�rrrrrZdocutils.statemachiner	r
Zdocutils.nodesrr�rr�r
rrrZdocutils.parsers.rst.languagesrZ_fallback_language_moduleZdocutils.utilsrrrrrrrrr!r"r#�	Exceptionr$�objectr%r,rBrCr�r7rr!r#r&rDrr
rKr
rRrlrxrr�r�r�r�rrrr�rrFrrrr�<module>s�b'n
\[.,	8K


�

Youez - 2016 - github.com/yon3zu
LinuXploit