|
1
|
|
|
# This Python file uses the following encoding: utf-8 |
|
2
|
|
|
from unittest import TestCase |
|
3
|
|
|
from pandocfilters import Str, Code, Math, LineBreak, Space, Note |
|
4
|
|
|
|
|
5
|
|
|
import pandoc_listof |
|
6
|
|
|
|
|
7
|
|
|
def init(): |
|
8
|
|
|
pandoc_listof.collections = {} |
|
9
|
|
|
pandoc_listof.headers = [0, 0, 0, 0, 0, 0] |
|
10
|
|
|
|
|
11
|
|
|
def test_Str(): |
|
12
|
|
|
init() |
|
13
|
|
|
|
|
14
|
|
|
src = [Str(u'Exercise')] |
|
15
|
|
|
dest = u'Exercise' |
|
16
|
|
|
assert pandoc_listof.stringify(src, '') == dest |
|
17
|
|
|
assert pandoc_listof.stringify(src, 'latex') == dest |
|
18
|
|
|
|
|
19
|
|
|
def test_Code(): |
|
20
|
|
|
init() |
|
21
|
|
|
|
|
22
|
|
|
src = [Code(['', [], []], 'unsigned int')] |
|
23
|
|
|
dest = u'unsigned int' |
|
24
|
|
|
assert pandoc_listof.stringify(src, '') == dest |
|
25
|
|
|
assert pandoc_listof.stringify(src, 'latex') == dest |
|
26
|
|
|
|
|
27
|
|
|
def test_Math(): |
|
28
|
|
|
init() |
|
29
|
|
|
|
|
30
|
|
|
src = [Math({'t': 'InlineMath', 'c': []}, 'a=1')] |
|
31
|
|
|
dest = u'a=1' |
|
32
|
|
|
assert pandoc_listof.stringify(src, '') == dest |
|
33
|
|
|
|
|
34
|
|
|
dest = u'$a=1$' |
|
35
|
|
|
assert pandoc_listof.stringify(src, 'latex') == dest |
|
36
|
|
|
|
|
37
|
|
|
def test_LineBreak(): |
|
38
|
|
|
init() |
|
39
|
|
|
|
|
40
|
|
|
src = [LineBreak()] |
|
41
|
|
|
dest = u' ' |
|
42
|
|
|
assert pandoc_listof.stringify(src, '') == dest |
|
43
|
|
|
assert pandoc_listof.stringify(src, 'latex') == dest |
|
44
|
|
|
|
|
45
|
|
|
def test_Space(): |
|
46
|
|
|
init() |
|
47
|
|
|
|
|
48
|
|
|
src = [Space()] |
|
49
|
|
|
dest = u' ' |
|
50
|
|
|
assert pandoc_listof.stringify(src, '') == dest |
|
51
|
|
|
assert pandoc_listof.stringify(src, 'latex') == dest |
|
52
|
|
|
|
|
53
|
|
|
def test_Note(): |
|
54
|
|
|
init() |
|
55
|
|
|
|
|
56
|
|
|
src = [Note([Str(u'The'), Space(), Str(u'note')])] |
|
57
|
|
|
dest = u'' |
|
58
|
|
|
assert pandoc_listof.stringify(src, '') == dest |
|
59
|
|
|
assert pandoc_listof.stringify(src, 'latex') == dest |
|
60
|
|
|
|
|
61
|
|
|
|