|
1
|
|
|
# This Python file uses the following encoding: utf-8 |
|
2
|
|
|
from unittest import TestCase |
|
3
|
|
|
from panflute import * |
|
4
|
|
|
|
|
5
|
|
|
import pandoc_latex_tip |
|
6
|
|
|
|
|
7
|
|
|
def metadata(): |
|
8
|
|
|
return { |
|
9
|
|
|
'pandoc-latex-tip': MetaList( |
|
10
|
|
|
MetaMap( |
|
11
|
|
|
classes = MetaList(MetaString('tip'), MetaString('listing')), |
|
12
|
|
|
icons = MetaList(MetaMap(name = MetaString('file-text'), color=MetaString('darksalmon')), MetaString('comments')), |
|
13
|
|
|
size = MetaString('36'), |
|
14
|
|
|
position = MetaString('right') |
|
15
|
|
|
), |
|
16
|
|
|
MetaMap( |
|
17
|
|
|
classes = MetaList(MetaString('warning')), |
|
18
|
|
|
icons = MetaString('comments') |
|
19
|
|
|
), |
|
20
|
|
|
MetaMap( |
|
21
|
|
|
classes = MetaList(MetaString('tip')), |
|
22
|
|
|
position = MetaString('left') |
|
23
|
|
|
), |
|
24
|
|
|
MetaMap( |
|
25
|
|
|
classes = MetaList(MetaString('v5.0')), |
|
26
|
|
|
icons = MetaList(MetaMap( |
|
27
|
|
|
name=MetaString('balance-scale'), |
|
28
|
|
|
version=MetaString('5.0'), |
|
29
|
|
|
variant=MetaString('solid'), |
|
30
|
|
|
color=MetaString('orange') |
|
31
|
|
|
)) |
|
32
|
|
|
) |
|
33
|
|
|
) |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
def test_span(): |
|
37
|
|
|
doc = Doc( |
|
38
|
|
|
Para( |
|
39
|
|
|
Span(classes = ['tip', 'listing']), |
|
40
|
|
|
Span(classes = ['tip']), |
|
41
|
|
|
Span(classes = ['warning']), |
|
42
|
|
|
Span(classes = ['v5.0']), |
|
43
|
|
|
Span(attributes = {'latex-tip-icon': 'warning', 'latex-tip-position': 'right', 'latex-tip-size': 24}) |
|
44
|
|
|
), |
|
45
|
|
View Code Duplication |
metadata=metadata(), |
|
|
|
|
|
|
46
|
|
|
format='latex', |
|
47
|
|
|
api_version=(1, 17, 2) |
|
48
|
|
|
) |
|
49
|
|
|
pandoc_latex_tip.main(doc) |
|
50
|
|
|
assert doc.content[0].content[0].format == 'tex' |
|
51
|
|
|
assert doc.content[0].content[2].format == 'tex' |
|
52
|
|
|
assert doc.content[0].content[4].format == 'tex' |
|
53
|
|
|
assert doc.content[0].content[6].format == 'tex' |
|
54
|
|
|
assert doc.content[0].content[8].format == 'tex' |
|
55
|
|
|
|
|
56
|
|
|
def test_div(): |
|
57
|
|
|
doc = Doc( |
|
58
|
|
|
Div(classes = ['tip', 'listing']), |
|
59
|
|
|
Div(classes = ['tip']), |
|
60
|
|
|
Div(classes = ['warning']), |
|
61
|
|
|
Div(attributes = {'latex-tip-icon': 'warning', 'latex-tip-position': 'right', 'latex-tip-size': 24}), |
|
62
|
|
|
metadata=metadata(), |
|
63
|
|
|
format='latex', |
|
64
|
|
|
api_version=(1, 17, 2) |
|
65
|
|
|
) |
|
66
|
|
|
pandoc_latex_tip.main(doc) |
|
67
|
|
|
assert doc.content[0].format == 'tex' |
|
68
|
|
|
assert doc.content[2].format == 'tex' |
|
69
|
|
|
assert doc.content[4].format == 'tex' |
|
70
|
|
|
assert doc.content[6].format == 'tex' |
|
71
|
|
|
|
|
72
|
|
|
def test_code(): |
|
73
|
|
|
doc = Doc( |
|
74
|
|
|
Para( |
|
75
|
|
|
Code('', classes = ['tip', 'listing']), |
|
76
|
|
|
Code('', classes = ['tip']), |
|
77
|
|
|
Code('', classes = ['warning']), |
|
78
|
|
|
Code('', attributes = {'latex-tip-icon': 'warning', 'latex-tip-position': 'right', 'latex-tip-size': 24}), |
|
79
|
|
View Code Duplication |
), |
|
|
|
|
|
|
80
|
|
|
metadata=metadata(), |
|
81
|
|
|
format='latex', |
|
82
|
|
|
api_version=(1, 17, 2) |
|
83
|
|
|
) |
|
84
|
|
|
pandoc_latex_tip.main(doc) |
|
85
|
|
|
assert doc.content[0].content[0].format == 'tex' |
|
86
|
|
|
assert doc.content[0].content[2].format == 'tex' |
|
87
|
|
|
assert doc.content[0].content[4].format == 'tex' |
|
88
|
|
|
assert doc.content[0].content[6].format == 'tex' |
|
89
|
|
|
|
|
90
|
|
|
def test_codeblock(): |
|
91
|
|
|
doc = Doc( |
|
92
|
|
|
CodeBlock('', classes = ['tip', 'listing']), |
|
93
|
|
|
CodeBlock('', classes = ['tip']), |
|
94
|
|
|
CodeBlock('', classes = ['warning']), |
|
95
|
|
|
CodeBlock('', attributes = {'latex-tip-icon': 'warning', 'latex-tip-position': 'right', 'latex-tip-size': 24}), |
|
96
|
|
|
metadata=metadata(), format='latex', |
|
97
|
|
|
api_version=(1, 17, 2) |
|
98
|
|
|
) |
|
99
|
|
|
pandoc_latex_tip.main(doc) |
|
100
|
|
|
assert doc.content[0].format == 'tex' |
|
101
|
|
|
assert doc.content[2].format == 'tex' |
|
102
|
|
|
assert doc.content[5].format == 'tex' |
|
103
|
|
|
assert doc.content[8].format == 'tex' |
|
104
|
|
|
|
|
105
|
|
|
|