1
|
|
|
# This Python file uses the following encoding: utf-8 |
2
|
|
|
|
3
|
|
|
from unittest import TestCase |
4
|
|
|
from panflute import convert_text |
5
|
|
|
|
6
|
|
|
import pandoc_latex_french_spaces |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
class FrenchSpacesTest(TestCase): |
10
|
|
|
def verify_conversion(self, markdown, expected, format="markdown"): |
11
|
|
|
doc = convert_text(markdown, standalone=True) |
12
|
|
|
doc.format = format |
13
|
|
|
pandoc_latex_french_spaces.main(doc) |
14
|
|
|
converted = convert_text( |
15
|
|
|
doc.content, |
16
|
|
|
input_format="panflute", |
17
|
|
|
output_format="markdown", |
18
|
|
|
extra_args=["--wrap=none"], |
19
|
|
|
standalone=True, |
20
|
|
|
) |
21
|
|
|
self.assertEqual(converted, expected.strip()) |
22
|
|
|
|
23
|
|
|
def test_colon(self): |
24
|
|
|
self.verify_conversion( |
25
|
|
|
""" |
26
|
|
|
This is a colon test : explanation |
27
|
|
|
""", |
28
|
|
|
""" |
29
|
|
|
This is a colon test`~`{=tex}: explanation |
30
|
|
|
""", |
31
|
|
|
"latex", |
32
|
|
|
) |
33
|
|
|
|
34
|
|
|
def test_ponctuations(self): |
35
|
|
|
self.verify_conversion( |
36
|
|
|
""" |
37
|
|
|
This is a semi-colon test ; explanation |
38
|
|
|
|
39
|
|
|
This is a exclamation mark test ! |
40
|
|
|
|
41
|
|
|
This is a question mark test ? |
42
|
|
|
""", |
43
|
|
|
""" |
44
|
|
|
This is a semi-colon test`\\thinspace{}`{=tex}; explanation |
45
|
|
|
|
46
|
|
|
This is a exclamation mark test`\\thinspace{}`{=tex}! |
47
|
|
|
|
48
|
|
|
This is a question mark test`\\thinspace{}`{=tex}? |
49
|
|
|
""", |
50
|
|
|
"latex", |
51
|
|
|
) |
52
|
|
|
|
53
|
|
|
def test_space_quotes(self): |
54
|
|
|
self.verify_conversion( |
55
|
|
|
""" |
56
|
|
|
« This is a quoted test » |
57
|
|
|
|
58
|
|
|
‹ This is a quoted test › |
59
|
|
|
|
60
|
|
|
“ This is a quoted test ” |
61
|
|
|
""", |
62
|
|
|
""" |
63
|
|
|
«`\\thinspace{}`{=tex}This is a quoted test`\\thinspace{}`{=tex}» |
64
|
|
|
|
65
|
|
|
‹`\\thinspace{}`{=tex}This is a quoted test`\\thinspace{}`{=tex}› |
66
|
|
|
|
67
|
|
|
"`\\thinspace{}`{=tex}This is a quoted test`\\thinspace{}`{=tex}" |
68
|
|
|
""", |
69
|
|
|
"latex", |
70
|
|
|
) |
71
|
|
|
|