+
    VBix                    *  a  0 t $ R t^ RIHt Rt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIHtHt ^ RIHtHt ^ RIHtHt ^ RIHt Rt]'       dD   ^ R	IHtHtHt ^ R
IHtHtHtHt ^ RI H!t! ^ RIH"t" ^ RI#H$t$ ]]PJ                  .R3,          t&R]'R&    ! R R]4      t( ! R R]4      t) ! R R4      t* ! R R]4      t+ ! R R]+4      t, ! R R]+4      t- ! R R]+4      t.R R lt/R  R! lt0R" R# lt1 ! R$ R%]4      t2R& R' lt3R( t4R) R* lt5RUR+ R, llt6R- R. lt7R/ R0 lt8RUR1 R2 llt9R3 R4 lt:R5 R6 lt;R7 R8 lt<R9 R: lt=R; R< lt>R= R> lt?R? R@ lt@RA RB ltARC RD ltBRE^RF^RG^RH^RI^RJ^/tC RK RL ltDRM RN ltERO RP ltFRURQ RR lltG ! RS RT4      tHR# )Vz:
Miscellaneous utilities for the documentation utilities.
)annotationsreStructuredTextN)PurePathPath)ApplicationError	DataError)ionodes)unescapeF)CallableSequenceIterable)AnyFinalLiteralTextIO)	TypeAlias)StrPath)Valuesr   _ObserverFuncc                  "    ] tR t^(tR R ltRtR# )SystemMessagec               $    V ^8  d   QhRRRRRR/# )   system_messagenodes.system_messagelevelintreturnNone )formats   "</usr/lib/python3.14/site-packages/docutils/utils/__init__.py__annotate__SystemMessage.__annotate__*   s#      '; C     c                	X    \         P                  WP                  4       4       W n        R # N)	Exception__init__astextr   )selfr   r   s   &&&r"   r)   SystemMessage.__init__*   s    4!6!6!89
r%   )r   N)__name__
__module____qualname____firstlineno__r)   __static_attributes__r    r%   r"   r   r   (   s     r%   r   c                      ] tR t^0tRtR# )SystemMessagePropagationr    Nr-   r.   r/   r0   r1   r    r%   r"   r3   r3   0   s    r%   r3   c                      ] tR t^4t$ RtR]R&   R"tR]R&    ^ tR]R&   ^tR]R&   ^t	R]R	&   ^t
R]R
&   ^tR]R&   R#R R lltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R  ltR!tR# )$Reportera  
Info/warning/error reporter and ``system_message`` element generator.

Five levels of system messages are defined, along with corresponding
methods: `debug()`, `info()`, `warning()`, `error()`, and `severe()`.

There is typically one Reporter object per process.  A Reporter object is
instantiated with thresholds for reporting (generating warnings) and
halting processing (raising exceptions), a switch to turn debug output on
or off, and an I/O stream for warnings.  These are stored as instance
attributes.

When a system message is generated, its level is compared to the stored
thresholds, and a warning or error is generated as appropriate.  Debug
messages are produced if the stored debug switch is on, independently of
other thresholds.  Message output is sent to the stored warning stream if
not set to ''.

The Reporter class also employs a modified form of the "Observer" pattern
[GoF95]_ to track system messages generated.  The `attach_observer` method
should be called before parsing, with a bound method or function which
accepts system messages.  The observer can be removed with
`detach_observer`, and another added in its place.

.. [GoF95] Gamma, Helm, Johnson, Vlissides. *Design Patterns: Elements of
   Reusable Object-Oriented Software*. Addison-Wesley, Reading, MA, USA,
   1995.
z9Callable[[int | None], tuple[StrPath | None, int | None]]get_source_and_linezFinal[Sequence[str]]levelsr   DEBUG_LEVEL
INFO_LEVELWARNING_LEVELERROR_LEVELSEVERE_LEVELNc               8    V ^8  d   QhRRRRRRRRRR	R
RRRRR/# )r   sourcer   report_levelr   
halt_levelstreamz5io.ErrorOutput | TextIO | str | Literal[False] | Nonedebugboolencodingz
str | Noneerror_handlerstrr   r   r    )r!   s   "r"   r#   Reporter.__annotate__a   se     :A :A:A :A 	:A
 B:A :A :A :A :Ar%   c                    Wn          Wpn         WPn         W n         W0n         \        V\        P                  4      '       g   \        P                  ! WFV4      pW@n         T;'       g    \        VRR4      V n
         . V n         RV n        R# )a  Low level instantiating. See also `new_reporter().`.

