Your IP : 216.73.216.213
!e�K � @ sx d Z d Z d d l m Z d d l m Z m Z Gd d � d e � Z Gd d � d e � Z Gd d
� d
e � Z d S)z
Miscellaneous transforms.
ZreStructuredText� )�nodes)� Transform�TransformErrorc @ s( e Z d Z d Z d Z d 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 C s. | j } | j d | � | j j | � d S)N�callback)� startnode�details�parent�remove)�self�pending� r
�I/opt/alt/python35/lib/python3.5/site-packages/docutils/transforms/misc.py�apply s zCallBack.applyN)�__name__�
__module__�__qualname__�__doc__�default_priorityr r
r
r
r r s
r c @ s( e Z d Z d Z d Z d d � Z d S)�ClassAttributez|
Move the "class" attribute specified in the "pending" node into the
immediately following non-comment element.
�� c C s | j } | j } | } x� | r� x� t | j | � d t | � � D]] } | | } t | t j � sD t | t j � r{ qD | d | j d 7<| j j
| � d SW| } | j } q W| j j j
d | j d t j | j | j � d | j �} | j | � d S)N� �classes�classz,No suitable element following "%s" directiveZ directive�line)r r �range�index�len�
isinstancer Z InvisibleZsystem_messager r
�document�reporter�errorZ
literal_blockZ rawsourcer Zreplace_self)r r r Zchildr �elementr! r
r
r r , s( )
zClassAttribute.applyN)r r r r r r r
r
r
r r # s r c @ s4 e Z d Z d Z d Z d d � Z d 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 C s1 x* | j j t j � D] } | j | � q Wd S)N)r Ztraverser �
transition�visit_transition)r �noder
r
r r ` s zTransitions.applyc C s' | j j | � } d } | d k sn t | j d t j � r� | d k sn t | j d t j � r� | d k r� t | j t j � s� t | j t j � s� t � | j j j
d d | j d | j �} nD t | j | d t j
� r| j j j
d d | j d | j �} | r/| j j | | � | d 7} | t | j � k sJt � | t | j � d k rgd S| } x� | t | j � d k r�| j } | j d k r�| j j j
d d | j �} | j j | j j | � d | � d S| j j | � } qpW| j j | � | j j | d | � 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 �titleZsubtitler �section�AssertionErrorr r! r( r r$ �insertr r
)r r&