1
|
|
|
# This Python file uses the following encoding: utf-8 |
2
|
|
|
|
3
|
|
|
from unittest import TestCase |
4
|
|
|
from panflute import * |
5
|
|
|
|
6
|
|
|
import pandoc_latex_admonition |
7
|
|
|
|
8
|
|
|
from helper import conversion |
9
|
|
|
|
10
|
|
|
def test_codeblock_classes(): |
11
|
|
|
doc = conversion( |
12
|
|
|
''' |
13
|
|
|
--- |
14
|
|
|
pandoc-latex-admonition: |
15
|
|
|
- classes: ['class1', 'class2'] |
16
|
|
|
color: red |
17
|
|
|
position: right |
18
|
|
|
linewidth: 5 |
19
|
|
|
innermargin: -8 |
20
|
|
|
margin: 10 |
21
|
|
|
--- |
22
|
|
|
~~~{.class1 .class2} |
23
|
|
|
~~~ |
24
|
|
|
''', |
25
|
|
|
'latex' |
26
|
|
|
) |
27
|
|
|
text = convert_text(doc, input_format='panflute', output_format='latex', extra_args=['--wrap=none']) |
28
|
|
|
assert '\\begin{env-' in text |
29
|
|
|
assert '\\end{env-' in text |
30
|
|
|
assert pandoc_latex_admonition.environment_option('right', 5, -8, 10, 'red') in doc.get_metadata()['header-includes'][-1] |
31
|
|
|
|
32
|
|
|
def test_codeblock_attributes(): |
33
|
|
|
doc = conversion( |
34
|
|
|
''' |
35
|
|
|
::: {latex-admonition-color=xyz latex-admonition-linewidth=xyz' latex-admonition-margin=xyz latex-admonition-innermargin=xyz latex-admonition-localfootnotes=true} ::: |
36
|
|
|
::::::::: |
37
|
|
|
''', |
38
|
|
|
'latex' |
39
|
|
|
) |
40
|
|
|
text = convert_text(doc, input_format='panflute', output_format='latex', extra_args=['--wrap=none']) |
41
|
|
|
assert '\\begin{env-' in text |
42
|
|
|
assert '\\end{env-' in text |
43
|
|
|
assert pandoc_latex_admonition.environment_option('left', 2, 5, -4, 'black') in doc.get_metadata()['header-includes'][-1] |
44
|
|
|
|
45
|
|
|
def test_latex_images(): |
46
|
|
|
doc = conversion( |
47
|
|
|
''' |
48
|
|
|
::: {latex-admonition-color=black} ::: |
49
|
|
|
|
50
|
|
|
![Title]() |
51
|
|
|
|
52
|
|
|
Hello |
53
|
|
|
::::::::: |
54
|
|
|
''', |
55
|
|
|
'latex' |
56
|
|
|
) |
57
|
|
|
text = convert_text(doc, input_format='panflute', output_format='latex', extra_args=['--wrap=none']) |
58
|
|
|
assert '\\begin{env-' in text |
59
|
|
|
assert '\\end{env-' in text |
60
|
|
|
assert pandoc_latex_admonition.environment_option('left', 2, 5, -4, 'black') in doc.get_metadata()['header-includes'][-1] |
61
|
|
|
assert isinstance(doc.content[-1], Para) |
62
|
|
|
assert isinstance(doc.content[-1].content[0], Image) |
63
|
|
|
|
64
|
|
|
def test_beamer_notes(): |
65
|
|
|
doc = conversion( |
66
|
|
|
''' |
67
|
|
|
::: {latex-admonition-color=black} ::: |
68
|
|
|
|
69
|
|
|
This a text[^note] |
70
|
|
|
|
71
|
|
|
[^note]: This is a *note* |
72
|
|
|
|
73
|
|
|
::: |
74
|
|
|
''', |
75
|
|
|
'beamer' |
76
|
|
|
) |
77
|
|
|
text = convert_text(doc, input_format='panflute', output_format='beamer', extra_args=['--wrap=none']) |
78
|
|
|
assert 'This a text\\footnote<.->[frame]{This is a \\emph{note}}' in text |
79
|
|
|
|
80
|
|
|
|