
    
3j:                    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/wildlama/miniconda3/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                  SSSSS9 Hi  n[        U[        R                  [        R
                  45      (       a  M4  US==   UR                  S   -  ss'   UR                  R                  U5          g    U R                  R                  R                  SUR                  S   -  [        R                  " UR                  UR                  5      UR                  S9nUR                  U5        g )	NFT)include_selfdescendsiblingsascendclassesclassz,No suitable element following "%s" directive	directive)line)r   findall
isinstancer   	Invisiblesystem_messager   r   r   documentreportererrorliteral_block	rawsourcer.   replace_self)r   r   elementr5   s       r   r   ClassAttribute.apply.   s    ..E504T ' CG'EOOU5I5I#JKKI'//'"::NN!!'*C &&,,:ook*+ 1 173D3DE	 - 
 	U#r   r   Nr   r   r   r   r   r#   r#   %   s    
 $r   r#   c                  :    \ rS rSrSrSrS	S jrS	S jrS	S jrSr	g)
Transitions@   a  
Post-process <transition> elements.

Move transitions at the end of sections up the tree.
Warn on transitions at the beginning or end of the document or
a section (ignoring title, decoration, or invisible elements),
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)r3   r/   r   
transitionvisit_transition)r   nodes     r   r   Transitions.apply\   s/    MM))%*:*:;D!!$' <r   c                   Sn[        UR                  [        R                  [        R                  45      (       d  U R                  SU5        O UR                  5         SU;   a  UR                  nUR                  nUbq  UR                  U5      nU[        U5      S-
  :  a1  UR                  R                  U5        UR                  US-   U5        O/UR                  nUR                  nUb  Mq  U R                  SU5        SU;   a+  U R                  SUR                  R                   S3U5        g S	U;   a  U R                  S
U5        g g ! [        R                   a  n[        U5      n S nAGNS nAff = f)N z:Transition only valid as child of <document> or <section>.zmay not end   z&Transition at the end of the document.zmay not beginzTransition at the start of the .zmay not directly followz6At least one body element should separate transitions.)r0   r   r   r3   sectionwarnvalidate_positionValidationErrorstrindexlenr   inserttagname)r   rA   msgesiblingr   rL   s          r   r@   Transitions.visit_transition`   sJ   $++'FGGII &'+-&&( CkkG^^F$W-3v;?*KK&&t,MM%!)T2!..  $ 		BDIc!II78K8K7LAN&#-IIN .' (( !fs   E E9#E44E9c                   U R                   R                  R                  XS9nS[        UR                  R
                  5      ;   a9  UR                  R                  UR                  R                  U5      S-   U5        g g )N)	base_nodez
nodes.BodyrE   )r3   r4   warningreprr   content_modelrN   rL   )r   rP   rA   rV   s       r   rH   Transitions.warn   sc    --((000E4 9 9::KKt{{006q8'B ;r   r   Nr   )
r   r   r   r   r   r    r   r@   rH   r!   r   r   r   r<   r<   @   s    2 (>Cr   r<   N)r   
__future__r   __docformat__docutilsr   docutils.transformsr   r   r#   r<   r   r   r   <module>r^      sB   
 #"  )'y '($Y $6CC) CCr   