1
|
|
|
from unittest import TestCase |
2
|
|
|
|
3
|
|
|
from panflute import convert_text, Para, Image |
4
|
|
|
|
5
|
|
|
import pandoc_beamer_block |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
class BlockTest(TestCase): |
9
|
|
|
@classmethod |
10
|
|
|
def conversion(cls, markdown, fmt="markdown"): |
11
|
|
|
doc = convert_text(markdown, standalone=True) |
12
|
|
|
doc.format = fmt |
13
|
|
|
pandoc_beamer_block.main(doc) |
14
|
|
|
return doc |
15
|
|
|
|
16
|
|
|
def test_simple(self): |
17
|
|
|
doc = BlockTest.conversion( |
18
|
|
|
""" |
19
|
|
|
--- |
20
|
|
|
pandoc-beamer-block: |
21
|
|
|
- classes: ['class1', 'class2'] |
22
|
|
|
--- |
23
|
|
|
::: {.class1 .class2} |
24
|
|
|
::: |
25
|
|
|
""", |
26
|
|
|
"beamer", |
27
|
|
|
) |
28
|
|
|
text = convert_text( |
29
|
|
|
doc, |
30
|
|
|
input_format="panflute", |
31
|
|
|
output_format="latex", |
32
|
|
|
extra_args=["--wrap=none"], |
33
|
|
|
) |
34
|
|
|
self.assertIn("\\begin{block}", text) |
35
|
|
|
self.assertIn("\\end{block}", text) |
36
|
|
|
|
37
|
|
|
def test_title(self): |
38
|
|
|
doc = BlockTest.conversion( |
39
|
|
|
""" |
40
|
|
|
--- |
41
|
|
|
pandoc-beamer-block: |
42
|
|
|
- classes: ['class1', 'class2'] |
43
|
|
|
--- |
44
|
|
|
::: {.class1 .class2 title="My Title"} |
45
|
|
|
::: |
46
|
|
|
""", |
47
|
|
|
"beamer", |
48
|
|
|
) |
49
|
|
|
text = convert_text( |
50
|
|
|
doc, |
51
|
|
|
input_format="panflute", |
52
|
|
|
output_format="latex", |
53
|
|
|
extra_args=["--wrap=none"], |
54
|
|
|
) |
55
|
|
|
self.assertIn("\\begin{block}{My Title}", text) |
56
|
|
|
self.assertIn("\\end{block}", text) |
57
|
|
|
|
58
|
|
|
def test_theorem(self): |
59
|
|
|
doc = BlockTest.conversion( |
60
|
|
|
""" |
61
|
|
|
--- |
62
|
|
|
pandoc-beamer-block: |
63
|
|
|
- classes: ['theorem'] |
64
|
|
|
type: theorem |
65
|
|
|
--- |
66
|
|
|
::: {.theorem title="My Title"} |
67
|
|
|
::: |
68
|
|
|
""", |
69
|
|
|
"beamer", |
70
|
|
|
) |
71
|
|
|
text = convert_text( |
72
|
|
|
doc, |
73
|
|
|
input_format="panflute", |
74
|
|
|
output_format="latex", |
75
|
|
|
extra_args=["--wrap=none"], |
76
|
|
|
) |
77
|
|
|
self.assertIn("\\begin{theorem}[My Title]", text) |
78
|
|
|
self.assertIn("\\end{theorem}", text) |
79
|
|
|
|
80
|
|
|
def test_alert(self): |
81
|
|
|
doc = BlockTest.conversion( |
82
|
|
|
""" |
83
|
|
|
--- |
84
|
|
|
pandoc-beamer-block: |
85
|
|
|
- classes: ['class1', 'class2'] |
86
|
|
|
type: alert |
87
|
|
|
--- |
88
|
|
|
::: {.class1 .class2} |
89
|
|
|
::: |
90
|
|
|
""", |
91
|
|
|
"beamer", |
92
|
|
|
) |
93
|
|
|
text = convert_text( |
94
|
|
|
doc, |
95
|
|
|
input_format="panflute", |
96
|
|
|
output_format="latex", |
97
|
|
|
extra_args=["--wrap=none"], |
98
|
|
|
) |
99
|
|
|
self.assertIn("\\begin{alertblock}", text) |
100
|
|
|
self.assertIn("\\end{alertblock}", text) |
101
|
|
|
|
102
|
|
|
def test_example(self): |
103
|
|
|
doc = BlockTest.conversion( |
104
|
|
|
""" |
105
|
|
|
--- |
106
|
|
|
pandoc-beamer-block: |
107
|
|
|
- classes: ['class1', 'class2'] |
108
|
|
|
type: example |
109
|
|
|
--- |
110
|
|
|
::: {.class1 .class2} |
111
|
|
|
::: |
112
|
|
|
""", |
113
|
|
|
"beamer", |
114
|
|
|
) |
115
|
|
|
text = convert_text( |
116
|
|
|
doc, |
117
|
|
|
input_format="panflute", |
118
|
|
|
output_format="latex", |
119
|
|
|
extra_args=["--wrap=none"], |
120
|
|
|
) |
121
|
|
|
self.assertIn("\\begin{exampleblock}", text) |
122
|
|
|
self.assertIn("\\end{exampleblock}", text) |
123
|
|
|
|
124
|
|
|
def test_title_complex(self): |
125
|
|
|
doc = BlockTest.conversion( |
126
|
|
|
""" |
127
|
|
|
--- |
128
|
|
|
pandoc-beamer-block: |
129
|
|
|
- classes: ['class1', 'class2'] |
130
|
|
|
--- |
131
|
|
|
::: {.class1 .class2 title="**My Title**"} |
132
|
|
|
::: |
133
|
|
|
""", |
134
|
|
|
"beamer", |
135
|
|
|
) |
136
|
|
|
text = convert_text( |
137
|
|
|
doc, |
138
|
|
|
input_format="panflute", |
139
|
|
|
output_format="latex", |
140
|
|
|
extra_args=["--wrap=none"], |
141
|
|
|
) |
142
|
|
|
self.assertIn("\\begin{block}{\\textbf{My Title}}", text) |
143
|
|
|
self.assertIn("\\end{block}", text) |
144
|
|
|
|