:Parameters:
    - `source`: The path to or description of the source data.
    - `report_level`: The level at or above which warning output will
      be sent to `stream`.
    - `halt_level`: The level at or above which `SystemMessage`
      exceptions will be raised, halting execution.
    - `debug`: Show debug (level=0) system messages?
    - `stream`: Where warning output is sent.  Can be file-like (has a
      ``.write`` method), a string (file name, opened for writing),
      '' (empty string) or `False` (for discarding all stream messages)
      or `None` (implies `sys.stderr`; default).
    - `encoding`: The output encoding.
    - `error_handler`: The error handler for stderr output encoding.
rE   asciiN)r?   rF   
debug_flagr@   rA   
isinstancer   ErrorOutputrB   getattrrE   	observers	max_level)r+   r?   r@   rA   rB   rC   rE   rF   s   &&&&&&&&r"   r)   Reporter.__init__a   s    6 <*33(	 %	. &"..11^^FmDF&,+%MMW)M,.0	 !@r%   c                    V ^8  d   QhRRRR/# r   observerr   r   r   r    )r!   s   "r"   r#   rH      s     ( ( ($ (r%   c                <    V P                   P                  V4       R# )zu
The `observer` parameter is a function or bound method which takes one
argument, a `nodes.system_message` instance.
N)rP   appendr+   rU   s   &&r"   attach_observerReporter.attach_observer   s    
 	h'r%   c                    V ^8  d   QhRRRR/# rT   r    )r!   s   "r"   r#   rH      s     ( ( ($ (r%   c                	<    V P                   P                  V4       R # r'   )rP   removerX   s   &&r"   detach_observerReporter.detach_observer   s    h'r%   c                    V ^8  d   QhRRRR/# )r   messager   r   r   r    )r!   s   "r"   r#   rH      s      (<  r%   c                	<    V P                    F  pV! V4       K  	  R # r'   )rP   )r+   ra   rU   s   && r"   notify_observersReporter.notify_observers   s    HW 'r%   c               (    V ^8  d   QhRRRRRRRR/# )	r   r   r   ra   rG   kwargsr   r   r   r    )r!   s   "r"   r#   rH      s0     2 2!2 #2 "%	2
 12r%   c                   \        V\        4      '       d   \        V4      pVP                  4       pRV9   dD   \	        VR,          4      w  rgVR Ve   VP                  RV4       Ve   VP                  RV4       RV9  d4    V P                  VP                  R4      4      w  rgVe   WeR&   Ve   WuR&   VP                  RV P                  4       \        P                  ! V.VO5RVRV P                  V,          /VB pV P                  '       ds   WP                  8  g3   V P                  '       d   WP                   8X  g   WP"                  8  d1   V P                  P%                  VP'                  4       R,           4       WP"                  8  d   \)        W4      hWP                   8  g   V P                  '       d   V P+                  V4       \-        WP.                  4      V n        V#   \         d    RRrv ELZi ; i)z[
Return a system_message object.

Raise an exception or generate a warning if appropriate.
	base_nodeNr?   liner   type
)rM   r(   rG   copyget_source_line
setdefaultr7   getAttributeErrorr?   r	   r   r8   rB   r@   rL   r9   rA   writer*   r   rc   maxrQ   )	r+   r   ra   childrenrf   
attributesr?   ri   msgs	   &&&*,    r"   r   Reporter.system_message   s    gy))'lG[[]
& *6++>?LF;'!%%h7%%fd3:%*#77
v8NO !'-8$%)6" 	h4""7 <$,<% <(,E(:<0:< ;;;E%6%66#5<L<L3L$7KKcjjlT12OO#++###t!!#&UNN3
- " *#T*s   "G/ /H Hc                    V ^8  d   QhRRRR/# r   rf   r   r   r   r    )r!   s   "r"   r#   rH      s     J JS J-A Jr%   c                j    V P                   '       d!   V P                  ! V P                  .VO5/ VB # R# )z
Level-0, "DEBUG": an internal reporting issue.

Typically, there is no effect on the processing. Level-0 system
messages are handled separately from the others.
N)rL   r   r9   r+   argsrf   s   &*,r"   rC   Reporter.debug   s3     ???&&t'7'7I$I&II r%   c                    V ^8  d   QhRRRR/# rx   r    )r!   s   "r"   r#   rH      s     E EC E,@ Er%   c                B    V P                   ! V P                  .VO5/ VB # )z
Level-1, "INFO": a minor issue that can be ignored.

