Passed
Push — develop ( bcdb14...7e0539 )
by Christophe
01:15
created

test_referencing_meta   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 257
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 257
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A tests.test_referencing_meta.ReferencingMetaTest.test_referencing_link_standard() 0 26 1
A tests.test_referencing_meta.ReferencingMetaTest.test_referencing_caption_latex() 0 76 1
A tests.test_referencing_meta.ReferencingMetaTest.test_referencing_link_latex() 0 76 1
A tests.test_referencing_meta.ReferencingMetaTest.test_referencing_caption_standard() 0 26 1
1
from unittest import TestCase
2
3
from .helper import verify_conversion
4
5
6
class ReferencingMetaTest(TestCase):
7
    def test_referencing_link_standard(self):
8
        verify_conversion(
9
            self,
10
            r"""
11
---
12
pandoc-numbering:
13
  exercise:
14
    general:
15
      cite-shortcut: True
16
    standard:
17
      format-link-classic: '**%D %d %g %s %n %c**' 
18
      format-link-title: '**%D %d %T %t %g %s %n %c**' 
19
---
20
21
Title
22
=====
23
24
Exercise -.#first
25
26
Exercise (Title) -.#second
27
28
See @exercise:first
29
30
See @exercise:second
31
            """,
32
            r"""
33
---
34
pandoc-numbering:
35
  exercise:
36
    general:
37
      cite-shortcut: true
38
    standard:
39
      format-link-classic: "**%D %d %g %s %n %c**"
40
      format-link-title: "**%D %d %T %t %g %s %n %c**"
41
---
42
43
# Title
44
45
[]{#exercise:title.1}[**Exercise 1**]{#exercise:first .pandoc-numbering-text .exercise}
46
47
[]{#exercise:title.title}[**Exercise 2** *(Title)*]{#exercise:second .pandoc-numbering-text .exercise}
48
49
See [[**Exercise exercise 1.1 1 1 2**]{.pandoc-numbering-link .exercise}](#exercise:first "Exercise 1")
50
51
See [[**Exercise exercise Title title 1.2 1 2 2**]{.pandoc-numbering-link .exercise}](#exercise:second "Exercise 2 (Title)")
52
            """,
53
        )
54
55
    def test_referencing_link_latex(self):
56
        verify_conversion(
57
            self,
58
            r"""
59
---
60
pandoc-numbering:
61
  exercise:
62
    general:
63
      cite-shortcut: True
64
    latex:
65
      format-link-classic: '**%D %d %g %s %n %p**'
66
      format-link-title: '**%D %d %T %t %g %s %n %p**'
67
---
68
69
Title
70
=====
71
72
Exercise -.#first
73
74
Exercise (Title) -.#second
75
76
See @exercise:first
77
78
See @exercise:second
79
            """,
80
            r"""
81
---
82
header-includes:
83
- |
84
  `
85
  \makeatletter
86
  \@ifpackageloaded{subfig}{
87
      \usepackage[subfigure]{tocloft}
88
  }{
89
      \usepackage{tocloft}
90
  }
91
  \makeatother
92
  `{=tex}
93
- "`\\usepackage{etoolbox}`{=tex}"
94
- "`\\ifdef{\\mainmatter}{\\let\\oldmainmatter\\mainmatter\\renewcommand{\\mainmatter}[0]{\\oldmainmatter}}{}`{=tex}"
95
pandoc-numbering:
96
  exercise:
97
    general:
98
      cite-shortcut: true
99
    latex:
100
      format-link-classic: "**%D %d %g %s %n %p**"
101
      format-link-title: "**%D %d %T %t %g %s %n %p**"
102
---
103
104
`
105
\makeatletter
106
\@ifpackageloaded{subfig}{
107
    \usepackage[subfigure]{tocloft}
108
}{
109
    \usepackage{tocloft}
110
}
111
\makeatother
112
`{=tex}
113
114
`\usepackage{etoolbox}`{=tex}
115
116
`\ifdef{\mainmatter}{\let\oldmainmatter\mainmatter\renewcommand{\mainmatter}[0]{\oldmainmatter}}{}`{=tex}
117
118
`\ifdef{\mainmatter}{}{}`{=tex}
119
120
# Title
121
122
`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1.1}{\ignorespaces {Exercise}}}`{=tex}[]{#exercise:title.1}[**Exercise 1**]{#exercise:first .pandoc-numbering-text .exercise}
123
124
`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1.2}{\ignorespaces {Title}}}`{=tex}[]{#exercise:title.title}[**Exercise 2** *(Title)*]{#exercise:second .pandoc-numbering-text .exercise}
125
126
See [[**Exercise exercise 1.1 1 1 `\pageref{exercise:first}`{=tex}**]{.pandoc-numbering-link .exercise}](#exercise:first "Exercise 1")
127
128
See [[**Exercise exercise Title title 1.2 1 2 `\pageref{exercise:second}`{=tex}**]{.pandoc-numbering-link .exercise}](#exercise:second "Exercise 2 (Title)")
129
            """,
130
            "latex",
131
        )
