1
|
|
|
from unittest import TestCase |
2
|
|
|
|
3
|
|
|
from .helper import verify_conversion |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
class ParaTest(TestCase): |
7
|
|
|
def test_para_none( |
8
|
|
|
self, |
9
|
|
|
): |
10
|
|
|
verify_conversion(self, "Not an example", "Not an example") |
11
|
|
|
|
12
|
|
|
def test_para(self): |
13
|
|
|
verify_conversion( |
14
|
|
|
self, |
15
|
|
|
r""" |
16
|
|
|
Example # |
17
|
|
|
|
18
|
|
|
Example # |
19
|
|
|
""", |
20
|
|
|
r""" |
21
|
|
|
[**Example 1**]{#example:1 .pandoc-numbering-text .example} |
22
|
|
|
|
23
|
|
|
[**Example 2**]{#example:2 .pandoc-numbering-text .example} |
24
|
|
|
""", |
25
|
|
|
) |
26
|
|
|
|
27
|
|
|
def test_para_title( |
28
|
|
|
self, |
29
|
|
|
): |
30
|
|
|
verify_conversion( |
31
|
|
|
self, |
32
|
|
|
r""" |
33
|
|
|
Example (This is the first title) # |
34
|
|
|
|
35
|
|
|
Example (This is the second title) # |
36
|
|
|
""", |
37
|
|
|
r""" |
38
|
|
|
[]{#example:this-is-the-first-title}[**Example 1** *(This is the first title)*]{#example:1 .pandoc-numbering-text .example} |
39
|
|
|
|
40
|
|
|
[]{#example:this-is-the-second-title}[**Example 2** *(This is the second title)*]{#example:2 .pandoc-numbering-text .example} |
41
|
|
|
""", |
42
|
|
|
) |
43
|
|
|
|
44
|
|
|
def test_para_prefix_single(self): |
45
|
|
|
verify_conversion( |
46
|
|
|
self, |
47
|
|
|
"Example #ex:", |
48
|
|
|
"[**Example 1**]{#ex:1 .pandoc-numbering-text .ex}", |
49
|
|
|
) |
50
|
|
|
|
51
|
|
|
def test_para_double(self): |
52
|
|
|
verify_conversion( |
53
|
|
|
self, |
54
|
|
|
r""" |
55
|
|
|
Example # |
56
|
|
|
|
57
|
|
|
Example # |
58
|
|
|
""", |
59
|
|
|
r""" |
60
|
|
|
[**Example 1**]{#example:1 .pandoc-numbering-text .example} |
61
|
|
|
|
62
|
|
|
[**Example 2**]{#example:2 .pandoc-numbering-text .example} |
63
|
|
|
""", |
64
|
|
|
) |
65
|
|
|
|
66
|
|
|
def test_para_sectioning(self): |
67
|
|
|
verify_conversion( |
68
|
|
|
self, |
69
|
|
|
r""" |
70
|
|
|
First chapter |
71
|
|
|
============= |
72
|
|
|
|
73
|
|
|
Second chapter |
74
|
|
|
============== |
75
|
|
|
|
76
|
|
|
First section |
77
|
|
|
------------- |
78
|
|
|
|
79
|
|
|
Second section |
80
|
|
|
-------------- |
81
|
|
|
|
82
|
|
|
Exercise -.+.# |
83
|
|
|
""", |
84
|
|
|
r""" |
85
|
|
|
# First chapter |
86
|
|
|
|
87
|
|
|
# Second chapter |
88
|
|
|
|
89
|
|
|
## First section |
90
|
|
|
|
91
|
|
|
## Second section |
92
|
|
|
|
93
|
|
|
[]{#exercise:second-chapter.second-section.1}[**Exercise 2.1**]{#exercise:2.2.1 .pandoc-numbering-text .exercise} |
94
|
|
|
""", |
95
|
|
|
) |
96
|
|
|
|
97
|
|
|
def test_para_numbering_hidden(self): |
98
|
|
|
verify_conversion( |
99
|
|
|
self, |
100
|
|
|
r""" |
101
|
|
|
First chapter |
102
|
|
|
============= |
103
|
|
|
|
104
|
|
|
Exercise -.#exercise:one |
105
|
|
|
|
106
|
|
|
Exercise -.# |
107
|
|
|
|
108
|
|
|
Second chapter |
109
|
|
|
============== |
110
|
|
|
|
111
|
|
|
Exercise -.# |
112
|
|
|
|
113
|
|
|
Exercise -.# |
114
|
|
|
|
115
|
|
|
Exercice # |
116
|
|
|
""", |
117
|
|
|
r""" |
118
|
|
|
# First chapter |
119
|
|
|
|
120
|
|
|
[]{#exercise:first-chapter.1}[**Exercise 1**]{#exercise:one .pandoc-numbering-text .exercise} |
121
|
|
|
|
122
|
|
|
[]{#exercise:first-chapter.2}[**Exercise 2**]{#exercise:1.2 .pandoc-numbering-text .exercise} |
123
|
|
|
|
124
|
|
|
# Second chapter |
125
|
|
|
|
126
|
|
|
[]{#exercise:second-chapter.1}[**Exercise 1**]{#exercise:2.1 .pandoc-numbering-text .exercise} |
127
|
|
|
|
128
|
|
|
[]{#exercise:second-chapter.2}[**Exercise 2**]{#exercise:2.2 .pandoc-numbering-text .exercise} |
129
|
|
|
|
130
|
|
|
[**Exercice 1**]{#exercice:1 .pandoc-numbering-text .exercice} |
131
|
|
|
""", |
132
|
|
|
) |
133
|
|
|
|
134
|
|
|
def test_para_sectioning_unnumbered(self): |
135
|
|
|
verify_conversion( |
136
|
|
|
self, |
137
|
|
|
r""" |
138
|
|
|
Unnumbered chapter {#unnumbered-chapter .unnumbered} |
139
|
|
|
================== |
140
|
|
|
|
141
|
|
|
Exercise +.# |
142
|
|
|
""", |
143
|
|
|
r""" |
144
|
|
|
# Unnumbered chapter {#unnumbered-chapter .unnumbered} |
145
|
|
|
|
146
|
|
|
[]{#exercise:unnumbered-chapter.1}[**Exercise 0.1**]{#exercise:0.1 .pandoc-numbering-text .exercise} |
147
|
|
|
""", |
148
|
|
|
) |
149
|
|
|
|
150
|
|
|
def test_para_numbering_level(self): |
151
|
|
|
verify_conversion( |
152
|
|
|
self, |
153
|
|
|
r""" |
154
|
|
|
Exercise +.+.# |
155
|
|
|
|
156
|
|
|
First chapter |
157
|
|
|
============= |
158
|
|
|
|
159
|
|
|
First section |
160
|
|
|
------------- |
161
|
|
|
|
162
|
|
|
Exercise +.+.# |
163
|
|
|
|
164
|
|
|
Exercise +.+.# |
165
|
|
|
|
166
|
|
|
Second section |
167
|
|
|
-------------- |
168
|
|
|
|
169
|
|
|
Exercise +.+.# |
170
|
|
|
""", |
171
|
|
|
r""" |
172
|
|
|
[**Exercise 0.0.1**]{#exercise:0.0.1 .pandoc-numbering-text .exercise} |
173
|
|
|
|
174
|
|
|
# First chapter |
175
|
|
|
|
176
|
|
|
## First section |
177
|
|
|
|
178
|
|
|
[]{#exercise:first-chapter.first-section.1}[**Exercise 1.1.1**]{#exercise:1.1.1 .pandoc-numbering-text .exercise} |
179
|
|
|
|
180
|
|
|
[]{#exercise:first-chapter.first-section.2}[**Exercise 1.1.2**]{#exercise:1.1.2 .pandoc-numbering-text .exercise} |
181
|
|
|
|
182
|
|
|
## Second section |
183
|
|
|
|
184
|
|
|
[]{#exercise:first-chapter.second-section.1}[**Exercise 1.2.1**]{#exercise:1.2.1 .pandoc-numbering-text .exercise} |
185
|
|
|
""", |
186
|
|
|
) |
187
|
|
|
|
188
|
|
|
def test_numbering_latex(self): |
189
|
|
|
verify_conversion( |
190
|
|
|
self, |
191
|
|
|
r""" |
192
|
|
|
Exercise (Equation $a=b$) # |
193
|
|
|
""", |
194
|
|
|
r""" |
195
|
|
|
--- |
196
|
|
|
header-includes: |
197
|
|
|
- | |
198
|
|
|
` |
199
|
|
|
\makeatletter |
200
|
|
|
\@ifpackageloaded{subfig}{ |
201
|
|
|
\usepackage[subfigure]{tocloft} |
202
|
|
|
}{ |
203
|
|
|
\usepackage{tocloft} |
204
|
|
|
} |
205
|
|
|
\makeatother |
206
|
|
|
`{=tex} |
207
|
|
|
- "`\\usepackage{etoolbox}`{=tex}" |
208
|
|
|
- "`\\ifdef{\\mainmatter}{\\let\\oldmainmatter\\mainmatter\\renewcommand{\\mainmatter}[0]{\\oldmainmatter}}{}`{=tex}" |
209
|
|
|
--- |
210
|
|
|
|
211
|
|
|
` |
212
|
|
|
\makeatletter |
213
|
|
|
\@ifpackageloaded{subfig}{ |
214
|
|
|
\usepackage[subfigure]{tocloft} |
215
|
|
|
}{ |
216
|
|
|
\usepackage{tocloft} |
217
|
|
|
} |
218
|
|
|
\makeatother |
219
|
|
|
`{=tex} |
220
|
|
|
|
221
|
|
|
`\usepackage{etoolbox}`{=tex} |
222
|
|
|
|
223
|
|
|
`\ifdef{\mainmatter}{\let\oldmainmatter\mainmatter\renewcommand{\mainmatter}[0]{\oldmainmatter}}{}`{=tex} |
224
|
|
|
|
225
|
|
|
`\ifdef{\mainmatter}{}{}`{=tex} |
226
|
|
|
|
227
|
|
|
`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1}{\ignorespaces {Equation \(a=b\)}}}`{=tex}[]{#exercise:equation-a-b}[**Exercise 1** *(Equation $a=b$`<!-- -->`{=html})*]{#exercise:1 .pandoc-numbering-text .exercise} |
228
|
|
|
""", |
229
|
|
|
"latex", |
230
|
|
|
) |
231
|
|
|
|