Passed
Push — develop ( 75c20b...40e5a0 )
by Christophe
01:10
created

test_tables.TableTest.test_table()   A

Complexity

Conditions 2

Size

Total Lines 48
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 16
nop 1
dl 0
loc 48
rs 9.6
c 0
b 0
f 0
1
from unittest import TestCase
2
3
from panflute import convert_text
4
from panflute.tools import PandocVersion
5
import pandoc_glfm
6
7
version = PandocVersion().version
8
9
10
class TableTest(TestCase):
11
    @classmethod
12
    def conversion(cls, markdown, fmt="markdown"):
13
        doc = convert_text(markdown, standalone=True)
14
        doc.format = fmt
15
        pandoc_glfm.main(doc)
16
        return doc
17
18
    def test_table(self):
19
        doc = TableTest.conversion(
20
            """
21
| Name | Details |
22
| ---  | ---     |
23
| Item1 | This text is on one line |
24
|       | This item has:<br><br>- Multiple items<br>- That we want listed separately |
25
            """,
26
        )
27
        text = convert_text(
28
            doc,
29
            input_format="panflute",
30
            output_format="markdown",
31
        )
32
33
        if version < (3, 6, 4):
34
            self.assertEqual(
35
                text,
36
                """
37
+-----------------------------------+-----------------------------------+
38
| Name                              | Details                           |
39
+===================================+===================================+
40
| Item1                             | This text is on one line          |
41
+-----------------------------------+-----------------------------------+
42
|                                   | This item has:                    |
43
|                                   |                                   |
44
|                                   | -   Multiple items                |
45
|                                   | -   That we want listed           |
46
|                                   |     separately                    |
47
+-----------------------------------+-----------------------------------+
48
                  """.strip()
49
            )
50
51
        else:
52
            self.assertEqual(
53
                text,
54
                """
55
+-----------------------------------+-----------------------------------+
56
| Name                              | Details                           |
57
+===================================+===================================+
58
| Item1                             | This text is on one line          |
59
+-----------------------------------+-----------------------------------+
60
|                                   | This item has:                    |
61
|                                   |                                   |
62
|                                   | - Multiple items                  |
63
|                                   | - That we want listed separately  |
64
+-----------------------------------+-----------------------------------+
65
                  """.strip()
66
            )
67