From 8252a44b36b80dc64f70b92666b525f5b44f2d4c Mon Sep 17 00:00:00 2001 From: wiemann Date: Sun, 11 Sep 2005 22:23:43 +0000 Subject: added writer_aux module containing Compound transform, which flattens the compound paragraph structure git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3872 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/transforms/writer_aux.py | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 docutils/transforms/writer_aux.py (limited to 'docutils/transforms/writer_aux.py') diff --git a/docutils/transforms/writer_aux.py b/docutils/transforms/writer_aux.py new file mode 100644 index 000000000..99e961243 --- /dev/null +++ b/docutils/transforms/writer_aux.py @@ -0,0 +1,52 @@ +# Authors: Felix Wiemann +# Contact: Felix_Wiemann@ososo.de +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +Auxiliary transforms mainly to be used by Writer components. + +This module is called "writer_aux" because otherwise there would be +conflicting imports like this one:: + + from docutils import writers + from docutils.transforms import writers +""" + +__docformat__ = 'reStructuredText' + +from docutils import nodes, utils +from docutils.transforms import Transform + + +class Compound(Transform): + + """ + Flatten all compound paragraphs. For example, transform :: + + + + + + + into :: + + + + + """ + + default_priority = 810 + + def apply(self): + for compound in self.document.traverse(nodes.compound): + first_child = 1 + for child in compound: + if first_child: + if not isinstance(child, nodes.Invisible): + first_child = 0 + else: + child['classes'].append('continued') + # Substitute children for compound. + compound.substitute(compound[:]) -- cgit v1.2.1 From 69fadff9ca4f067b3042b6383989ce638ff4d42d Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 26 Sep 2005 18:17:31 +0000 Subject: renamed Element.substitute to Element.replace_self git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3909 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/transforms/writer_aux.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/transforms/writer_aux.py') diff --git a/docutils/transforms/writer_aux.py b/docutils/transforms/writer_aux.py index 99e961243..74ac4d4f6 100644 --- a/docutils/transforms/writer_aux.py +++ b/docutils/transforms/writer_aux.py @@ -49,4 +49,4 @@ class Compound(Transform): else: child['classes'].append('continued') # Substitute children for compound. - compound.substitute(compound[:]) + compound.replace_self(compound[:]) -- cgit v1.2.1