コード例 #1
0
    def test_transition_levels(self):
        # Make the XML
        xml, deps = rst2xml(
            b'Intro\n\n====\n\nLevel 1\n\n====\n\nLevel 1\n\n----\n\nLevel 2\n\n'
            b'....\n\nLevel 3\n\n----\n\nLevel 2\n\n....\n\nLevel 3\n\n'
            b'====\n\nLevel 1')

        target_start = (
            b'<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE document PUBLIC "+'
            b'//IDN docutils.sourceforge.net//DTD Docutils Generic//EN//XML" '
            b'"http://docutils.sourceforge.net/docs/ref/docutils.dtd">\n')
        target_end = (
            b'<document source="&lt;string&gt;"><paragraph>Intro</paragraph>'
            b'<transition level="1"></transition><paragraph>Level 1</paragraph>'
            b'<transition level="1"></transition><paragraph>Level 1</paragraph>'
            b'<transition level="2"></transition><paragraph>Level 2</paragraph>'
            b'<transition level="3"></transition><paragraph>Level 3</paragraph>'
            b'<transition level="2"></transition><paragraph>Level 2</paragraph>'
            b'<transition level="3"></transition><paragraph>Level 3</paragraph>'
            b'<transition level="1"></transition><paragraph>Level 1</paragraph>'
            b'</document>')
        self.assertTrue(xml.startswith(target_start))
        self.assertTrue(xml.endswith(target_end))

        # Make the slides:
        tree = SlideMaker(etree.fromstring(xml)).walk()

        target = (
            b'<document source="&lt;string&gt;"><paragraph>Intro</paragraph>'
            b'<step class="step step-level-1" step="0"><paragraph>Level 1</paragraph></step>'
            b'<step class="step step-level-1" step="1"><paragraph>Level 1</paragraph>'
            b'<step class="step step-level-2" step="2"><paragraph>Level 2</paragraph>'
            b'<step class="step step-level-3" step="3"><paragraph>Level 3</paragraph></step>'
            b'</step><step class="step step-level-2" step="4"><paragraph>Level 2</paragraph>'
            b'<step class="step step-level-3" step="5"><paragraph>Level 3</paragraph></step>'
            b'</step></step><step class="step step-level-1" step="6"><paragraph>Level 1'
            b'</paragraph></step></document>'
        )
        self.assertEqual(etree.tostring(tree), target)
コード例 #2
0
def make_tree(file_name):
    """Loads reStructuredText, outputs an lxml tree"""
    rst = resource_string(__name__, os.path.join('test_data', file_name))
    xml = rst2xml(rst)
    return SlideMaker(etree.fromstring(xml)).walk()
コード例 #3
0
ファイル: test_parse.py プロジェクト: spollard/hovercraft
def make_tree(file_name):
    """Loads reStructuredText, outputs an lxml tree"""
    rst = resource_string(__name__, file_name)
    xml, dependencies = rst2xml(rst)
    return etree.fromstring(xml)
コード例 #4
0
ファイル: test_parse.py プロジェクト: cgswong/hovercraft
def make_tree(file_name):
    """Loads reStructuredText, outputs an lxml tree"""
    rst = resource_string(__name__, file_name)
    xml, dependencies = rst2xml(rst)
    return etree.fromstring(xml)
コード例 #5
0
def make_tree(file_name):
    """Loads reStructuredText, outputs an lxml tree"""
    rst = resource_string(__name__, os.path.join('test_data', file_name))
    xml, deps = rst2xml(rst)
    return SlideMaker(etree.fromstring(xml)).walk()