132
133
    def test_referencing_caption_standard(self):
134
        verify_conversion(
135
            self,
136
            r"""
137
---
138
pandoc-numbering:
139
  exercise:
140
    general:
141
      cite-shortcut: True
142
    standard:
143
      format-caption-classic: '%D %d %g %s %n %c'
144
      format-caption-title: '%D %d %T %t %g %s %n %c'
145
---
146
147
Title
148
=====
149
150
Exercise -.#first
151
152
Exercise (Title) -.#second
153
154
See @exercise:first
155
156
See @exercise:second
157
            """,
158
            r"""
159
---
160
pandoc-numbering:
161
  exercise:
162
    general:
163
      cite-shortcut: true
164
    standard:
165
      format-caption-classic: "%D %d %g %s %n %c"
166
      format-caption-title: "%D %d %T %t %g %s %n %c"
167
---
168
169
# Title
170
171
[]{#exercise:title.1}[**Exercise 1**]{#exercise:first .pandoc-numbering-text .exercise}
172
173
[]{#exercise:title.title}[**Exercise 2** *(Title)*]{#exercise:second .pandoc-numbering-text .exercise}
174
175
See [[Exercise 1]{.pandoc-numbering-link .exercise}](#exercise:first "Exercise exercise 1.1 1 1 2")
176
177
See [[Exercise 2 (Title)]{.pandoc-numbering-link .exercise}](#exercise:second "Exercise exercise Title title 1.2 1 2 2")
178
            """,
179
        )
180
181
    def test_referencing_caption_latex(self):
182
        verify_conversion(
183
            self,
184
            r"""
185
---
186
pandoc-numbering:
187
  exercise:
188
    general:
189
      cite-shortcut: True
190
    latex:
191
      format-caption-classic: '%D %d %g %s %n %c %p'
192
      format-caption-title: '%D %d %T %t %g %s %n %c %p'
193
---
194
195
Title
196
=====
197
198
Exercise -.#first
199
200
Exercise (Title) -.#second
201
202
See @exercise:first
203
204
See @exercise:second
205
            """,
206
            r"""
207
---
208
header-includes:
209
- |
210
  `
211
  \makeatletter
212
  \@ifpackageloaded{subfig}{
213
      \usepackage[subfigure]{tocloft}
214
  }{
215
      \usepackage{tocloft}
216
  }
217
  \makeatother
218
  `{=tex}
219
- "`\\usepackage{etoolbox}`{=tex}"
220
- "`\\ifdef{\\mainmatter}{\\let\\oldmainmatter\\mainmatter\\renewcommand{\\mainmatter}[0]{\\oldmainmatter}}{}`{=tex}"
221
pandoc-numbering:
222
  exercise:
223
    general:
224
      cite-shortcut: true
225
    latex:
226
      format-caption-classic: "%D %d %g %s %n %c %p"
227
      format-caption-title: "%D %d %T %t %g %s %n %c %p"
228
---
229
230
`
231
\makeatletter
232
\@ifpackageloaded{subfig}{
233
    \usepackage[subfigure]{tocloft}
234
}{
235
    \usepackage{tocloft}
236
}
237
\makeatother
238
`{=tex}
239
240
`\usepackage{etoolbox}`{=tex}
241
242
`\ifdef{\mainmatter}{\let\oldmainmatter\mainmatter\renewcommand{\mainmatter}[0]{\oldmainmatter}}{}`{=tex}
243
244
`\ifdef{\mainmatter}{}{}`{=tex}
245
246
# Title
247
248
`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1.1}{\ignorespaces {Exercise}}}`{=tex}[]{#exercise:title.1}[**Exercise 1**]{#exercise:first .pandoc-numbering-text .exercise}
249
250
`\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1.2}{\ignorespaces {Title}}}`{=tex}[]{#exercise:title.title}[**Exercise 2** *(Title)*]{#exercise:second .pandoc-numbering-text .exercise}
251
252
See [[Exercise 1]{.pandoc-numbering-link .exercise}](#exercise:first "Exercise exercise 1.1 1 1 2 \pageref{exercise:first}")
253
254
See [[Exercise 2 (Title)]{.pandoc-numbering-link .exercise}](#exercise:second "Exercise exercise Title title 1.2 1 2 2 \pageref{exercise:second}")
255
            """,
256
            "latex",
257
        )
258