def table_emit(self, node):
     self._table = MarkupTable(head_prefix=self.table_head_prefix,
                               auto_width=self.table_auto_width,
                               debug_msg=self.debug_msg)
     self.emit_children(node)
     content = self._table.get_table_markup()
     return "%s\n" % content
Exemple #2
0
    def test_markup_table_rest(self):
        t = MarkupTable(head_prefix="")
        t.add_tr()
        t.add_th("head1")
        t.add_th("head2")
        t.add_tr()
        t.add_td("1.1.")
        t.add_td("1.2.")
        t.add_tr()
        t.add_td("2.1.")
        t.add_td("2.2.")
        table = t.get_rest_table()

        self.assertEqual2(
            table,
            """
            +-------+-------+
            | head1 | head2 |
            +=======+=======+
            | 1.1.  | 1.2.  |
            +-------+-------+
            | 2.1.  | 2.2.  |
            +-------+-------+
            """
        )
Exemple #3
0
 def table_emit(self, node):
     """
     http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#tables
     """
     self._table = MarkupTable(head_prefix="",
                               auto_width=True,
                               debug_msg=self.debug_msg)
     self.emit_children(node)
     content = self._table.get_rest_table()
     return "%s\n\n" % content
Exemple #4
0
    def test_markup_table_textile(self):
        t = MarkupTable(head_prefix="_. ", auto_width=False)
        t.add_tr()
        t.add_th("head1")
        t.add_th("head2")
        t.add_tr()
        t.add_td("1.1.")
        t.add_td("1.2.")
        t.add_tr()
        t.add_td("2.1.")
        t.add_td("2.2.")
        table = t.get_table_markup()

        self.assertEqual2(
            table, """
            |_. head1|_. head2|
            |1.1.|1.2.|
            |2.1.|2.2.|
            """)
Exemple #5
0
    def test_markup_table_creole(self):
        t = MarkupTable(head_prefix="* ")
        t.add_tr()
        t.add_th("head1")
        t.add_th("head2")
        t.add_tr()
        t.add_td("1.1.")
        t.add_td("1.2.")
        t.add_tr()
        t.add_td("2.1.")
        t.add_td("2.2.")
        table = t.get_table_markup()

        self.assertEqual2(
            table, """
            |* head1 |* head2 |
            | 1.1.   | 1.2.   |
            | 2.1.   | 2.2.   |
            """)