U å€C^ã@sXdZdZddlmZddlmZmZGdd„deƒZGdd„deƒZGd d „d eƒZ d S) z Miscellaneous transforms. ZreStructuredTexté)Únodes)Ú TransformÚTransformErrorc@seZdZdZdZdd„ZdS)Ú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ÞcCs$|j}|jd|ƒ|j |¡dS)NÚcallback)Ú startnodeÚdetailsÚparentÚremove)ÚselfÚpending©r ú>/tmp/pip-install-6_kvzl1k/docutils/docutils/transforms/misc.pyÚapplyszCallBack.applyN©Ú__name__Ú __module__Ú __qualname__Ú__doc__Údefault_priorityrr r r rrs rc@seZdZdZdZdd„ZdS)ÚClassAttributez| Move the "class" attribute specified in the "pending" node into the immediately following non-comment element. éÒcCsÀ|j}|j}|}|r†t| |¡dt|ƒƒD]L}||}t|tjƒs,t|tjƒrRq,|d|j d7<|j  |¡dS|}|j}q|j j j d|j dt |j|j¡|jd�}| |¡dS)NéÚclassesÚclassz,No suitable element following "%s" directiveÚ directive©Úline)rr ÚrangeÚindexÚlenÚ isinstancerZ InvisibleZsystem_messagerr ÚdocumentÚreporterÚerrorZ literal_blockZ rawsourcerZ replace_self)r r r ÚchildrÚelementr$r r rr,s.  ÿ ÿüzClassAttribute.applyNrr r r rr#src@s$eZdZdZdZdd„Zdd„ZdS)Ú 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::
...
... into this::
...
... i>cCs"|j tj¡D]}| |¡qdS)N)r"ZtraverserÚ transitionÚvisit_transition)r Únoder r rr`szTransitions.applycCs‚|j |¡}d}|dksLt|jdtjƒr†|dksLt|jdtjƒr†|dkr†t|jtjƒslt|jtjƒslt‚|jj j d|j |j d�}n.t|j|dtj ƒr´|jj j d|j |j d�}|rÎ|j ||¡|d7}|t|jƒksàt‚|t|jƒdkrödS|}|t|jƒdk�r`|j}|jdk�rR|jj j d|j d�}|j |j |¡d|¡dS|j |¡}qú|j |¡|j |d|¡dS) Nrréz4Document 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 rr!rÚtitleZsubtitler"ÚsectionÚAssertionErrorr#r$r,rr(Úinsertr r )r r*rr$Zsiblingr r rr)dsX ÿþýü ÿþý þ zTransitions.visit_transitionN)rrrrrrr)r r r rr'Fsr'N) rZ __docformat__ZdocutilsrZdocutils.transformsrrrrr'r r r rÚs  #