~ubuntu-branches/ubuntu/jaunty/python-docutils/jaunty

« back to all changes in this revision

Viewing changes to test/test_writers/test_latex2e.py

  • Committer: Bazaar Package Importer
  • Author(s): Simon McVittie
  • Date: 2008-07-24 10:39:53 UTC
  • mfrom: (1.1.4 upstream) (3.1.7 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080724103953-8gh4uezg17g9ysgy
Tags: 0.5-2
* Upload docutils 0.5 to unstable
* Update rst.el to upstream Subversion r5596, which apparently fixes
  all its performance problems (17_speed_up_rst_el.dpatch, closes: #474941)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/env python
2
2
 
3
 
# Author: engelbert gruber
4
 
# Contact: grubert@users.sourceforge.net
5
 
# Revision: $Revision: 3840 $
6
 
# Date: $Date: 2005-08-27 15:43:58 +0200 (Sat, 27 Aug 2005) $
 
3
# $Id: test_latex2e.py 5512 2008-02-15 19:25:44Z grubert $
 
4
# Author: engelbert gruber <grubert@users.sourceforge.net>
7
5
# Copyright: This module has been placed in the public domain.
8
6
 
9
7
"""
13
11
from __init__ import DocutilsTestSupport
14
12
 
15
13
def suite():
16
 
    s = DocutilsTestSupport.PublishTestSuite('latex')
 
14
    settings = {'use_latex_toc': 0}
 
15
    s = DocutilsTestSupport.PublishTestSuite('latex', suite_settings=settings)
17
16
    s.generateTests(totest)
 
17
    settings['use_latex_toc'] = 1
 
18
    s.generateTests(totest_latex_toc)
 
19
    settings['use_latex_citations'] = 1
 
20
    s.generateTests(totest_latex_citations)
18
21
    return s
19
22
 
20
23
 
33
36
\\usepackage{color}
34
37
\\usepackage{multirow}
35
38
\\usepackage{ifthen}
36
 
\\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
37
39
\\usepackage[DIV12]{typearea}
38
 
%% generator Docutils: http://docutils.sourceforge.net/
 
40
% generated by Docutils <http://docutils.sourceforge.net/>
39
41
\\newlength{\\admonitionwidth}
40
42
\\setlength{\\admonitionwidth}{0.9\\textwidth}
41
43
\\newlength{\\docinfowidth}
76
78
\\newcommand{\\rubric}[1]{\\subsection*{~\\hfill {\\it #1} \\hfill ~}}
77
79
\\newcommand{\\titlereference}[1]{\\textsl{#1}}
78
80
% end of "some commands"
 
81
\\ifthenelse{\\isundefined{\\hypersetup}}{
 
82
\\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
 
83
}{}
79
84
"""
80
85
 
81
86
totest = {}
 
87
totest_latex_toc = {}
 
88
totest_latex_citations = {}
 
89
 
 
90
totest['url_chars'] = [
 
91
["http://nowhere/url_with%28parens%29",
 
92
latex_head + """\
 
93
\\title{}
 
94
\\author{}
 
95
\\date{}
 
96
\\raggedbottom
 
97
\\begin{document}
 
98
 
 
99
\\setlength{\\locallinewidth}{\\linewidth}
 
100
 
 
101
\\href{http://nowhere/url_with\\%28parens\\%29}{http://nowhere/url{\\_}with{\\%}28parens{\\%}29}
 
102
 
 
103
\\end{document}
 
104
"""],
 
105
]
82
106
 
83
107
totest['table_of_contents'] = [
84
108
# input
105
129
\\hypertarget{table-of-contents}{}
106
130
\\pdfbookmark[0]{Table of Contents}{table-of-contents}
107
131
\\subsubsection*{~\\hfill Table of Contents\\hfill ~}
 
132
\\label{table-of-contents}
108
133
\\begin{list}{}{}
109
134
\\item {} \\href{\\#title-1}{Title 1}
110
135
\\begin{list}{}{}
121
146
\\hypertarget{title-1}{}
122
147
\\pdfbookmark[0]{Title 1}{title-1}
123
148
\\section*{Title 1}
 
149
\\label{title-1}
124
150
 
125
151
Paragraph 1.
126
152
 
130
156
\\hypertarget{title-2}{}
131
157
\\pdfbookmark[1]{Title 2}{title-2}
132
158
\\subsection*{Title 2}
133
 
 
134
 
Paragraph 2.
135
 
 
136
 
\\end{document}
137
 
"""],
138
 
 
 
159
\\label{title-2}
 
160
 
 
161
Paragraph 2.
 
162
 
 
163
\\end{document}
 
164
"""],
 
165
 
 
166
]
 
167
 
 
168
totest_latex_toc['table_of_contents'] = [
 
169
# input
 
170
["""\
 
171
.. contents:: Table of Contents
 
172
 
 
173
Title 1
 
174
=======
 
175
Paragraph 1.
 
176
 
 
177
Title 2
 
178
-------
 
179
Paragraph 2.
 
180
""",
 
181
## # expected output
 
182
latex_head + """\
 
183
\\title{}
 
184
\\author{}
 
185
\\date{}
 
186
\\raggedbottom
 
187
\\begin{document}
 
188
 
 
189
\\setlength{\\locallinewidth}{\\linewidth}
 
190
\\hypertarget{table-of-contents}{}
 
191
\\renewcommand{\contentsname}{Table of Contents}
 
192
\\tableofcontents
 
193
 
 
194
\\bigskip
 
195
\\label{table-of-contents}
 
196
 
 
197
 
 
198
%___________________________________________________________________________
 
199
 
 
200
\\hypertarget{title-1}{}
 
201
\\section{Title 1}
 
202
\\label{title-1}
 
203
 
 
204
Paragraph 1.
 
205
 
 
206
 
 
207
%___________________________________________________________________________
 
208
 
 
209
\\hypertarget{title-2}{}
 
210
\\subsection{Title 2}
 
211
\\label{title-2}
 
212
 
 
213
Paragraph 2.
 
214
 
 
215
\\end{document}
 
216
"""],
 
217
 
 
218
]
 
219
 
 
220
 
 
221
totest_latex_citations['citations_with_underscore'] = [
 
222
# input
 
223
["""\
 
224
Just a test citation [my_cite2006]_.
 
225
 
 
226
.. [my_cite2006]
 
227
   The underscore is mishandled.
 
228
""",
 
229
## # expected output
 
230
latex_head + """\
 
231
\\title{}
 
232
\\author{}
 
233
\\date{}
 
234
\\raggedbottom
 
235
\\begin{document}
 
236
 
 
237
\\setlength{\\locallinewidth}{\\linewidth}
 
238
 
 
239
Just a test citation \\cite{my_cite2006}.
 
240
 
 
241
\\begin{thebibliography}{my{\\_}cite2006}
 
242
\\bibitem[my{\\_}cite2006]{my_cite2006}{
 
243
The underscore is mishandled.
 
244
}
 
245
\\end{thebibliography}
 
246
 
 
247
\\end{document}
 
248
"""],
139
249
]
140
250
 
141
251
 
162
272
\\begin{document}
163
273
 
164
274
\\setlength{\\locallinewidth}{\\linewidth}
165
 
\\newcounter{listcnt1}
166
 
\\begin{list}{\\arabic{listcnt1}.}
 
275
\\newcounter{listcnt0}
 
276
\\begin{list}{\\arabic{listcnt0}.}
167
277
{
168
 
\\usecounter{listcnt1}
 
278
\\usecounter{listcnt0}
169
279
\\setlength{\\rightmargin}{\\leftmargin}
170
280
}
171
281
\\item {} 
176
286
 
177
287
\\end{list}
178
288
\\begin{quote}
179
 
\\newcounter{listcnt2}
180
 
\\begin{list}{\\alph{listcnt2})}
 
289
\\setcounter{listcnt0}{0}
 
290
\\begin{list}{\\alph{listcnt0})}
181
291
{
182
 
\\usecounter{listcnt2}
 
292
\\usecounter{listcnt0}
183
293
\\setlength{\\rightmargin}{\\leftmargin}
184
294
}
185
295
\\item {} 
190
300
 
