1
|
|
|
# This Python file uses the following encoding: utf-8 |
2
|
|
|
|
3
|
|
|
from unittest import TestCase |
4
|
|
|
from panflute import * |
5
|
|
|
|
6
|
|
|
from helper import verify_conversion |
7
|
|
|
|
8
|
|
|
def test_unlisted(): |
9
|
|
|
verify_conversion( |
10
|
|
|
''' |
11
|
|
|
Header {.unlisted} |
12
|
|
|
====== |
13
|
|
|
''', |
14
|
|
|
''' |
15
|
|
|
--- |
16
|
|
|
header-includes: |
17
|
|
|
- '\\let\\oldaddcontentsline\\addcontentsline' |
18
|
|
|
--- |
19
|
|
|
|
20
|
|
|
\\let\\oldaddcontentsline\\addcontentsline |
21
|
|
|
|
22
|
|
|
\\renewcommand{\\addcontentsline}[3]{} |
23
|
|
|
Header {#header .unlisted} |
24
|
|
|
====== |
25
|
|
|
|
26
|
|
|
\\renewcommand{\\addcontentsline}[3]{\\oldaddcontentsline{#1}{#2}{#3}} |
27
|
|
|
''', |
28
|
|
|
'latex' |
29
|
|
|
) |
30
|
|
|
|
31
|
|
|
def test_meta_simple(): |
32
|
|
|
verify_conversion( |
33
|
|
|
''' |
34
|
|
|
--- |
35
|
|
|
pandoc-latex-unlisted: [myclass] |
36
|
|
|
--- |
37
|
|
|
|
38
|
|
|
Header {.myclass} |
39
|
|
|
====== |
40
|
|
|
''', |
41
|
|
|
''' |
42
|
|
|
--- |
43
|
|
|
header-includes: |
44
|
|
|
- '\\let\\oldaddcontentsline\\addcontentsline' |
45
|
|
|
pandoc-latex-unlisted: |
46
|
|
|
- myclass |
47
|
|
|
--- |
48
|
|
|
|
49
|
|
|
\\let\\oldaddcontentsline\\addcontentsline |
50
|
|
|
|
51
|
|
|
\\renewcommand{\\addcontentsline}[3]{} |
52
|
|
|
Header {#header .myclass} |
53
|
|
|
====== |
54
|
|
|
|
55
|
|
|
\\renewcommand{\\addcontentsline}[3]{\\oldaddcontentsline{#1}{#2}{#3}} |
56
|
|
|
''', |
57
|
|
|
'latex' |
58
|
|
|
) |
59
|
|
|
|
60
|
|
|
def test_meta_multiple(): |
61
|
|
|
verify_conversion( |
62
|
|
|
''' |
63
|
|
|
--- |
64
|
|
|
pandoc-latex-unlisted: [[myclass1, myclass2]] |
65
|
|
|
--- |
66
|
|
|
|
67
|
|
|
Header {.myclass1 .myclass2} |
68
|
|
|
====== |
69
|
|
|
''', |
70
|
|
|
''' |
71
|
|
|
--- |
72
|
|
|
header-includes: |
73
|
|
|
- '\\let\\oldaddcontentsline\\addcontentsline' |
74
|
|
|
pandoc-latex-unlisted: |
75
|
|
|
- - myclass1 |
76
|
|
|
- myclass2 |
77
|
|
|
--- |
78
|
|
|
|
79
|
|
|
\\let\\oldaddcontentsline\\addcontentsline |
80
|
|
|
|
81
|
|
|
\\renewcommand{\\addcontentsline}[3]{} |
82
|
|
|
Header {#header .myclass1 .myclass2} |
83
|
|
|
====== |
84
|
|
|
|
85
|
|
|
\\renewcommand{\\addcontentsline}[3]{\\oldaddcontentsline{#1}{#2}{#3}} |
86
|
|
|
''', |
87
|
|
|
'latex' |
88
|
|
|
) |
89
|
|
|
|
90
|
|
|
def test_header_includes1(): |
91
|
|
|
verify_conversion( |
92
|
|
|
''' |
93
|
|
|
--- |
94
|
|
|
header-includes: \\usepackage{fancyhdr} |
95
|
|
|
--- |
96
|
|
|
Header {.unlisted} |
97
|
|
|
====== |
98
|
|
|
''', |
99
|
|
|
''' |
100
|
|
|
--- |
101
|
|
|
header-includes: |
102
|
|
|
- '\\usepackage{fancyhdr}' |
103
|
|
|
- '\\let\\oldaddcontentsline\\addcontentsline' |
104
|
|
|
--- |
105
|
|
|
|
106
|
|
|
\\usepackage{fancyhdr} |
107
|
|
|
|
108
|
|
|
\\let\\oldaddcontentsline\\addcontentsline |
109
|
|
|
|
110
|
|
|
\\renewcommand{\\addcontentsline}[3]{} |
111
|
|
|
Header {#header .unlisted} |
112
|
|
|
====== |
113
|
|
|
|
114
|
|
|
\\renewcommand{\\addcontentsline}[3]{\\oldaddcontentsline{#1}{#2}{#3}} |
115
|
|
|
''', |
116
|
|
|
'latex' |
117
|
|
|
) |
118
|
|
|
|
119
|
|
|
def test_header_includes2(): |
120
|
|
|
verify_conversion( |
121
|
|
|
''' |
122
|
|
|
--- |
123
|
|
|
header-includes: | |
124
|
|
|
\\usepackage{fancyhdr} |
125
|
|
|
\\pagestyle{fancy} |
126
|
|
|
--- |
127
|
|
|
Header {.unlisted} |
128
|
|
|
====== |
129
|
|
|
''', |
130
|
|
|
''' |
131
|
|
|
--- |
132
|
|
|
header-includes: |
133
|
|
|
- | |
134
|
|
|
\\usepackage{fancyhdr} |
135
|
|
|
\\pagestyle{fancy} |
136
|
|
|
- '\\let\\oldaddcontentsline\\addcontentsline' |
137
|
|
|
--- |
138
|
|
|
|
139
|
|
|
\\usepackage{fancyhdr} |
140
|
|
|
\\pagestyle{fancy} |
141
|
|
|
|
142
|
|
|
\\let\\oldaddcontentsline\\addcontentsline |
143
|
|
|
|
144
|
|
|
\\renewcommand{\\addcontentsline}[3]{} |
145
|
|
|
Header {#header .unlisted} |
146
|
|
|
====== |
147
|
|
|
|
148
|
|
|
\\renewcommand{\\addcontentsline}[3]{\\oldaddcontentsline{#1}{#2}{#3}} |
149
|
|
|
''', |
150
|
|
|
'latex' |
151
|
|
|
) |
152
|
|
|
|
153
|
|
|
|