|
1
|
|
|
from unittest import TestCase |
|
2
|
|
|
|
|
3
|
|
|
from .helper import verify_conversion |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
class ListingsTest(TestCase): |
|
7
|
|
|
def test_listing_classic(self): |
|
8
|
|
|
verify_conversion( |
|
9
|
|
|
self, |
|
10
|
|
|
r""" |
|
11
|
|
|
--- |
|
12
|
|
|
pandoc-numbering: |
|
13
|
|
|
exercise: |
|
14
|
|
|
general: |
|
15
|
|
|
listing-title: List of exercises |
|
16
|
|
|
--- |
|
17
|
|
|
|
|
18
|
|
|
Exercise # |
|
19
|
|
|
|
|
20
|
|
|
Exercise (Title) # |
|
21
|
|
|
""", |
|
22
|
|
|
r""" |
|
23
|
|
|
--- |
|
24
|
|
|
pandoc-numbering: |
|
25
|
|
|
exercise: |
|
26
|
|
|
general: |
|
27
|
|
|
listing-title: List of exercises |
|
28
|
|
|
--- |
|
29
|
|
|
|
|
30
|
|
|
# List of exercises {#list-of-exercises .pandoc-numbering-listing .exercise .unnumbered .unlisted} |
|
31
|
|
|
|
|
32
|
|
|
- [[Exercise 1]{.pandoc-numbering-entry .exercise}](#exercise:1) |
|
33
|
|
|
- [[Title]{.pandoc-numbering-entry .exercise}](#exercise:2) |
|
34
|
|
|
|
|
35
|
|
|
[**Exercise 1**]{#exercise:1 .pandoc-numbering-text .exercise .exercise-1} |
|
36
|
|
|
|
|
37
|
|
|
[]{#exercise:title}[**Exercise 2** *(Title)*]{#exercise:2 .pandoc-numbering-text .exercise .exercise-2} |
|
38
|
|
|
""", |
|
39
|
|
|
) |
|
40
|
|
|
|
|
41
|
|
|
def test_listing_identifier_false(self): |
|
42
|
|
|
verify_conversion( |
|
43
|
|
|
self, |
|
44
|
|
|
r""" |
|
45
|
|
|
--- |
|
46
|
|
|
pandoc-numbering: |
|
47
|
|
|
exercise: |
|
48
|
|
|
general: |
|
49
|
|
|
listing-identifier: False |
|
50
|
|
|
listing-title: List of exercises |
|
51
|
|
|
--- |
|
52
|
|
|
|
|
53
|
|
|
Exercise # |
|
54
|
|
|
|
|
55
|
|
|
Exercise (Title) # |
|
56
|
|
|
""", |
|
57
|
|
|
r""" |
|
58
|
|
|
--- |
|
59
|
|
|
pandoc-numbering: |
|
60
|
|
|
exercise: |
|
61
|
|
|
general: |
|
62
|
|
|
listing-identifier: false |
|
63
|
|
|
listing-title: List of exercises |
|
64
|
|
|
--- |
|
65
|
|
|
|
|
66
|
|
|
# List of exercises {.pandoc-numbering-listing .exercise .unnumbered .unlisted} |
|
67
|
|
|
|
|
68
|
|
|
- [[Exercise 1]{.pandoc-numbering-entry .exercise}](#exercise:1) |
|
69
|
|
|
- [[Title]{.pandoc-numbering-entry .exercise}](#exercise:2) |
|
70
|
|
|
|
|
71
|
|
|
[**Exercise 1**]{#exercise:1 .pandoc-numbering-text .exercise .exercise-1} |
|
72
|
|
|
|
|
73
|
|
|
[]{#exercise:title}[**Exercise 2** *(Title)*]{#exercise:2 .pandoc-numbering-text .exercise .exercise-2} |
|
74
|
|
|
""", |
|
75
|
|
|
) |
|
76
|
|
|
|
|
77
|
|
|
def test_listing_identifier(self): |
|
78
|
|
|
verify_conversion( |
|
79
|
|
|
self, |
|
80
|
|
|
r""" |
|
81
|
|
|
--- |
|
82
|
|
|
pandoc-numbering: |
|
83
|
|
|
exercise: |
|
84
|
|
|
general: |
|
85
|
|
|
listing-identifier: myident |
|
86
|
|
|
listing-title: List of exercises |
|
87
|
|
|
--- |
|
88
|
|
|
|
|
89
|
|
|
Exercise # |
|
90
|
|
|
|
|
91
|
|
|
Exercise (Title) # |
|
92
|
|
|
""", |
|
93
|
|
|
r""" |
|
94
|
|
|
--- |
|
95
|
|
|
pandoc-numbering: |
|
96
|
|
|
exercise: |
|
97
|
|
|
general: |
|
98
|
|
|
listing-identifier: myident |
|
99
|
|
|
listing-title: List of exercises |
|
100
|
|
|
--- |
|
101
|
|
|
|
|
102
|
|
|
# List of exercises {#myident .pandoc-numbering-listing .exercise .unnumbered .unlisted} |
|
103
|
|
|
|
|
104
|
|
|
- [[Exercise 1]{.pandoc-numbering-entry .exercise}](#exercise:1) |
|
105
|
|
|
- [[Title]{.pandoc-numbering-entry .exercise}](#exercise:2) |
|
106
|
|
|
|
|
107
|
|
|
[**Exercise 1**]{#exercise:1 .pandoc-numbering-text .exercise .exercise-1} |
|
108
|
|
|
|
|
109
|
|
|
[]{#exercise:title}[**Exercise 2** *(Title)*]{#exercise:2 .pandoc-numbering-text .exercise .exercise-2} |
|
110
|
|
|
""", |
|
111
|
|
|
) |
|
112
|
|
|
|
|
113
|
|
|
def test_listing_options(self): |
|
114
|
|
|
verify_conversion( |
|
115
|
|
|
self, |
|
116
|
|
|
r""" |
|
117
|
|
|
--- |
|
118
|
|
|
pandoc-numbering: |
|
119
|
|
|
exercise: |
|
120
|
|
|
general: |
|
121
|
|
|
listing-title: List of exercises |
|
122
|
|
|
listing-unlisted: False |
|
123
|
|
|
listing-unnumbered: False |
|
124
|
|
|
--- |
|
125
|
|
|
|
|
126
|
|
|
Exercise # |
|
127
|
|
|
|
|
128
|
|
|
Exercise (Title) # |
|
129
|
|
|
""", |
|
130
|
|
|
r""" |
|
131
|
|
|
--- |
|
132
|
|
|
pandoc-numbering: |
|
133
|
|
|
exercise: |
|
134
|
|
|
general: |
|
135
|
|
|
listing-title: List of exercises |
|
136
|
|
|
listing-unlisted: false |
|
137
|
|
|
listing-unnumbered: false |
|
138
|
|
|
--- |
|
139
|
|
|
|
|
140
|
|
|
# List of exercises {#list-of-exercises .pandoc-numbering-listing .exercise} |
|
141
|
|
|
|
|
142
|
|
|
- [[Exercise 1]{.pandoc-numbering-entry .exercise}](#exercise:1) |
|
143
|
|
|
- [[Title]{.pandoc-numbering-entry .exercise}](#exercise:2) |
|
144
|
|
|
|
|
145
|
|
|
[**Exercise 1**]{#exercise:1 .pandoc-numbering-text .exercise .exercise-1} |
|
146
|
|
|
|
|
147
|
|
|
[]{#exercise:title}[**Exercise 2** *(Title)*]{#exercise:2 .pandoc-numbering-text .exercise .exercise-2} |
|
148
|
|
|
""", |
|
149
|
|
|
) |
|
150
|
|
|
|
|
151
|
|
|
def test_listing_latex(self): |
|
152
|
|
|
verify_conversion( |
|
153
|
|
|
self, |
|
154
|
|
|
r""" |
|
155
|
|
|
--- |
|
156
|
|
|
pandoc-numbering: |
|
157
|
|
|
exercise: |
|
158
|
|
|
general: |
|
159
|
|
|
listing-title: List of exercises |
|
160
|
|
|
--- |
|
161
|
|
|
|
|
162
|
|
|
Exercise # |
|
163
|
|
|
|
|
164
|
|
|
Exercise (Title) # |
|
165
|
|
|
""", |
|
166
|
|
|
r""" |
|
167
|
|
|
--- |
|
168
|
|
|
header-includes: |
|
169
|
|
|
- | |
|
170
|
|
|
` |
|
171
|
|
|
\makeatletter |
|
172
|
|
|
\@ifpackageloaded{subfig}{ |
|
173
|
|
|
\usepackage[subfigure]{tocloft} |
|
174
|
|
|
}{ |
|
175
|
|
|
\usepackage{tocloft} |
|
176
|
|
|
} |
|
177
|
|
|
\makeatother |
|
178
|
|
|
`{=tex} |
|
179
|
|
|
- "`\\usepackage{etoolbox}`{=tex}" |
|
180
|
|
|
- "`\\newlistof{exercise}{exercise}{List of exercises}\\renewcommand{\\cftexercisetitlefont}{\\cfttoctitlefont}\\setlength{\\cftexercisenumwidth}{\\cftfignumwidth}\\setlength{\\cftexerciseindent}{\\cftfigindent}`{=tex}" |
|
181
|
|
|
- "`\\ifdef{\\mainmatter}{\\let\\oldmainmatter\\mainmatter\\renewcommand{\\mainmatter}[0]{\\phantomsection\\label{list-of-exercises}\\listofexercise\\oldmainmatter}}{}`{=tex}" |
|
182
|
|
|
pandoc-numbering: |
|
183
|
|
|
exercise: |
|
184
|
|
|
general: |
|
185
|
|
|
listing-title: List of exercises |
|
186
|
|
|
--- |
|
187
|
|
|
|
|
188
|
|
|
` |
|
189
|
|
|
\makeatletter |
|
190
|
|
|
\@ifpackageloaded{subfig}{ |
|
191
|
|
|
\usepackage[subfigure]{tocloft} |
|
192
|
|
|
}{ |
|
193
|
|
|
\usepackage{tocloft} |
|
194
|
|
|
} |
|
195
|
|
|
\makeatother |
|
196
|
|
|
`{=tex} |
|
197
|
|
|
|
|
198
|
|
|
`\usepackage{etoolbox}`{=tex} |
|
199
|
|
|
|
|
200
|
|
|
`\newlistof{exercise}{exercise}{List of exercises}\renewcommand{\cftexercisetitlefont}{\cfttoctitlefont}\setlength{\cftexercisenumwidth}{\cftfignumwidth}\setlength{\cftexerciseindent}{\cftfigindent}`{=tex} |
|
201
|
|
|
|
|
202
|
|
|
`\ifdef{\mainmatter}{\let\oldmainmatter\mainmatter\renewcommand{\mainmatter}[0]{\phantomsection\label{list-of-exercises}\listofexercise\oldmainmatter}}{}`{=tex} |
|
203
|
|
|
|
|
204
|
|
|
`\ifdef{\mainmatter}{}{\phantomsection\label{list-of-exercises}\listofexercise}`{=tex} |
|
205
|
|
|
|
|
206
|
|
|
`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1}{\ignorespaces {Exercise}}}`{=tex}[**Exercise 1**]{#exercise:1 .pandoc-numbering-text .exercise .exercise-1} |
|
207
|
|
|
|
|
208
|
|
|
`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {2}{\ignorespaces {Title}}}`{=tex}[]{#exercise:title}[**Exercise 2** *(Title)*]{#exercise:2 .pandoc-numbering-text .exercise .exercise-2} |
|
209
|
|
|
""", |
|
210
|
|
|
"latex", |
|
211
|
|
|
) |
|
212
|
|
|
|
|
213
|
|
|
def test_listing_classic_format(self): |
|
214
|
|
|
verify_conversion( |
|
215
|
|
|
self, |
|
216
|
|
|
r""" |
|
217
|
|
|
--- |
|
218
|
|
|
pandoc-numbering: |
|
219
|
|
|
exercise: |
|
220
|
|
|
general: |
|
221
|
|
|
listing-title: List of exercises |
|
222
|
|
|
standard: |
|
223
|
|
|
format-entry-classic: '%g %D' |
|
224
|
|
|
format-entry-title: '%g %D (%T)' |
|
225
|
|
|
--- |
|
226
|
|
|
|
|
227
|
|
|
Exercise # |
|
228
|
|
|
|
|
229
|
|
|
Exercise (Title) # |
|
230
|
|
|
""", |
|
231
|
|
|
r""" |
|
232
|
|
|
--- |
|
233
|
|
|
pandoc-numbering: |
|
234
|
|
|
exercise: |
|
235
|
|
|
general: |
|
236
|
|
|
listing-title: List of exercises |
|
237
|
|
|
standard: |
|
238
|
|
|
format-entry-classic: "%g %D" |
|
239
|
|
|
format-entry-title: "%g %D (%T)" |
|
240
|
|
|
--- |
|
241
|
|
|
|
|
242
|
|
|
# List of exercises {#list-of-exercises .pandoc-numbering-listing .exercise .unnumbered .unlisted} |
|
243
|
|
|
|
|
244
|
|
|
- [[1 Exercise]{.pandoc-numbering-entry .exercise}](#exercise:1) |
|
245
|
|
|
- [[2 Exercise (Title)]{.pandoc-numbering-entry .exercise}](#exercise:2) |
|
246
|
|
|
|
|
247
|
|
|
[**Exercise 1**]{#exercise:1 .pandoc-numbering-text .exercise .exercise-1} |
|
248
|
|
|
|
|
249
|
|
|
[]{#exercise:title}[**Exercise 2** *(Title)*]{#exercise:2 .pandoc-numbering-text .exercise .exercise-2} |
|
250
|
|
|
""", |
|
251
|
|
|
) |
|
252
|
|
|
|
|
253
|
|
|
def test_listing_latex_format(self): |
|
254
|
|
|
verify_conversion( |
|
255
|
|
|
self, |
|
256
|
|
|
r""" |
|
257
|
|
|
--- |
|
258
|
|
|
pandoc-numbering: |
|
259
|
|
|
exercise: |
|
260
|
|
|
general: |
|
261
|
|
|
listing-title: List of exercises |
|
262
|
|
|
latex: |
|
263
|
|
|
entry-space: 3 |
|
264
|
|
|
entry-tab: 2 |
|
265
|
|
|
format-entry-classic: '%D' |
|
266
|
|
|
format-entry-title: '%D (%T)' |
|
267
|
|
|
toccolor: blue |
|
268
|
|
|
--- |
|
269
|
|
|
|
|
270
|
|
|
Exercise # |
|
271
|
|
|
|
|
272
|
|
|
Exercise (Title) # |
|
273
|
|
|
""", |
|
274
|
|
|
r""" |
|
275
|
|
|
--- |
|
276
|
|
|
header-includes: |
|
277
|
|
|
- | |
|
278
|
|
|
` |
|
279
|
|
|
\makeatletter |
|
280
|
|
|
\@ifpackageloaded{subfig}{ |
|
281
|
|
|
\usepackage[subfigure]{tocloft} |
|
282
|
|
|
}{ |
|
283
|
|
|
\usepackage{tocloft} |
|
284
|
|
|
} |
|
285
|
|
|
\makeatother |
|
286
|
|
|
`{=tex} |
|
287
|
|
|
- "`\\usepackage{etoolbox}`{=tex}" |
|
288
|
|
|
- "`\\newlistof{exercise}{exercise}{List of exercises}\\renewcommand{\\cftexercisetitlefont}{\\cfttoctitlefont}\\setlength{\\cftexercisenumwidth}{\\cftfignumwidth}\\setlength{\\cftexerciseindent}{\\cftfigindent}`{=tex}" |
|
289
|
|
|
- "`\\ifdef{\\mainmatter}{\\let\\oldmainmatter\\mainmatter\\renewcommand{\\mainmatter}[0]{\\phantomsection\\label{list-of-exercises}\\listofexercise\\oldmainmatter}}{}`{=tex}" |
|
290
|
|
|
pandoc-numbering: |
|
291
|
|
|
exercise: |
|
292
|
|
|
general: |
|
293
|
|
|
listing-title: List of exercises |
|
294
|
|
|
latex: |
|
295
|
|
|
entry-space: 3 |
|
296
|
|
|
entry-tab: 2 |
|
297
|
|
|
format-entry-classic: "%D" |
|
298
|
|
|
format-entry-title: "%D (%T)" |
|
299
|
|
|
toccolor: blue |
|
300
|
|
|
--- |
|
301
|
|
|
|
|
302
|
|
|
` |
|
303
|
|
|
\makeatletter |
|
304
|
|
|
\@ifpackageloaded{subfig}{ |
|
305
|
|
|
\usepackage[subfigure]{tocloft} |
|
306
|
|
|
}{ |
|
307
|
|
|
\usepackage{tocloft} |
|
308
|
|
|
} |
|
309
|
|
|
\makeatother |
|
310
|
|
|
`{=tex} |
|
311
|
|
|
|
|
312
|
|
|
`\usepackage{etoolbox}`{=tex} |
|
313
|
|
|
|
|
314
|
|
|
`\newlistof{exercise}{exercise}{List of exercises}\renewcommand{\cftexercisetitlefont}{\cfttoctitlefont}\setlength{\cftexercisenumwidth}{\cftfignumwidth}\setlength{\cftexerciseindent}{\cftfigindent}`{=tex} |
|
315
|
|
|
|
|
316
|
|
|
`\ifdef{\mainmatter}{\let\oldmainmatter\mainmatter\renewcommand{\mainmatter}[0]{\phantomsection\label{list-of-exercises}\listofexercise\oldmainmatter}}{}`{=tex} |
|
317
|
|
|
|
|
318
|
|
|
`\ifdef{\mainmatter}{}{\phantomsection\label{list-of-exercises}\listofexercise}`{=tex} |
|
319
|
|
|
|
|
320
|
|
|
`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1}{\ignorespaces {Exercise}}}`{=tex}[**Exercise 1**]{#exercise:1 .pandoc-numbering-text .exercise .exercise-1} |
|
321
|
|
|
|
|
322
|
|
|
`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {2}{\ignorespaces {Exercise (Title)}}}`{=tex}[]{#exercise:title}[**Exercise 2** *(Title)*]{#exercise:2 .pandoc-numbering-text .exercise .exercise-2} |
|
323
|
|
|
""", |
|
324
|
|
|
"latex", |
|
325
|
|
|
) |
|
326
|
|
|
|