191
301
\\end{list}
192
302
\\end{quote}
193
 
\\newcounter{listcnt3}
194
 
\\begin{list}{\\arabic{listcnt3}.}
 
303
\\setcounter{listcnt0}{0}
 
304
\\begin{list}{\\arabic{listcnt0}.}
195
305
{
196
 
\\usecounter{listcnt3}
197
 
\\addtocounter{listcnt3}{2}
 
306
\\usecounter{listcnt0}
 
307
\\addtocounter{listcnt0}{2}
198
308
\\setlength{\\rightmargin}{\\leftmargin}
199
309
}
200
310
\\item {} 
202
312
 
203
313
\\end{list}
204
314
\\begin{quote}
205
 
\\newcounter{listcnt4}
206
 
\\begin{list}{(\\Roman{listcnt4})}
 
315
\\setcounter{listcnt0}{0}
 
316
\\begin{list}{(\\Roman{listcnt0})}
207
317
{
208
 
\\usecounter{listcnt4}
 
318
\\usecounter{listcnt0}
209
319
\\setlength{\\rightmargin}{\\leftmargin}
210
320
}
211
321
\\item {} 
294
404
 
295
405
\\setlength{\\locallinewidth}{\\linewidth}
296
406
 
297
 
\\begin{longtable}[c]{|p{0.07\locallinewidth}|p{0.07\locallinewidth}|}
 
407
\\leavevmode
 
408
\\begin{longtable}[c]{|p{0.075\locallinewidth}|p{0.075\locallinewidth}|}
298
409
\\caption{Foo}\\\\
299
410
\\hline
300
411
 &  \\\\
307
418
"""],
308
419
]
309
420
 
 
421
totest['table_class'] = [
 
422
# input
 
423
["""\
 
424
.. table::
 
425
   :class: borderless
 
426
 
 
427
   +-----+-----+
 
428
   |  1  |  2  |
 
429
   +-----+-----+
 
430
   |  3  |  4  |
 
431
   +-----+-----+
 
432
""",
 
433
latex_head + """\
 
434
\\title{}
 
435
\\author{}
 
436
\\date{}
 
437
\\raggedbottom
 
438
\\begin{document}
 
439
 
 
440
\\setlength{\\locallinewidth}{\\linewidth}
 
441
 
 
442
\\leavevmode
 
443
\\begin{longtable}[c]{p{0.075\locallinewidth}p{0.075\locallinewidth}}
 
444
 
 
445
1
 
446
 & 
 
447
2
 
448
 \\\\
 
449
 
 
450
3
 
451
 & 
 
452
4
 
453
 \\\\
 
454
\\end{longtable}
 
455
 
 
456
\\end{document}
 
457
"""],
 
458
]
 
459
 
310
460
# In "\\\n[" the "[" needs to be protected (otherwise it will be seen as an option to "\\").
311
461
totest['brackett_protection'] = [
312
462
# input