root/galaxy-central/eggs/docutils-0.4-py2.6.egg/docutils/transforms/writer_aux.py

リビジョン 3, 1.4 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1# Authors: Felix Wiemann
2# Contact: Felix_Wiemann@ososo.de
3# Revision: $Revision: 3909 $
4# Date: $Date: 2005-09-26 20:17:31 +0200 (Mon, 26 Sep 2005) $
5# Copyright: This module has been placed in the public domain.
6
7"""
8Auxiliary transforms mainly to be used by Writer components.
9
10This module is called "writer_aux" because otherwise there would be
11conflicting imports like this one::
12
13    from docutils import writers
14    from docutils.transforms import writers
15"""
16
17__docformat__ = 'reStructuredText'
18
19from docutils import nodes, utils
20from docutils.transforms import Transform
21
22
23class Compound(Transform):
24
25    """
26    Flatten all compound paragraphs.  For example, transform ::
27
28        <compound>
29            <paragraph>
30            <literal_block>
31            <paragraph>
32
33    into ::
34
35        <paragraph>
36        <literal_block classes="continued">
37        <paragraph classes="continued">
38    """
39
40    default_priority = 810
41
42    def apply(self):
43        for compound in self.document.traverse(nodes.compound):
44            first_child = 1
45            for child in compound:
46                if first_child:
47                    if not isinstance(child, nodes.Invisible):
48                        first_child = 0
49                else:
50                    child['classes'].append('continued')
51            # Substitute children for compound.
52            compound.replace_self(compound[:])
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。