diff options
| author | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-09-11 20:54:18 +0000 |
|---|---|---|
| committer | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-09-11 20:54:18 +0000 |
| commit | 963bd1c5e6b84ae881a1046be9f95fc8b18547d3 (patch) | |
| tree | 5c5712acca8993c1c3aad3a700c4e16ce01b3a10 /docutils/nodes.py | |
| parent | 4bab3b641ddd264e0b3b3dad289c088758ed4cf2 (diff) | |
| download | docutils-963bd1c5e6b84ae881a1046be9f95fc8b18547d3.tar.gz | |
added Element.substitute()
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3866 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/nodes.py')
| -rw-r--r-- | docutils/nodes.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/docutils/nodes.py b/docutils/nodes.py index af1ba59f5..b7ee898c0 100644 --- a/docutils/nodes.py +++ b/docutils/nodes.py @@ -569,6 +569,17 @@ class Element(Node): elif new is not None: self[index:index+1] = new + def substitute(self, new): + """ + Substitute `new` for `self` node, where `new` is a node or + list of nodes. + """ + if isinstance(new, Node): + new.update(self) + else: + new[0].update(self) + self.parent.replace(self, new) + def first_child_matching_class(self, childclass, start=0, end=sys.maxint): """ Return the index of the first child whose class exactly matches. |