Typically, there is no effect on processing and level-1 system
messages are not reported.
)r   r:   rz   s   &*,r"   infoReporter.info   s#     ""4??DTDVDDr%   c                    V ^8  d   QhRRRR/# rx   r    )r!   s   "r"   r#   rH      s     H Hs H/C Hr%   c                B    V P                   ! V P                  .VO5/ VB # )zz
Level-2, "WARNING": an issue that should be addressed.

If ignored, there may be unpredictable problems with the output.
)r   r;   rz   s   &*,r"   warningReporter.warning   s%     ""4#5#5GGGGr%   c                    V ^8  d   QhRRRR/# rx   r    )r!   s   "r"   r#   rH      s     F FS F-A Fr%   c                B    V P                   ! V P                  .VO5/ VB # )zc
Level-3, "ERROR": an error that should be addressed.

If ignored, the output will contain errors.
)r   r<   rz   s   &*,r"   errorReporter.error   s%     ""4#3#3EdEfEEr%   c                    V ^8  d   QhRRRR/# rx   r    )r!   s   "r"   r#   rH     s     G Gc G.B Gr%   c                B    V P                   ! V P                  .VO5/ VB # )z
Level-4, "SEVERE": a severe error that must be addressed.

If ignored, the output will contain severe errors. Typically level-4
system messages are turned into exceptions which halt processing.
)r   r=   rz   s   &*,r"   severeReporter.severe  s%     ""4#4#4FtFvFFr%   )	rL   rE   rF   rA   rQ   rP   r@   r?   rB   )DEBUGINFOWARNINGERRORSEVERE)NFNbackslashreplace)r-   r.   r/   r0   __doc____annotations__r8   r9   r:   r;   r<   r=   r)   rY   r^   rc   r   rC   r   r   r   r   r1   r    r%   r"   r6   r6   4   s    < ML$7F  7D KJM5KL%:Ax((2hJEHFG Gr%   r6   c                      ] tR tRtRtR# )ExtensionOptionErrori  r    Nr4   r    r%   r"   r   r     s    tr%   r   c                      ] tR tRtRtR# )BadOptionErrori  r    Nr4   r    r%   r"   r   r     s    Dr%   r   c                      ] tR tRtRtR# )BadOptionDataErrori  r    Nr4   r    r%   r"   r   r     s    r%   r   c                      ] tR tRtRtR# )DuplicateOptionErrori  r    Nr4   r    r%   r"   r   r     s    $r%   r   c               $    V ^8  d   QhRRRRRR/# )r   
field_listnodes.field_listoptions_spec dict[str, Callable[object], Any]r   dict[str, Any]r    )r!   s   "r"   r#   r#     s$     ; ;*: ;,L;#1;r%   c                .    \        V 4      p\        W!4      # )a  
Return a dictionary mapping extension option names to converted values.

:Parameters:
    - `field_list`: A flat field list without field arguments, where each
      field body consists of a single paragraph only.
    - `options_spec`: Dictionary mapping known option names to a
      conversion function such as `int` or `float`.

:Exceptions:
    - `KeyError` for unknown option names.
    - `ValueError` for invalid option values (raised by the conversion
       function).
    - `TypeError` for invalid option value types (raised by conversion
       function).
    - `DuplicateOptionError` for duplicate options.
    - `BadOptionError` for invalid fields.
    - `BadOptionDataError` for invalid option data (missing name,
      missing data, bad quotes, etc.).
)extract_optionsassemble_option_dict)r   r   option_lists   && r"   extract_extension_optionsr     s    . "*-K::r%   c                    V ^8  d   QhRRRR/# )r   r   r   r   list[tuple[str, str | None]]r    )r!   s   "r"   r#   r#   -  s     ! ! 0 !3!r%   c                   . pV  EFJ  p\        V^ ,          P                  4       P                  4       4      ^8w  d   \        R4      h\	        V^ ,          P                  4       P                  4       4      pV^,          p\        V4      ^ 8X  d   RpM\        V4      ^8  gm   \        V^ ,          \        P                  4      '       dF   \        V^ ,          4      ^8w  g/   \        V^ ,          ^ ,          \        P                  4      '       g   \        RV,          4      hV^ ,          ^ ,          P                  4       pVP                  W534       EKM  	  V# )a  
Return a list of option (name, value) pairs from field names & bodies.

:Parameter:
    `field_list`: A flat field list, where each field name is a single
    word and each field body consists of a single paragraph only.

