Completed
Push — master ( 3949a6...8b9eb6 )
by Christophe
03:03
created

test_numbering_latex()   A

Complexity

Conditions 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 9
Bugs 0 Features 0
Metric Value
cc 1
c 9
b 0
f 0
dl 0
loc 9
rs 9.6666
1
# This Python file uses the following encoding: utf-8
2
3
from unittest import TestCase
4
from panflute import *
5
6
import pandoc_numbering
7
from helper import verify_conversion
8
9
def test_para_none():
10
    verify_conversion(
11
        'Not an example',
12
        'Not an example'
13
    )
14
15
def test_para():
16
    verify_conversion(
17
        '''
18
Example #
19
20
Example #
21
        ''',
22
        '''
23
[**Example 1**]{#example:1 .pandoc-numbering-text .example}
24
25
[**Example 2**]{#example:2 .pandoc-numbering-text .example}
26
        '''
27
    )
28
29
def test_para_title():
30
    verify_conversion(
31
        '''
32
Example (This is the first title) #
33
34
Example (This is the second title) #
35
        ''',
36
        '''
37
[**Example 1** *(This is the first title)*]{#example:1 .pandoc-numbering-text .example}
38
39
[**Example 2** *(This is the second title)*]{#example:2 .pandoc-numbering-text .example}
40
        '''
41
    )
42
43
def test_para_prefix_single():
44
    verify_conversion(
45
        'Example #ex:',
46
        '[**Example 1**]{#ex:1 .pandoc-numbering-text .ex}'
47
    )
48
49
def test_para_double():
50
    verify_conversion(
51
        '''
52
Example #
53
54
Example #
55
        ''',
56
        '''
57
[**Example 1**]{#example:1 .pandoc-numbering-text .example}
58
59
[**Example 2**]{#example:2 .pandoc-numbering-text .example}
60
        '''
61
    )
62
63
def test_para_sectioning():
64
    verify_conversion(
65
        '''
66
First chapter
67
=============
68
69
Second chapter
70
==============
71
72
First section
73
-------------
74
75
Second section
76
--------------
77
78
Exercise -.+.#
79
        ''',
80
        '''
81
First chapter
82
=============
83
84
Second chapter
85
==============
86
87
First section
88
-------------
89
90
Second section
91
--------------
92
93
[**Exercise 2.1**]{#exercise:2.2.1 .pandoc-numbering-text .exercise}
94
        '''
95
    )
96
97
def test_para_numbering_hidden():
98
    verify_conversion(
99
        '''
100
First chapter
101
=============
102
103
Exercise -.#exercise:one
104
105
Exercise -.#
106
107
Second chapter
108
==============
109
110
Exercise -.#
111
112
Exercise -.#
113
114
Exercice #
115
        ''',
116
        '''
117
First chapter
118
=============
119
120
[**Exercise 1**]{#exercise:one .pandoc-numbering-text .exercise}
121
122
[**Exercise 2**]{#exercise:1.2 .pandoc-numbering-text .exercise}
123
124
Second chapter
125
==============
126
127
[**Exercise 1**]{#exercise:2.1 .pandoc-numbering-text .exercise}
128
129
[**Exercise 2**]{#exercise:2.2 .pandoc-numbering-text .exercise}
130
131
[**Exercice 1**]{#exercice:1 .pandoc-numbering-text .exercice}
132
        '''
133
    )
134
135
def test_para_sectioning_unnumbered():
136
    verify_conversion(
137
        '''
138
Unnumbered chapter {#unnumbered-chapter .unnumbered}
139
==================
140
141
Exercise +.#
142
        ''',
143
        '''
144
Unnumbered chapter {#unnumbered-chapter .unnumbered}
145
==================
146
147
[**Exercise 0.1**]{#exercise:0.1 .pandoc-numbering-text .exercise}
148
        '''
149
    )
150
151
def test_para_numbering_level():
152
    verify_conversion(
153
        '''
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
        '''
172
[**Exercise 0.0.1**]{#exercise:0.0.1 .pandoc-numbering-text .exercise}
173
174
First chapter
175
=============
176
177
First section
178
-------------
179
180
[**Exercise 1.1.1**]{#exercise:1.1.1 .pandoc-numbering-text .exercise}
181
182
[**Exercise 1.1.2**]{#exercise:1.1.2 .pandoc-numbering-text .exercise}
183
184
Second section
185
--------------
186
187
[**Exercise 1.2.1**]{#exercise:1.2.1 .pandoc-numbering-text .exercise}
188
        '''
189
    )
190
191
def test_numbering_latex():
192
    verify_conversion(
193
        '''
194
Exercise (Equation $a=b$) #
195
        ''',
196
        '''
197
\\phantomsection\\addcontentsline{exercise}{exercise}{\\protect\\numberline {1}{\\ignorespaces {Equation \(a=b\)}}}[\\label{exercise:1}**Exercise 1** *(Equation $a=b$)*]{#exercise:1 .pandoc-numbering-text .exercise}
198
        ''',
199
        'latex'
200
    )
201
202