
    -Ph	                     z    d Z dZddlmZ ddlmZ  G d de          Z G d de          Z G d	 d
e          ZdS )z
Miscellaneous transforms.
reStructuredText    )nodes)	Transformc                       e Zd ZdZdZd ZdS )CallBacka  
    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                 t    | j         } |j        d         |           |j                            |           d S )Ncallback)	startnodedetailsparentremove)selfpendings     X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/docutils/transforms/misc.pyapplyzCallBack.apply   s<    .#
#G,,,g&&&&&    N__name__
__module____qualname____doc__default_priorityr    r   r   r   r      s5          ' ' ' ' 'r   r   c                       e Zd ZdZdZd ZdS )ClassAttributez|
    Move the "class" attribute specified in the "pending" node into the
    immediately following non-comment element.
       c                 b   | j         }|j        }|}|rt          |                    |          dz   t	          |                    D ]v}||         }t          |t          j                  st          |t          j                  r?|dxx         |j	        d         z  cc<   |j        
                    |            d S |}|j        }|| j        j                            d|j	        d         z  t          j        |j        |j                  |j                  }|                    |           d S )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%   elementr,   s          r   r   zClassAttribute.apply,   sD   . 	'v||E22Q6FDD ' ' -w88 !'5+?@@	"""gog&>>"""%%g...   	' &,,:ok*+ 173DEE	 -  
 	U#####r   Nr   r   r   r   r   r   #   s5         
 $ $ $ $ $r   r   c                   "    e Zd ZdZdZd Zd ZdS )Transitionsa  
    Move transitions at the end of sections up the tree.  Complain
    on transitions after a title, 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                 ~    | j                             t          j                  D ]}|                     |           d S )N)r*   findallr   
transitionvisit_transition)r   nodes     r   r   zTransitions.apply`   sE    M))%*:;; 	( 	(D!!$''''	( 	(r   c                    |j                             |          }d }|dk    sVt          |j         d         t          j                  r|dk    s+t          |j         d         t          j                  rs|dk    rmt          |j         t          j                  s!t          |j         t          j                  sJ | j        j        	                    d|j
        |j                  }nTt          |j         |dz
           t          j                  r,| j        j        	                    d|j
        |j                  }|r |j                             ||           |dz  }|t          |j                   k     sJ |t          |j                   dz
  k    rd S |}|t          |j                   dz
  k    r|j         }|j         ^| j        j        	                    d|j                  }|j                             |j                             |          dz   |           d S |j                             |          }|t          |j                   dz
  k    |j                             |           |j                             |dz   |           d S )	Nr   r      z4Document or section may not begin with a transition.)sourcer#   zZAt least one body element must separate transitions; adjacent transitions are not allowed.z'Document may not end with a transition.r"   )r   r%   r'   r   titlesubtitler*   sectionr+   r,   r;   r#   r6   insertr&   r   )r   r8   r%   r,   siblings        r   r7   zTransitions.visit_transitiond   sx   !!$''QJJ$+a.%+66 !t{1~u~>> aZZt{EN;; ?!$+u}==? ? ?M*00F{ 1 4 4EE EAI.0@AA 	4M*008{ 1 4 4E  	Kue,,,QJEs4;''''''C$$q(((Fs7>**Q...nG~% .44= 5 $ $ ""4;#4#4T#:#:Q#>FFFN((11E s7>**Q... 	4   eai.....r   N)r   r   r   r   r   r   r7   r   r   r   r3   r3   F   sD         , ( ( (,/ ,/ ,/ ,/ ,/r   r3   N)	r   __docformat__docutilsr   docutils.transformsr   r   r   r3   r   r   r   <module>rD      s   
  #       ) ) ) ) ) )' ' ' ' 'y ' ' '( $  $  $  $  $Y  $  $  $FJ/ J/ J/ J/ J/) J/ J/ J/ J/ J/r   