:Exceptions:
    - `BadOptionError` for invalid fields.
    - `BadOptionDataError` for invalid option data (missing name,
      missing data, bad quotes, etc.).
z:extension option field name may not contain multiple wordsNzMextension option field body may contain
a single paragraph only (option "%s"))lenr*   splitr   rG   lowerrM   r	   	paragraphTextr   rW   )r   r   fieldnamebodydatas   &     r"   r   r   -  s    KuQx &&()Q. LN N58??$**,-Qxt9>D$i!mQ99T!W"Q
EJJ77$:<@AB B 71:$$&DD<(# $ r%   c               $    V ^8  d   QhRRRRRR/# )r   r   r   r   r   r   r   r    )r!   s   "r"   r#   r#   Q  s$        &@  'G , r%   c                2   / pV  F?  w  r4W,          pVf   \        V4      hW29   d   \        RV,          4      h V! V4      W#&   KA  	  V#   \        \        3 d<   pTP	                  RT: RT: RRP                  TP                  4      : 24      hRp?ii ; i)a)  
Return a mapping of option names to values.

:Parameters:
    - `option_list`: A list of (name, value) pairs (the output of
      `extract_options()`).
    - `options_spec`: Dictionary mapping known option names to a
      conversion function such as `int` or `float`.

:Exceptions:
    - `KeyError` for unknown option names.
    - `DuplicateOptionError` for duplicate options.
    - `ValueError` for invalid option values (raised by conversion
       function).
    - `TypeError` for invalid option value types (raised by conversion
       function).
Nzduplicate option "%s"z
(option: "z
"; value: z)
 )KeyErrorr   
ValueError	TypeError	__class__joinr{   )r   r   optionsr   value	convertordetails   &&     r"   r   r   Q  s    ( G" &	4. ?&'>'EFF	K%e,GM # N I& 	K""&*E388FKK3H$J K K	Ks   
A

B6BBc                      ] tR tRtRtR# )NameValueErrorit  r    Nr4   r    r%   r"   r   r   t  s    r%   r   c                    V ^8  d   QhRRRR/# )r   pathzstr | bytes | Noner   rG   r    )r!   s   "r"   r#   r#   w  s      n  r%   c                T   \        V \        4      '       d   V # V f   R#  V P                  \        P                  ! 4       R4      p V #   \
         d    \        RT : 24      h\         d=     T P                  RR4      p  T #   \         d    T P                  RR4      p   T # i ; ii ; i)z
Ensure `path` is Unicode. Return `str` instance.

Decode file/path string in a failsafe manner if not already done.

Deprecated. Will be removed in Docutils 1.0.
 strictz/`path` value must be a String or ``None``, not utf-8rJ   replace)rM   rG   decodesysgetfilesystemencodingrp   r   UnicodeDecodeError)r   s   &r"   decode_pathr   w  s     $|	3{{3446A K  *   $x) * 	* 3	3;;w1D K " 	3;;w	2DK	33s/   %A "B'*B',BB#B'"B##B'c                L   . pV '       Ed   V P                  R4      pVR8X  d   \        R4      hV RV P                  4       pV^ 8X  g	   V'       g   \        R4      hW^,           R P                  4       p V '       g   \        RV R24      hV ^ ,          R9   d   V P                  V ^ ,          ^4      pVR8X  d   \        RV R	V ^ ,           R
24      h\	        V 4      V^,           8  d=   W^,           ,          P                  4       '       d   \        RV RV ^ ,           R24      hV ^V pW^,           R P                  4       p M;V P                  R4      pVR8X  d   T pRp MV RV pW^,           R P                  4       p VP                  VP                  4       V34       EK  V# )z
Return a list of (name, value) from a line of the form "name=value ...".

:Exception:
    `NameValueError` for invalid input (missing name, missing data, bad
    quotes, etc.).
=zmissing "="Nz!missing attribute name before "="zmissing value after "z="z'"zattribute "z" missing end quote ()z" end quote (z) not followed by whitespacer   r   rK   )findr   striplstripr   rW   r   )ri   attlistequals_indexattnameendquote_indexr   space_indexs   &      r"   extract_name_valuer     s    G
$yy~2 //}%++-1G !DEENO$++- #8	!DEE7e!YYtAw2N#$#G9,A$q'!LN ND	NQ..!+,2244${7) <))-a	1M&O P P.)Dq()*113D))C.Kb L[)MN+224./Nr%   c               $    V ^8  d   QhRRRRRR/# )r   source_pathr   settingsr   r   r6   r    )r!   s   "r"   r#   r#     s!      g  H r%   c           
         \        WP                  VP                  VP                  VP                  VP
                  VP                  R7      pV# )z
