summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docutils/transforms/misc.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/docutils/transforms/misc.py b/docutils/transforms/misc.py
new file mode 100644
index 000000000..cf26f6c3b
--- /dev/null
+++ b/docutils/transforms/misc.py
@@ -0,0 +1,33 @@
+# 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)