1
|
|
|
from unittest import TestCase |
2
|
|
|
|
3
|
|
|
from .helper import verify_conversion |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
class ReferencincTest(TestCase): |
7
|
|
|
def test_referencing_standard(self): |
8
|
|
|
verify_conversion( |
9
|
|
|
self, |
10
|
|
|
r""" |
11
|
|
|
Header |
12
|
|
|
====== |
13
|
|
|
|
14
|
|
|
Section |
15
|
|
|
------- |
16
|
|
|
|
17
|
|
|
Exercise (First title) -.+.#exercise:first |
18
|
|
|
|
19
|
|
|
Exercise (Second title) -.+.#exercise:second |
20
|
|
|
|
21
|
|
|
See [%D %d %T %t %g %s %n # %c](#exercise:first) |
22
|
|
|
|
23
|
|
|
See [%D %d %T %t %g %s %n # %c](#exercise:second) |
24
|
|
|
""", |
25
|
|
|
r""" |
26
|
|
|
# Header |
27
|
|
|
|
28
|
|
|
## Section |
29
|
|
|
|
30
|
|
|
[]{#exercise:header.section.first-title}[**Exercise 1.1** *(First title)*]{#exercise:first .pandoc-numbering-text .exercise} |
31
|
|
|
|
32
|
|
|
[]{#exercise:header.section.second-title}[**Exercise 1.2** *(Second title)*]{#exercise:second .pandoc-numbering-text .exercise} |
33
|
|
|
|
34
|
|
|
See [Exercise exercise First title first title 1.1.1 1.1 1.1 1.1 2](#exercise:first) |
35
|
|
|
|
36
|
|
|
See [Exercise exercise Second title second title 1.1.2 1.1 1.2 1.2 2](#exercise:second) |
37
|
|
|
""", |
38
|
|
|
) |
39
|
|
|
|
40
|
|
|
def test_referencing_latex(self): |
41
|
|
|
verify_conversion( |
42
|
|
|
self, |
43
|
|
|
r""" |
44
|
|
|
Title |
45
|
|
|
===== |
46
|
|
|
|
47
|
|
|
Exercise -.#first |
48
|
|
|
|
49
|
|
|
Exercise (Title) -.#second |
50
|
|
|
|
51
|
|
|
See [%D %d %T %t %g %s %n # %c %p](#exercise:first) |
52
|
|
|
|
53
|
|
|
See [%D %d %T %t %g %s %n # %c %p](#exercise:second) |
54
|
|
|
""", |
55
|
|
|
r""" |
56
|
|
|
--- |
57
|
|
|
header-includes: |
58
|
|
|
- | |
59
|
|
|
` |
60
|
|
|
\makeatletter |
61
|
|
|
\@ifpackageloaded{subfig}{ |
62
|
|
|
\usepackage[subfigure]{tocloft} |
63
|
|
|
}{ |
64
|
|
|
\usepackage{tocloft} |
65
|
|
|
} |
66
|
|
|
\makeatother |
67
|
|
|
`{=tex} |
68
|
|
|
- "`\\usepackage{etoolbox}`{=tex}" |
69
|
|
|
- "`\\ifdef{\\mainmatter}{\\let\\oldmainmatter\\mainmatter\\renewcommand{\\mainmatter}[0]{\\oldmainmatter}}{}`{=tex}" |
70
|
|
|
--- |
71
|
|
|
|
72
|
|
|
` |
73
|
|
|
\makeatletter |
74
|
|
|
\@ifpackageloaded{subfig}{ |
75
|
|
|
\usepackage[subfigure]{tocloft} |
76
|
|
|
}{ |
77
|
|
|
\usepackage{tocloft} |
78
|
|
|
} |
79
|
|
|
\makeatother |
80
|
|
|
`{=tex} |
81
|
|
|
|
82
|
|
|
`\usepackage{etoolbox}`{=tex} |
83
|
|
|
|
84
|
|
|
`\ifdef{\mainmatter}{\let\oldmainmatter\mainmatter\renewcommand{\mainmatter}[0]{\oldmainmatter}}{}`{=tex} |
85
|
|
|
|
86
|
|
|
`\ifdef{\mainmatter}{}{}`{=tex} |
87
|
|
|
|
88
|
|
|
# Title |
89
|
|
|
|
90
|
|
|
`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1.1}{\ignorespaces {Exercise}}}`{=tex}[]{#exercise:title.1}[**Exercise 1**]{#exercise:first .pandoc-numbering-text .exercise} |
91
|
|
|
|
92
|
|
|
`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1.2}{\ignorespaces {Title}}}`{=tex}[]{#exercise:title.title}[**Exercise 2** *(Title)*]{#exercise:second .pandoc-numbering-text .exercise} |
93
|
|
|
|
94
|
|
|
See [Exercise exercise 1.1 1 1 1 2 `\pageref{exercise:first}`{=tex}](#exercise:first) |
95
|
|
|
|
96
|
|
|
See [Exercise exercise Title title 1.2 1 2 2 2 `\pageref{exercise:second}`{=tex}](#exercise:second) |
97
|
|
|
""", |
98
|
|
|
"latex", |
99
|
|
|
) |
100
|
|
|
|