Qc@sxdZdZddlmZddlmZmZdefdYZdefdYZd efd YZ d S( s Miscellaneous transforms. treStructuredTexti(tnodes(t TransformtTransformErrortCallBackcBseZdZdZdZRS(s 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||jj|dS(Ntcallback(t startnodetdetailstparenttremove(tselftpending((s</usr/lib/python2.7/site-packages/docutils/transforms/misc.pytapplys (t__name__t __module__t__doc__tdefault_priorityR (((s</usr/lib/python2.7/site-packages/docutils/transforms/misc.pyRs tClassAttributecBseZdZdZdZRS(s| Move the "class" attribute specified in the "pending" node into the immediately following non-comment element. icCs |j}|j}|}x|rxt|j|dt|D]b}||}t|tjsDt|tjr~qDn|dc|j d7<|jj |dSW|}|j}qW|j j j d|j dtj|j|jd|j}|j|dS(Nitclassestclasss,No suitable element following "%s" directivet directivetline(RRtrangetindextlent isinstanceRt Invisibletsystem_messageRR tdocumenttreporterterrort literal_blockt rawsourceRt replace_self(R R RtchildRtelementR((s</usr/lib/python2.7/site-packages/docutils/transforms/misc.pyR ,s(   )     (R RRRR (((s</usr/lib/python2.7/site-packages/docutils/transforms/misc.pyR#st TransitionscBs&eZdZdZdZdZRS(s 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>cCs1x*|jjtjD]}|j|qWdS(N(RttraverseRt transitiontvisit_transition(R tnode((s</usr/lib/python2.7/site-packages/docutils/transforms/misc.pyR `sc Cs|jj|}d}|dksnt|jdtjr|dksnt|jdtjr|dkr|jjj dd|j d|j }nGt|j|dtj r|jjj dd|j d|j }n|r|jj |||d7}n|t|jdkr"dS|}x|t|jdkr|j}|jdkr|jjj dd|j }|jj |jj|d|dS|jj|}q+W|jj||jj |d|dS( Niiis4Document or section may not begin with a transition.tsourceRsZAt least one body element must separate transitions; adjacent transitions are not allowed.s'Document may not end with a transition.(RRtNoneRRttitletsubtitleRRRR)RR&tinsertRR (R R(RRtsibling((s</usr/lib/python2.7/site-packages/docutils/transforms/misc.pyR'ds>         #(R RRRR R'(((s</usr/lib/python2.7/site-packages/docutils/transforms/misc.pyR$Fs N( Rt __docformat__tdocutilsRtdocutils.transformsRRRRR$(((s</usr/lib/python2.7/site-packages/docutils/transforms/misc.pyts #