Return a new Reporter object.

:Parameters:
    `source` : string
        The path to or description of the source text of the document.
    `settings` : optparse.Values object
        Runtime settings.
)rB   rC   rE   rF   )r6   r@   rA   warning_streamrC   error_encodingerror_encoding_error_handler)r   r   reporters   && r"   new_reporterr     sG     **H,?,?&&hnn((;;	=H
 Or%   c               $    V ^8  d   QhRRRRRR/# )r   r   r   r   zValues | Noner   znodes.documentr    )r!   s   "r"   r#   r#     s"     " "g " "$"r%   c                    ^ RI Hp Vf   VP                  4       p\        W4      p\        P
                  ! WV R7      pVP                  V R4       V# )a_  
Return a new empty document object.

:Parameters:
    `source_path` : str or pathlib.Path
        The path to or description of the source text of the document.
    `settings` : optparse.Values object
        Runtime settings.  If none are provided, a default core set will
        be used.  If you will use the document object with any Docutils
        components, you must provide their default settings as well.

        For example, if parsing rST, at least provide the rst-parser
        settings, obtainable as follows:

        Defaults for parser component::

            settings = docutils.frontend.get_default_settings(
                           docutils.parsers.rst.Parser)

        Defaults and configuration file customizations::

            settings = docutils.core.Publisher(
                parser=docutils.parsers.rst.Parser).get_settings()

)frontend)r?   rK   )docutilsr   get_default_settingsr   r	   documentnote_source)r   r   r   r   r   s   &&   r"   new_documentr     sJ    8 "002K2H~~hEHb)Or%   c               $    V ^8  d   QhRRRRRR/# )r   r   znodes.paragraphkeyword_substitutionsz'Sequence[tuple[re.Pattern[[str], str]]]r   r   r    )r!   s   "r"   r#   r#     s&     
 

B
 

r%   c                ,   \        V 4      ^8X  d   \        V ^ ,          \        P                  4      '       d[   V ^ ,          pV FI  w  r4VP	                  V4      pV'       g   K   \        P                  ! VP                  WB4      4      V ^ &    R# 	  R# R# R# )   N)r   rM   r	   r   searchsub)r   r   textnodepatternsubstitutionmatchs   &&    r"   clean_rcs_keywordsr     st     9~z)A,

CCQ<%:!GNN8,Eu$zz'++l*MN	!	 &;  Dr%   c               $    V ^8  d   QhRRRRRR/# )r   r?   StrPath | Nonetargetr   r   rG   r    )r!   s   "r"   r#   r#     s!     4 4, 4 4C 4r%   c                   \         P                  P                  T ;'       g    \        V4      ! R4      4      P	                  \         P
                  4      p\         P                  P                  V4      P	                  \         P
                  4      pVR,          VR,          8w  d   RP                  V4      # VP                  4        VP                  4        V'       d@   V'       d8   VR,          VR,          8X  d#   VP                  4        VP                  4        KG  VP                  4        R.\        V4      ^,
          ,          V,           pRP                  V4      # )ag  
Build and return a path to `target`, relative to `source` (both files).

The return value is a `str` suitable to be included in `source`
as a reference to `target`.

:Parameters:
    `source` : path-like object or None
        Path of a file in the start directory for the relative path
        (the file does not need to exist).
        The value ``None`` is replaced with "<cwd>/dummy_file".
    `target` : path-like object
        End point of the returned relative path.

Differences to `os.path.relpath()`:

* Inverse argument order.
* `source` is assumed to be a FILE in the start directory (add a "dummy"
  file name to obtain the path relative from a directory)
  while `os.path.relpath()` expects a DIRECTORY as `start` argument.
* Always use Posix path separator ("/") for the output.
* Use `os.sep` for parsing the input
  (changing the value of `os.sep` is ignored by `os.relpath()`).
* If there is no common prefix, return the absolute path to `target`.

Differences to `pathlib.PurePath.relative_to(other)`:

* pathlib offers an object oriented interface.
* `source` expects path to a FILE while `other` expects a DIRECTORY.
* `target` defaults to the cwd, no default value for `other`.
* `relative_path()` always returns a path (relative or absolute),
  while `PurePath.relative_to()` raises a ValueError
  if `target` is not a subpath of `other` (no ".." inserted).

