コード例 #1
0
    def test_bullet(self):
        self.buffer.insert_at_cursor("end1\nend2\n")
        self.buffer.place_cursor(self.buffer.get_start_iter())
        #self.buffer.indent()
        self.buffer.toggle_bullet_list()
        self.buffer.insert_at_cursor("line1\n")

        contents = list(
            iter_buffer_contents(self.buffer, None, None, ignore_tag))

        dom = TextBufferDom(
            normalize_tags(find_paragraphs(
                nest_indent_tags(self.get_contents(), self.buffer.tag_table)),
                           is_stable_tag=lambda tag: isinstance(
                               tag, RichTextIndentTag) or tag == P_TAG))
        self.io.prepare_dom_write(dom)
        print
        dom.display()

        # check the internal indentation structure
        self.assertEquals([display_item(x) for x in contents], [
            'BEGIN:bullet', 'BEGIN:indent 1 bullet', u'\u2022 ', 'END:bullet',
            'line1\n', 'BEGIN:bullet', u'\u2022 ', 'END:bullet', 'end1\n',
            'END:indent 1 bullet', 'end2\n'
        ])

        outfile = StringIO()
        self.write(self.buffer, outfile)

        self.assertEquals(
            outfile.getvalue(), '<ul><li>line1</li>\n'
            '<li>end1</li>\n</ul>\nend2<br/>\n')
コード例 #2
0
    def test_par(self):
        self.read(self.buffer,
                  StringIO("""word1 <b>word2<br/>\nword3</b> word4<br/>\n"""))

        contents = list(
            normalize_tags(find_paragraphs(self.get_contents()),
                           is_stable_tag=lambda tag: tag == P_TAG))

        self.assertEquals([display_item(x) for x in contents], [
            'BEGIN:p', 'word1 ', 'BEGIN:bold', 'word2\n', 'END:bold', 'END:p',
            'BEGIN:bold', 'END:bold', 'BEGIN:p', 'BEGIN:bold', 'word3',
            'END:bold', ' word4\n', 'END:p'
        ])
コード例 #3
0
    def test_bullet(self):
        self.buffer.insert_at_cursor("end1\nend2\n")
        self.buffer.place_cursor(self.buffer.get_start_iter())
        #self.buffer.indent()
        self.buffer.toggle_bullet_list()
        self.buffer.insert_at_cursor("line1\n")

        contents = list(iter_buffer_contents(self.buffer,
                                             None, None, ignore_tag))

        dom = TextBufferDom(
            normalize_tags(find_paragraphs(
                nest_indent_tags(self.get_contents(), self.buffer.tag_table)),
                is_stable_tag=lambda tag:
                isinstance(tag, RichTextIndentTag) or
                tag == P_TAG))
        self.io.prepare_dom_write(dom)
        print
        dom.display()

        # check the internal indentation structure
        self.assertEquals([display_item(x) for x in contents],
                          ['BEGIN:bullet',
                           'BEGIN:indent 1 bullet',
                           u'\u2022 ',
                           'END:bullet',
                           'line1\n',
                           'BEGIN:bullet',
                           u'\u2022 ',
                           'END:bullet',
                           'end1\n',
                           'END:indent 1 bullet',
                           'end2\n'])

        outfile = StringIO()
        self.write(self.buffer, outfile)

        self.assertEquals(outfile.getvalue(),
                          '<ul><li>line1</li>\n'
                          '<li>end1</li>\n</ul>\nend2<br/>\n')
コード例 #4
0
    def test_par(self):
        self.read(self.buffer, StringIO(
            """word1 <b>word2<br/>\nword3</b> word4<br/>\n"""))

        contents = list(normalize_tags(
            find_paragraphs(self.get_contents()),
            is_stable_tag=lambda tag: tag == P_TAG))

        self.assertEquals([display_item(x) for x in contents],
                          ['BEGIN:p',
                           'word1 ',
                           'BEGIN:bold',
                           'word2\n',
                           'END:bold',
                           'END:p',
                           'BEGIN:bold',
                           'END:bold',
                           'BEGIN:p',
                           'BEGIN:bold',
                           'word3',
                           'END:bold',
                           ' word4\n',
                           'END:p'])