AlertsTest.test_blockquote_rest_title()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 23
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 23
rs 9.85
c 0
b 0
f 0
cc 1
nop 1
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 AlertsTest(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_blockquote_empty(self):
19
        doc = self.conversion(
20
            """
21
> [!note]
22
            """,
23
        )
24
        text = convert_text(
25
            doc,
26
            input_format="panflute",
27
            output_format="markdown",
28
        )
29
        self.assertEqual(
30
            text,
31
            """
32
:::: note
33
::: title
34
Note
35
:::
36
::::
37
            """.strip()
38
        )
39
40
    def test_blockquote_rest(self):
41
        doc = self.conversion(
42
            """
43
> [!note]
44
> **rest**
45
            """,
46
        )
47
        text = convert_text(
48
            doc,
49
            input_format="panflute",
50
            output_format="markdown",
51
        )
52
        self.assertEqual(
53
            text,
54
            """
55
:::: note
56
::: title
57
Note
58
:::
59
60
**rest**
61
::::
62
            """.strip()
63
        )
64
65
    def test_blockquote_newline(self):
66
        doc = self.conversion(
67
            """
68
> [!note]
69
>
70
> **rest**
71
            """,
72
        )
73
        text = convert_text(
74
            doc,
75
            input_format="panflute",
76
            output_format="markdown",
77
        )
78
        self.assertEqual(
79
            text,
80
            """
81
:::: note
82
::: title
83
Note
84
:::
85
86
**rest**
87
::::
88
            """.strip()
89
        )
90
91
92
    def test_blockquote_empty_title(self):
93
        doc = self.conversion(
94
            """
95
> [!note] My title
96
            """,
97
        )
98
        text = convert_text(
99
            doc,
100
            input_format="panflute",
101
            output_format="markdown",
102
        )
103
        self.assertEqual(
104
            text,
105
            """
106
:::: note
107
::: title
108
My title
109
:::
110
::::
111
            """.strip()
112
        )
113
114
    def test_blockquote_rest_title(self):
115
        doc = self.conversion(
116
            """
117
> [!note] My title
118
> **rest**
119
            """,
120
        )
121
        text = convert_text(
122
            doc,
123
            input_format="panflute",
124
            output_format="markdown",
125
        )
126
        self.assertEqual(
127
            text,
128
            """
129
:::: note
130
::: title
131
My title
132
:::
133
134
**rest**
135
::::
136
            """.strip()
137
        )
138
139
    def test_blockquote_newline_title(self):
140
        doc = AlertsTest.conversion(
141
            """
142
> [!note] My title
143
>
144
> **rest**
145
            """,
146
        )
147
        text = convert_text(
148
            doc,
149
            input_format="panflute",
150
            output_format="markdown",
151
        )
152
        self.assertEqual(
153
            text,
154
            """
155
:::: note
156
::: title
157
My title
158
:::
159
160
**rest**
161
::::
162
            """.strip()
163
        )
164
165
    def test_blockquote_bullet(self):
166
        doc = self.conversion(
167
            """
168
> [!note] My title
169
> * **a**
170
> * b
171
>
172
> * c
173
            """,
174
        )
175
        text = convert_text(
176
            doc,
177
            input_format="panflute",
178
            output_format="markdown",
179
        )
180
        if version < (3, 6, 4):
181
            self.assertEqual(
182
                text,
183
                """
184
:::: note
185
::: title
186
My title
187
:::
188
189
-   **a**
190
-   b
191
-   c
192
::::
193
                """.strip()
194
            )
195
        else:
196
            self.assertEqual(
197
                text,
198
                """
199
:::: note
200
::: title
201
My title
202
:::
203
204
- **a**
205
- b
206
- c
207
::::
208
                """.strip()
209
            )
210