dummy_file:Nr   N/z..rK   )
osr   abspathrj   r   sepr   reversepopr   )r?   r   source_partstarget_partspartss   &&   r"   relative_pathr    s    F 77??6#G#GT&\,-G %%*U266] 77??6*008LB<++ xx%%LB<#33Fc,'!+,|;E88E?r%   c               $    V ^8  d   QhRRRRRR/# )r   r   r   relative_tor   r   rG   r    )r!   s   "r"   r#   r#   5  s#     # #v #*6#"%#r%   c                    \         P                  ! R\        ^R7       V P                  '       d?   V P                  '       d   Q R4       hVf   V P
                  p\        WP                  4      # V P                  # )u   
Retrieve a stylesheet reference from the settings object.

Deprecated. Will be removed in Docutils 1.0.
Use get_stylesheet_list() instead to enable specification of multiple
stylesheets as a comma-separated list.
zqutils.get_stylesheet_reference() is obsoleted by utils.get_stylesheet_list() and will be removed in Docutils 2.0.)
stacklevel6stylesheet and stylesheet_path are mutually exclusive.)warningswarnDeprecationWarningstylesheet_path
stylesheetoutput_pathr  )r   r  s   &&r"   get_stylesheet_referencer  5  sv     MM : %4 &&& 	FD	F&"..K[*B*BCC"""r%   c                    V ^8  d   QhRRRR/# )r   r   r   r   	list[str]r    )r!   s   "r"   r#   r#   W  s      & Y r%   c                   V P                   '       d   V P                  '       d   Q R4       hV P                  ;'       g    V P                   ;'       g    . p\        V\        4      '       g.   VP	                  R4       Uu. uF  q"P                  4       NK  	  ppV P                  '       d%   V Uu. uF  p\        W P                  4      NK  	  ppV# u upi u upi )z@Retrieve list of stylesheet references from the settings object.r	  ,)r  r  rM   listr   r   find_file_in_dirsstylesheet_dirs)r   stylesheetsr   s   &  r"   get_stylesheet_listr  W  s    ###(@(@(@ FDFA**GGh.A.AGGRKk4((0;0A0A#0FG0Fzz|0FG $/0#.4 )/G/GH#. 	 0 H0s   ?C/Cc               $    V ^8  d   QhRRRRRR/# )r   r   r   dirsIterable[StrPath]r   rG   r    )r!   s   "r"   r#   r#   f  s"      G +<  r%   c                &   \        V 4      p V P                  4       '       d   V P                  4       # V FK  p\        V4      P                  4       V ,          pVP	                  4       '       g   K;  VP                  4       u # 	  V P                  4       # )zq
Search for `path` in the list of directories `dirs`.

Return the first expansion that matches an existing file.
)r   is_absoluteas_posix
expanduserexists)r   r  dfs   &&  r"   r  r  f  sn     :D}}G 4'88::::<  ==?r%   c                    V ^8  d   QhRRRR/# )r   r   r   r   rD   r    )r!   s   "r"   r#   r#   v  s     6 6& 6T 6r%   c                b    V P                  RR4      f   \        V RR4      R8H  # V P                  # )z
Return whether or not to trim footnote space.

If trim_footnote_reference_space is not None, return it.

If trim_footnote_reference_space is None, return False unless the
footnote reference style is 'superscript'.
trim_footnote_reference_spaceNfootnote_referencessuperscript)rn   rO   r&  )r   s   &r"   get_trim_footnote_ref_spacer)  v  s9     :DAIx!6=NN555r%   c                   V ^8  d   QhRR/# )r   r   z!tuple[StrPath | None, int | None]r    )r!   s   "r"   r#   r#     s     	 	: 	r%   c                    V '       dK   V P                   '       g   V P                  '       d   V P                   V P                  3# V P                  p KR  R# )z_
Return the "source" and "line" attributes from the `node` given or from
its closest ancestor.
)NN)r?   ri   parent)nodes   &r"   rm   rm     s:    
 ;;;$)));;		)){{r%   c                    V ^8  d   QhRRRR/# r   textrG   r   r    )r!   s   "r"   r#   r#     s      c c r%   c                    . p^ p V P                  RV4      pVR8X  d%   VP                  WR 4       RP                  V4      # VP                  WV RW^,           V^,            ,           34       V^,           pKu  )z;Return a string with escape-backslashes converted to nulls.\Nr    rK   )r   rW   r   extend)r0  r  startbs_indexs   &   r"   escape2nullr7    s|    EE
99T5)r>LLf&775>!d*tqLA>>@ 	A1r%   c                    V ^8  d   QhRRRR/# )r   r0  rG   r   r  r    )r!   s   "r"   r#   r#     s     + +3 +9 +r%   c                    V P                  R4      pV Uu. uF  q"P                  R4      NK  	  pp\        \        P                  ! V!  4      # u upi )z\
Split `text` on escaped whitespace (null+space or null+newline).
Return a list of strings.
z  z 
)r   r  	itertoolschain)r0  stringsstrings   &  r"   split_escaped_whitespacer>    sF    
 jj!G4;<G&||H%GG<	)** =s   Ac                    V ^8  d   QhRRRR/# r/  r    )r!   s   "r"   r#   r#     s     D D D Dr%   c                2    R P                  R V  4       4      # )r   c              3  b   "   T F%  p\         P                  ! V4      '       d   K!  Vx  K'  	  R # 5ir'   )unicodedata	combining.0cs   & r"   	<genexpr>(strip_combining_chars.<locals>.<genexpr>  s     Cd+*?*?*B11ds   /
/)r   )r0  s   &r"   strip_combining_charsrI    s    77CdCCCr%   c                    V ^8  d   QhRRRR/# r   r0  rG   r   z	list[int]r    )r!   s   "r"   r#   r#     s     G Gs Gy Gr%   c                    \        V 4       UUu. uF%  w  r\        P                  ! V4      '       g   K#  VNK'  	  upp# u uppi )u   Return indices of all combining chars in  Unicode string `text`.

>>> from docutils.utils import find_combining_chars
>>> find_combining_chars('A t̆ab̆lĕ')
[3, 6, 9]

	enumeraterB  rC  r0  irF  s   &  r"   find_combining_charsrQ    s1     $D/F/$![-B-B1-EAA/FFF    >>c                    V ^8  d   QhRRRR/# rK  r    )r!   s   "r"   r#   r#     s     
K 
K 
K 
Kr%   c                    \        V 4       UUu. uF%  w  r\        P                  ! V4      '       d   K#  VNK'  	  upp# u uppi )u   Indices of Unicode string `text` when skipping combining characters.

>>> from docutils.utils import column_indices
>>> column_indices('A t̆ab̆lĕ')
[0, 1, 2, 4, 5, 7, 8]

rM  rO  s   &  r"   column_indicesrU    s1     $D/J/$!1F1Fq1IAA/JJJrR  WFNaHNAc                    V ^8  d   QhRRRR/# )r   r0  rG   r   r   r    )r!   s   "r"   r#   r#     s     	 	s 	s 	r%   c                `    \        R V  4       4      pV\        \        V 4      4      ,          pV# )ziReturn the column width of text.

Correct ``len(text)`` for wide East Asian and combining Unicode chars.
c              3  d   "   T F&  p\         \        P                  ! V4      ,          x  K(  	  R # 5ir'   )east_asian_widthsrB  east_asian_widthrD  s   & r"   rG  column_width.<locals>.<genexpr>  s*      A "+">">q"ABBs   .0)sumr   rQ  )r0  widths   & r"   column_widthrd    s7    
   E 
S%d+,,ELr%   c                    V ^8  d   QhRRRR/# )r   Lr  r   r    )r!   s   "r"   r#   r#     s      D T r%   c                N    . pV  F  pW!9  g   K  VP                  V4       K  	  V# r'   )rW   )rf  ritems   &  r"   uniqrj    s(    
A=HHTN  Hr%   c                    V ^8  d   QhRRRR/# )r   tagrG   r   r  r    )r!   s   "r"   r#   r#     s       	 r%   c           	        V P                  4       P                  RR4      p \        P                  ! RRV 4      p \	        V P                  R4      4      pVP                  ^ 4      3p\        \        V4      ^ R4       UUu. uF7  p\        P                  ! W4       F  pRP                  W$,           4      NK  	  K9  	  pppWR,          pV# u uppi )a;  Return a list of normalized combinations for a `BCP 47` language tag.

Example:

>>> from docutils.utils import normalize_language_tag
>>> normalize_language_tag('de_AT-1901')
['de-at-1901', 'de-at', 'de-1901', 'de']
>>> normalize_language_tag('de-CH-x_altquot')
['de-ch-x-altquot', 'de-ch', 'de-x-altquot', 'de']

-_z_([a-zA-Z0-9])_z_\1-rK   )r   r   rer   r  r   r   ranger   r:  combinationsr   )rl  subtagsbase_tagntagstaglists   &     r"   normalize_language_tagrx    s     ))+

c3
'C
&&#Wc
2C399S>"GA H c'lAr221$11'=4 xx(= )2   GNs   >=Cc                    V ^8  d   QhRRRR/# )r   rE   zstr | Literal['unicode'] | Noner   rG   r    )r!   s   "r"   r#   r#      s     
< 
<9 
<S 
<r%   c                Z    V '       d   V P                  4       R8w  d   RV  R2pMRpRV R2# )zoReturn an XML text declaration.

Include an encoding declaration, if `encoding`
is not 'unicode', '', or None.
unicodez encoding=""r   z<?xml version="1.0"z?>
)r   )rE   encoding_declarations   & r"   xml_declarationr~     s;     HNN$	1!,XJa8! !5 6d;;r%   c                  Z    ] tR tRtRtRR R lltR R ltR R	 ltR
 R ltR R lt	Rt
R# )DependencyListi  z
List of dependencies, with file recording support.

Note that the output file is not automatically closed.  You have
to explicitly call the close() method.
Nc               $    V ^8  d   QhRRRRRR/# )r   output_fileLiteral['-'] | StrPath | Nonedependenciesr  r   r   r    )r!   s   "r"   r#   DependencyList.__annotate__  s&        ; 0   r%   c                H    V P                  V4       V P                  ! V!   R# )z
Initialize the dependency list, automatically setting the
output file to `output_file` (see `set_output()`) and adding
all supplied dependencies.

If output_file is None, no file output is done when calling add().
N)
set_outputadd)r+   r  r  s   &&&r"   r)   DependencyList.__init__  s     	$,r%   c                    V ^8  d   QhRRRR/# )r   r  r  r   r   r    )r!   s   "r"   r#   r  $  s      &? D r%   c                    VR8X  d   \         P                  V n        M#V'       d   \        VRRR7      V n        MRV n        . V n        R# )z
Set the output file and clear the list of already added
dependencies.

The specified file is immediately overwritten.

If `output_file` is '-', the output will be written to stdout.
The empty string or None stop output.
rn  wr   )rE   N)r   stdoutfileopenr  r+   r  s   &&r"   r  DependencyList.set_output$  s8     #

DI[#@DIDI	r%   c                    V ^8  d   QhRRRR/# )r   pathsr   r   r   r    )r!   s   "r"   r#   r  6  s     / /' /d /r%   c                "   V F  p\        V\        4      '       d   VP                  4       pW P                  9  g   K;  V P                  P	                  V4       V P
                  f   Kf  V P
                  P                  VR,           4       K  	  R# )z
Append `path` to `self.list` unless it is already there.

Also append to `self.file` unless it is already there
or `self.file is `None`.
Nrk   )rM   r   r  r  rW   r  rq   )r+   r  r   s   &* r"   r  DependencyList.add6  s`     D$))}}99$		  &99(IIOODI. r%   c                   V ^8  d   QhRR/# )r   r   r   r    )r!   s   "r"   r#   r  E  s      t r%   c                    V P                   \        P                  Jd   V P                   P                  4        RV n         R# )z
Close the output file.
N)r  r   r  close)r+   s   &r"   r  DependencyList.closeE  s)     99CJJ&IIOO	r%   c                   V ^8  d   QhRR/# )r   r   rG   r    )r!   s   "r"   r#   r  M  s     P P# Pr%   c                	     V P                   P                  pV P                  P                  : RV: RV P
                  : R2#   \         d    R p L;i ; i)N(z, r   )r  r   rp   r   r-   r  r  s   & r"   __repr__DependencyList.__repr__M  sG    	))..K  $~~66TYYOO  	K	s   A AA)r  r  )Nr    )r-   r.   r/   r0   r   r)   r  r  r  r  r1   r    r%   r"   r  r    s'     $/P Pr%   r  r'   )I__conditional_annotations__r   
__future__r   __docformat__r:  r   os.pathrp  r   rB  r
  pathlibr   r   r   r   r   r   r	   docutils.nodesr
   TYPE_CHECKINGcollections.abcr   r   r   typingr   r   r   r   docutils.utils._typingr   r   docutils.frontendr   r   r   r   r   r3   r6   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r)  rm   r7  r>  rI  rQ  rU  r_  rd  rj  rx  r~  r  )r  s   @r"   <module>r     s  
 #"  	  	 
   " 0  #<<220&(')=)=(>(DEM9E$ 	/ 	UG UGp ,9 + 0) 0 4- 4 6/ 6;6!H F &Y %2'T$"J
4n#D 6	+DG
K !!1!!! 	6
<EP EPr%   