Ejemplo n.º 1
0
    def test_scan_after_attribute_tag2(self):
        doc = dedent("""\
                        test \\tag this \\tag{inline \\tag{} \\tag}\\tag
                        other tag
                        """)
        parser = QqParser(allowed_tags={"tag"})
        parser.parse_init(doc)
        start = parser.position(0, 0)
        stop = parser.position(None, 0)
        tag_positoin, tag, type, after = parser.locate_tag(start, stop)

        start = after.copy()
        before = parser.scan_after_attribute_tag(start, stop)
        self.assertEqual(start.clipped_line(before),
                         'this \\tag{inline \\tag{} \\tag}')
Ejemplo n.º 2
0
    def test_inline_tag_contents(self):
        doc = dedent("""\
                    haha \\tag{this}{
                        that}[another]{this
                        }[okay test] stop
                """)
        parser = QqParser(allowed_tags={"tag"})
        parser.parse_init(doc)
        start = parser.position(0, 0)
        stop = parser.position(None, 0)
        tag_position, tag, type, after = parser.locate_tag(start, stop)
        self.assertEqual(start.clipped_line(tag_position), "haha ")
        self.assertEqual(tag, "tag")
        self.assertEqual(type, "inline")

        items = parser.inline_tag_contents(after, stop)
        contents = ["".join(item['start'].lines_before(item['stop']))
                    for item in items]
        self.assertEqual(contents,
                         ["this", "\n    that",
                          "another", "this\n    ", "okay test"])
        self.assertEqual([item['type'] for item in items],
                         ['{', '{', '[', '{', '['])