B \@sXdZdZddlmZddlmZmZGdddeZGdddeZGd d d eZ d S) z Miscellaneous transforms. ZreStructuredText)nodes) TransformTransformErrorc@seZdZdZdZddZdS)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. icCs$|j}|jd||j|dS)Ncallback) startnodedetailsparentremove)selfpendingr ...
... into this::
...
... i>cCs&x |jtjD]}||qWdS)N)rZtraverser transitionvisit_transition)r noder r rr`szTransitions.applycCs|j|}d}|dksLt|jdtjr|dksLt|jdtjr|dkrt|jtjslt|jtjslt|jj j d|j |j d}n.t|j|dtj r|jj j d|j |j d}|r|j|||d7}|t|jkst|t|jdkrdS|}xh|t|jdkrb|j}|jdkrT|jj j d|j d}|j|j|d|dS|j|}qW|j||j|d|dS) Nrrz4Document or section may not begin with a transition.)sourcerzZAt least one body element must separate transitions; adjacent transitions are not allowed.z'Document may not end with a transition.)r)r rrrtitleZsubtitlersectionAssertionErrorr r!r)rr%insertrr )r r'rr!Zsiblingr r rr&dsD    zTransitions.visit_transitionN)rrrrrrr&r r r rr$Fsr$N) rZ __docformat__ZdocutilsrZdocutils.transformsrrrrr$r r r rs  #