
    k7i                    r    S r SSKJr  SrSSKJr  SSKJr   " S S\5      r " S S	\5      r	 " S
 S\5      r
g)z
Miscellaneous transforms.
    )annotationsreStructuredText)nodes)	Transformc                  &    \ rS rSrSrSrSS jrSrg)CallBack   a  
Inserts a callback into a document.  The callback is called when the
transform is applied, which is determined by its priority.

For use with `nodes.pending` elements.  Requires a ``details['callback']``
entry, a bound method or function which takes one parameter: the pending
node.  Other data can be stored in the ``details`` attribute or in the
object hosting the callback method.
i  c                |    U R                   nUR                  S   " U5        UR                  R                  U5        g )Ncallback)	startnodedetailsparentremove)selfpendings     R/home/james-whalen/.local/lib/python3.13/site-packages/docutils/transforms/misc.pyapplyCallBack.apply   s.    ..
#G,g&     NreturnNone__name__
__module____qualname____firstlineno____doc__default_priorityr   __static_attributes__r   r   r   r   r      s     'r   r   c                  &    \ rS rSrSrSrSS jrSrg)ClassAttribute%   z[
Move the "class" attribute specified in the "pending" node into the
next visible element.
   c                   U R                   nUR                  nUnU(       a  [        UR                  U5      S-   [	        U5      5       H|  nX$   n[        U[        R                  5      (       d  [        U[        R                  5      (       a  MG  US==   UR                  S   -  ss'   UR                  R                  U5          g    UnUR                  nU(       a  M  U R                  R                  R                  SUR                  S   -  [        R                  " UR                  UR                  5      UR                   S9nUR#                  U5        g )N   classesclassz,No suitable element following "%s" directive	directive)line)r   r   rangeindexlen
isinstancer   	Invisiblesystem_messager   r   documentreportererrorliteral_block	rawsourcer+   replace_self)r   r   r   childr-   elementr4   s          r   r   ClassAttribute.apply.   s   ..v||E2Q6FD -w88!'5+?+?@@	"goog&>>"%%g. E  f &&,,:ook*+ 1 173D3DE	 - 
 	U#r   r   Nr   r   r   r   r   r#   r#   %   s    
 $r   r#   c                  0    \ rS rSrSrSrSS jrSS jrSrg)	TransitionsH   a  
Move transitions at the end of sections up the tree.  Complain
on transitions after a title, subtitle, meta, or decoration element,
at the beginning or end of the document, and after another transition.

For example, transform this::

    <section>
        ...
        <transition>
    <section>
        ...

into this::

    <section>
        ...
    <transition>
    <section>
        ...
i>  c                    U R                   R                  [        R                  5       H  nU R	                  U5        M     g )N)r2   findallr   
transitionvisit_transition)r   nodes     r   r   Transitions.applyb   s/    MM))%*:*:;D!!$' <r   c                   UR                   R                  U5      nUR                  5       nSn[        UR                   [        R
                  [        R                  45      (       d  SnOwUS:X  dM  [        U[        R                  [        R                  [        R                  [        R                  45      (       a  SnO![        U[        R                  5      (       a  SnU(       a  U R
                  R                  R                  XAS9n[        R                  " 5       UR                   U'    UR                   R                  SS9  XR                   U'   UR                   R!                  US	-   U5        US	-  n[        UR                   [        R
                  [        R                  45      (       d  g U[%        UR                   5      :  d   eU[%        UR                   5      S	-
  :w  a  g UnU[%        UR                   5      S	-
  :X  a  UR                   nUR                   c@  U R
                  R                  R                  S
US9nUR                   R'                  U5        g UR                   R                  U5      nU[%        UR                   5      S	-
  :X  a  M  UR                   R)                  U5        UR                   R!                  US	-   U5        g ! [        R"                   a    XR                   U'    GNf = f)N z4Transition must be child of <document> or <section>.r   z4Document or section may not begin with a transition.zZAt least one body element must separate transitions; adjacent transitions are not allowed.)	base_nodeF)	recursiver'   z'Document may not end with a transition.)r   r-   previous_siblingr/   r   r2   sectiontitlesubtitlemeta
decorationr@   r3   warning	paragraphvalidateinsertValidationErrorr.   appendr   )r   rB   r-   rH   msgrN   siblings          r   rA   Transitions.visit_transitionf   sa   !!$'002$++'FGGHCaZ:&69>9>9>9I9I9K L L IC(%*:*:;;;Cmm,,44S4IG!&!2DKK$$u$5 &*E"""57G4
$++'FGGs4;;''''C$q((s7>>*Q..nnG~~% --0088G(, 9 . ""7+NN((1E s7>>*Q.. 	4 eai.; (( *%)E"*s   .K "K<;K<r   Nr   )	r   r   r   r   r   r    r   rA   r!   r   r   r   r<   r<   H   s    , (1/r   r<   N)r   
__future__r   __docformat__docutilsr   docutils.transformsr   r   r#   r<   r   r   r   <module>r[      sA   
 #"  )'y '( $Y  $FO/) O/r   