34 lines
917 B
Python
34 lines
917 B
Python
|
# Author: David Goodger
|
||
|
# Contact: goodger@users.sourceforge.net
|
||
|
# Revision: $Revision$
|
||
|
# Date: $Date$
|
||
|
# Copyright: This module has been placed in the public domain.
|
||
|
|
||
|
"""
|
||
|
Miscellaneous transforms.
|
||
|
"""
|
||
|
|
||
|
__docformat__ = 'reStructuredText'
|
||
|
|
||
|
from docutils.transforms import Transform, TransformError
|
||
|
|
||
|
|
||
|
class CallBack(Transform):
|
||
|
|
||
|
"""
|
||
|
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.
|
||
|
"""
|
||
|
|
||
|
default_priority = 990
|
||
|
|
||
|
def apply(self):
|
||
|
pending = self.startnode
|
||
|
pending.details['callback'](pending)
|
||
|
pending.parent.remove(pending)
|