~ubuntu-branches/ubuntu/quantal/python-docutils/quantal

« back to all changes in this revision

Viewing changes to test/test_writers/test_latex2e.py

  • Committer: Bazaar Package Importer
  • Author(s): Jakub Wilk
  • Date: 2009-12-13 19:54:12 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20091213195412-9o7q348lfkucx01f
* Unconditionally recommend python-lxml, as it is used by
  /usr/bin/rst2odt_prepstyles (closes: #560330).
* Demote dependency on an ElementTree implementation to recommendation, as it
  is only used by /usr/bin/rst2odt; remove python-lxml from alternatives, as
  it is never used by the script (closes: #560328).
* Fix insecure use of temporary files in the Emacs major mode for
  reStructuredText (closes: #560755). Thanks to Kumar Appaiah for helping to
  deal with this bug.
* Register docutils documentation using doc-base.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/env python
2
2
 
3
 
# $Id: test_latex2e.py 5512 2008-02-15 19:25:44Z grubert $
 
3
# $Id: test_latex2e.py 6156 2009-10-08 09:42:38Z milde $
4
4
# Author: engelbert gruber <grubert@users.sourceforge.net>
5
5
# Copyright: This module has been placed in the public domain.
6
6
 
10
10
 
11
11
from __init__ import DocutilsTestSupport
12
12
 
 
13
from docutils._compat import b
 
14
 
13
15
def suite():
14
16
    settings = {'use_latex_toc': 0}
15
17
    s = DocutilsTestSupport.PublishTestSuite('latex', suite_settings=settings)
16
18
    s.generateTests(totest)
17
19
    settings['use_latex_toc'] = 1
18
20
    s.generateTests(totest_latex_toc)
 
21
    settings['use_latex_toc'] = 0
 
22
    settings['sectnum_xform'] = 0
 
23
    s.generateTests(totest_latex_sectnum)
 
24
    settings['sectnum_xform'] = 1
19
25
    settings['use_latex_citations'] = 1
20
26
    s.generateTests(totest_latex_citations)
21
27
    return s
22
28
 
23
 
 
24
 
latex_head = """\
25
 
\\documentclass[10pt,a4paper,english]{article}
26
 
\\usepackage{babel}
27
 
\\usepackage{ae}
28
 
\\usepackage{aeguill}
29
 
\\usepackage{shortvrb}
30
 
\\usepackage[latin1]{inputenc}
31
 
\\usepackage{tabularx}
32
 
\\usepackage{longtable}
33
 
\\setlength{\\extrarowheight}{2pt}
34
 
\\usepackage{amsmath}
35
 
\\usepackage{graphicx}
36
 
\\usepackage{color}
37
 
\\usepackage{multirow}
38
 
\\usepackage{ifthen}
39
 
\\usepackage[DIV12]{typearea}
40
 
% generated by Docutils <http://docutils.sourceforge.net/>
41
 
\\newlength{\\admonitionwidth}
42
 
\\setlength{\\admonitionwidth}{0.9\\textwidth}
43
 
\\newlength{\\docinfowidth}
44
 
\\setlength{\\docinfowidth}{0.9\\textwidth}
45
 
\\newlength{\\locallinewidth}
46
 
\\newcommand{\\optionlistlabel}[1]{\\bf #1 \\hfill}
47
 
\\newenvironment{optionlist}[1]
48
 
{\\begin{list}{}
49
 
  {\\setlength{\\labelwidth}{#1}
50
 
   \\setlength{\\rightmargin}{1cm}
51
 
   \\setlength{\\leftmargin}{\\rightmargin}
52
 
   \\addtolength{\\leftmargin}{\\labelwidth}
53
 
   \\addtolength{\\leftmargin}{\\labelsep}
54
 
   \\renewcommand{\\makelabel}{\\optionlistlabel}}
55
 
}{\\end{list}}
56
 
\\newlength{\\lineblockindentation}
57
 
\\setlength{\\lineblockindentation}{2.5em}
58
 
\\newenvironment{lineblock}[1]
59
 
{\\begin{list}{}
60
 
  {\\setlength{\\partopsep}{\\parskip}
61
 
   \\addtolength{\\partopsep}{\\baselineskip}
62
 
   \\topsep0pt\\itemsep0.15\\baselineskip\\parsep0pt
63
 
   \\leftmargin#1}
64
 
 \\raggedright}
65
 
{\\end{list}}
66
 
% begin: floats for footnotes tweaking.
67
 
\\setlength{\\floatsep}{0.5em}
68
 
\\setlength{\\textfloatsep}{\\fill}
69
 
\\addtolength{\\textfloatsep}{3em}
70
 
\\renewcommand{\\textfraction}{0.5}
71
 
\\renewcommand{\\topfraction}{0.5}
72
 
\\renewcommand{\\bottomfraction}{0.5}
73
 
\\setcounter{totalnumber}{50}
74
 
\\setcounter{topnumber}{50}
75
 
\\setcounter{bottomnumber}{50}
76
 
% end floats for footnotes
77
 
% some commands, that could be overwritten in the style file.
78
 
\\newcommand{\\rubric}[1]{\\subsection*{~\\hfill {\\it #1} \\hfill ~}}
79
 
\\newcommand{\\titlereference}[1]{\\textsl{#1}}
80
 
% end of "some commands"
81
 
\\ifthenelse{\\isundefined{\\hypersetup}}{
82
 
\\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
83
 
}{}
84
 
"""
 
29
latex_head_prefix = b(
 
30
r"""% generated by Docutils <http://docutils.sourceforge.net/>
 
31
\documentclass[a4paper,english]{article}
 
32
\usepackage{fixltx2e} % LaTeX patches, \textsubscript
 
33
\usepackage{cmap} % fix search and cut-and-paste in PDF
 
34
\usepackage{babel}
 
35
\usepackage[T1]{fontenc}
 
36
\usepackage[latin1]{inputenc}
 
37
\usepackage{ifthen}
 
38
""")
 
39
 
 
40
latex_requirements = b('')
 
41
 
 
42
latex_head = b(r"""
 
43
%%% User specified packages and stylesheets
 
44
 
 
45
%%% Fallback definitions for Docutils-specific commands
 
46
 
 
47
% hyperlinks:
 
48
\ifthenelse{\isundefined{\hypersetup}}{
 
49
  \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
 
50
}{}
 
51
""")
 
52
 
 
53
latex_head_DUtitle = b(r"""
 
54
%%% User specified packages and stylesheets
 
55
 
 
56
%%% Fallback definitions for Docutils-specific commands
 
57
 
 
58
% title for topics, admonitions and sidebar
 
59
\providecommand*{\DUtitle}[2][class-arg]{%
 
60
  % call \DUtitle#1{#2} if it exists:
 
61
  \ifcsname DUtitle#1\endcsname%
 
62
    \csname DUtitle#1\endcsname{#2}%
 
63
  \else
 
64
    \smallskip\noindent\textbf{#2}\smallskip%
 
65
  \fi
 
66
}
 
67
 
 
68
% hyperlinks:
 
69
\ifthenelse{\isundefined{\hypersetup}}{
 
70
  \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
 
71
}{}
 
72
""")
 
73
 
 
74
latex_requirements_table = b(r"""\usepackage{longtable}
 
75
\usepackage{array}
 
76
\setlength{\extrarowheight}{2pt}
 
77
\newlength{\DUtablewidth} % internal use in tables
 
78
""")
 
79
 
85
80
 
86
81
totest = {}
87
82
totest_latex_toc = {}
 
83
totest_latex_sectnum = {}
88
84
totest_latex_citations = {}
89
85
 
90
86
totest['url_chars'] = [
91
87
["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
 
"""],
 
88
latex_head_prefix + latex_requirements + latex_head + b(r"""
 
89
%%% Body
 
90
\begin{document}
 
91
 
 
92
\href{http://nowhere/url_with\%28parens\%29}{http://nowhere/url\_with\%28parens\%29}
 
93
 
 
94
\end{document}
 
95
""")],
105
96
]
106
97
 
107
98
totest['table_of_contents'] = [
118
109
Paragraph 2.
119
110
""",
120
111
## # expected output
121
 
latex_head + """\
122
 
\\title{}
123
 
\\author{}
124
 
\\date{}
125
 
\\raggedbottom
126
 
\\begin{document}
127
 
 
128
 
\\setlength{\\locallinewidth}{\\linewidth}
129
 
\\hypertarget{table-of-contents}{}
130
 
\\pdfbookmark[0]{Table of Contents}{table-of-contents}
131
 
\\subsubsection*{~\\hfill Table of Contents\\hfill ~}
132
 
\\label{table-of-contents}
133
 
\\begin{list}{}{}
134
 
\\item {} \\href{\\#title-1}{Title 1}
135
 
\\begin{list}{}{}
136
 
\\item {} \\href{\#title-2}{Title 2}
137
 
 
138
 
\\end{list}
139
 
 
140
 
\\end{list}
141
 
 
142
 
 
143
 
 
144
 
%___________________________________________________________________________
145
 
 
146
 
\\hypertarget{title-1}{}
147
 
\\pdfbookmark[0]{Title 1}{title-1}
148
 
\\section*{Title 1}
149
 
\\label{title-1}
150
 
 
151
 
Paragraph 1.
152
 
 
153
 
 
154
 
%___________________________________________________________________________
155
 
 
156
 
\\hypertarget{title-2}{}
157
 
\\pdfbookmark[1]{Title 2}{title-2}
158
 
\\subsection*{Title 2}
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
 
 
 
112
latex_head_prefix + latex_requirements + latex_head_DUtitle + b(r"""
 
113
%%% Body
 
114
\begin{document}
 
115
 
 
116
\phantomsection\label{table-of-contents}
 
117
\pdfbookmark[1]{Table of Contents}{table-of-contents}
 
118
\DUtitle[contents]{Table of Contents}
 
119
%
 
120
\begin{list}{}{}
 
121
 
 
122
\item \hyperref[title-1]{Title 1}
 
123
%
 
124
\begin{list}{}{}
 
125
 
 
126
\item \hyperref[title-2]{Title 2}
 
127
 
 
128
\end{list}
 
129
 
 
130
\end{list}
 
131
 
 
132
 
 
133
%___________________________________________________________________________
 
134
 
 
135
\section*{Title 1%
 
136
  \phantomsection%
 
137
  \addcontentsline{toc}{section}{Title 1}%
 
138
  \label{title-1}%
 
139
}
 
140
 
 
141
Paragraph 1.
 
142
 
 
143
 
 
144
%___________________________________________________________________________
 
145
 
 
146
\subsection*{Title 2%
 
147
  \phantomsection%
 
148
  \addcontentsline{toc}{subsection}{Title 2}%
 
149
  \label{title-2}%
 
150
}
 
151
 
 
152
Paragraph 2.
 
153
 
 
154
\end{document}
 
155
""")],
 
156
 
 
157
]
 
158
 
 
159
totest_latex_toc['no_sectnum'] = [
 
160
# input
 
161
["""\
 
162
.. contents::
 
163
 
 
164
first section
 
165
-------------
 
166
""",
 
167
## # expected output
 
168
latex_head_prefix + latex_requirements + latex_head + b(r"""
 
169
%%% Body
 
170
\begin{document}
 
171
 
 
172
\phantomsection\label{contents}
 
173
\pdfbookmark[1]{Contents}{contents}
 
174
\tableofcontents
 
175
 
 
176
 
 
177
 
 
178
%___________________________________________________________________________
 
179
 
 
180
\section*{first section%
 
181
  \phantomsection%
 
182
  \addcontentsline{toc}{section}{first section}%
 
183
  \label{first-section}%
 
184
}
 
185
 
 
186
\end{document}
 
187
""")],
 
188
]
 
189
 
 
190
totest_latex_toc['sectnum'] = [
 
191
# input
 
192
["""\
 
193
.. contents::
 
194
.. sectnum::
 
195
 
 
196
first section
 
197
-------------
 
198
""",
 
199
## # expected output
 
200
latex_head_prefix + latex_requirements + latex_head + b(r"""
 
201
%%% Body
 
202
\begin{document}
 
203
 
 
204
\phantomsection\label{contents}
 
205
\pdfbookmark[1]{Contents}{contents}
 
206
\tableofcontents
 
207
 
 
208
 
 
209
 
 
210
%___________________________________________________________________________
 
211
 
 
212
\section*{1~~~first section%
 
213
  \phantomsection%
 
214
  \addcontentsline{toc}{section}{1~~~first section}%
 
215
  \label{first-section}%
 
216
}
 
217
 
 
218
\end{document}
 
219
""")],
 
220
]
 
221
 
 
222
 
 
223
totest_latex_sectnum['no_sectnum'] = [
 
224
# input
 
225
["""\
 
226
some text
 
227
 
 
228
first section
 
229
-------------
 
230
""",
 
231
## # expected output
 
232
latex_head_prefix + latex_requirements + b(r"""\setcounter{secnumdepth}{0}
 
233
""") + latex_head + b(r"""
 
234
%%% Body
 
235
\begin{document}
 
236
 
 
237
some text
 
238
 
 
239
 
 
240
%___________________________________________________________________________
 
241
 
 
242
\section{first section%
 
243
  \label{first-section}%
 
244
}
 
245
 
 
246
\end{document}
 
247
""")],
 
248
]
 
249
 
 
250
totest_latex_sectnum['sectnum'] = [
 
251
# input
 
252
["""\
 
253
.. sectnum::
 
254
 
 
255
some text
 
256
 
 
257
first section
 
258
-------------
 
259
""",
 
260
## # expected output
 
261
latex_head_prefix + latex_requirements + latex_head + b(r"""
 
262
%%% Body
 
263
\begin{document}
 
264
 
 
265
some text
 
266
 
 
267
 
 
268
%___________________________________________________________________________
 
269
 
 
270
\section{first section%
 
271
  \label{first-section}%
 
272
}
 
273
 
 
274
\end{document}
 
275
""")],
 
276
]
220
277
 
221
278
totest_latex_citations['citations_with_underscore'] = [
222
279
# input
227
284
   The underscore is mishandled.
228
285
""",
229
286
## # 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}{
 
287
latex_head_prefix + latex_requirements + latex_head + b(r"""
 
288
%%% Body
 
289
\begin{document}
 
290
 
 
291
Just a test citation \cite{my_cite2006}.
 
292
 
 
293
\begin{thebibliography}{my\_cite2006}
 
294
\bibitem[my\_cite2006]{my_cite2006}{
243
295
The underscore is mishandled.
244
296
}
245
 
\\end{thebibliography}
246
 
 
247
 
\\end{document}
248
 
"""],
 
297
\end{thebibliography}
 
298
 
 
299
\end{document}
 
300
""")],
 
301
]
 
302
 
 
303
 
 
304
totest_latex_citations['adjacent_citations'] = [
 
305
# input
 
306
["""\
 
307
Two non-citations: [MeYou2007]_[YouMe2007]_.
 
308
 
 
309
Need to be separated for grouping: [MeYou2007]_ [YouMe2007]_.
 
310
 
 
311
Two spaces (or anything else) for no grouping: [MeYou2007]_  [YouMe2007]_.
 
312
 
 
313
But a line break should work: [MeYou2007]_
 
314
[YouMe2007]_.
 
315
 
 
316
.. [MeYou2007] not.
 
317
.. [YouMe2007] important.
 
318
""",
 
319
## # expected output
 
320
latex_head_prefix + latex_requirements + latex_head + b(r"""
 
321
%%% Body
 
322
\begin{document}
 
323
 
 
324
Two non-citations: {[}MeYou2007{]}\_{[}YouMe2007{]}\_.
 
325
 
 
326
Need to be separated for grouping: \cite{MeYou2007,YouMe2007}.
 
327
 
 
328
Two spaces (or anything else) for no grouping: \cite{MeYou2007}  \cite{YouMe2007}.
 
329
 
 
330
But a line break should work: \cite{MeYou2007,YouMe2007}.
 
331
 
 
332
\begin{thebibliography}{MeYou2007}
 
333
\bibitem[MeYou2007]{MeYou2007}{
 
334
not.
 
335
}
 
336
\bibitem[YouMe2007]{YouMe2007}{
 
337
important.
 
338
}
 
339
\end{thebibliography}
 
340
 
 
341
\end{document}
 
342
""")],
249
343
]
250
344
 
251
345
 
264
358
  (II) in roman numerals.
265
359
""",
266
360
# expected output
267
 
latex_head + """\
268
 
\\title{}
269
 
\\author{}
270
 
\\date{}
271
 
\\raggedbottom
272
 
\\begin{document}
273
 
 
274
 
\\setlength{\\locallinewidth}{\\linewidth}
275
 
\\newcounter{listcnt0}
276
 
\\begin{list}{\\arabic{listcnt0}.}
277
 
{
278
 
\\usecounter{listcnt0}
279
 
\\setlength{\\rightmargin}{\\leftmargin}
280
 
}
281
 
\\item {} 
282
 
Item 1.
283
 
 
284
 
\\item {} 
285
 
Second to the previous item this one will explain
286
 
 
287
 
\\end{list}
288
 
\\begin{quote}
289
 
\\setcounter{listcnt0}{0}
290
 
\\begin{list}{\\alph{listcnt0})}
291
 
{
292
 
\\usecounter{listcnt0}
293
 
\\setlength{\\rightmargin}{\\leftmargin}
294
 
}
295
 
\\item {} 
296
 
nothing.
297
 
 
298
 
\\item {} 
299
 
or some other.
300
 
 
301
 
\\end{list}
302
 
\\end{quote}
303
 
\\setcounter{listcnt0}{0}
304
 
\\begin{list}{\\arabic{listcnt0}.}
305
 
{
306
 
\\usecounter{listcnt0}
307
 
\\addtocounter{listcnt0}{2}
308
 
\\setlength{\\rightmargin}{\\leftmargin}
309
 
}
310
 
\\item {} 
311
 
Third is
312
 
 
313
 
\\end{list}
314
 
\\begin{quote}
315
 
\\setcounter{listcnt0}{0}
316
 
\\begin{list}{(\\Roman{listcnt0})}
317
 
{
318
 
\\usecounter{listcnt0}
319
 
\\setlength{\\rightmargin}{\\leftmargin}
320
 
}
321
 
\\item {} 
322
 
having pre and postfixes
323
 
 
324
 
\\item {} 
325
 
in roman numerals.
326
 
 
327
 
\\end{list}
328
 
\\end{quote}
329
 
 
330
 
\\end{document}
331
 
"""],
 
361
latex_head_prefix + latex_requirements + latex_head + b(r"""
 
362
%%% Body
 
363
\begin{document}
 
364
\newcounter{listcnt0}
 
365
\begin{list}{\arabic{listcnt0}.}
 
366
{
 
367
\usecounter{listcnt0}
 
368
\setlength{\rightmargin}{\leftmargin}
 
369
}
 
370
 
 
371
\item Item 1.
 
372
 
 
373
\item Second to the previous item this one will explain
 
374
\end{list}
 
375
%
 
376
\begin{quote}
 
377
\setcounter{listcnt0}{0}
 
378
\begin{list}{\alph{listcnt0})}
 
379
{
 
380
\usecounter{listcnt0}
 
381
\setlength{\rightmargin}{\leftmargin}
 
382
}
 
383
 
 
384
\item nothing.
 
385
 
 
386
\item or some other.
 
387
\end{list}
 
388
 
 
389
\end{quote}
 
390
\setcounter{listcnt0}{0}
 
391
\begin{list}{\arabic{listcnt0}.}
 
392
{
 
393
\usecounter{listcnt0}
 
394
\addtocounter{listcnt0}{2}
 
395
\setlength{\rightmargin}{\leftmargin}
 
396
}
 
397
 
 
398
\item Third is
 
399
\end{list}
 
400
%
 
401
\begin{quote}
 
402
\setcounter{listcnt0}{0}
 
403
\begin{list}{(\Roman{listcnt0})}
 
404
{
 
405
\usecounter{listcnt0}
 
406
\setlength{\rightmargin}{\leftmargin}
 
407
}
 
408
 
 
409
\item having pre and postfixes
 
410
 
 
411
\item in roman numerals.
 
412
\end{list}
 
413
 
 
414
\end{quote}
 
415
 
 
416
\end{document}
 
417
""")],
332
418
]
333
419
 
334
420
# BUG: need to test for quote replacing if language is de (ngerman).
354
440
 
355
441
Inline ``literal "quotes"`` should be kept.
356
442
""",
357
 
latex_head + """\
358
 
\\title{}
359
 
\\author{}
360
 
\\date{}
361
 
\\raggedbottom
362
 
\\begin{document}
363
 
 
364
 
\\setlength{\\locallinewidth}{\\linewidth}
 
443
latex_head_prefix + latex_head + b(r"""
 
444
%%% Body
 
445
\begin{document}
365
446
 
366
447
Depending on language quotes are converted for latex.
367
448
Expecting ``en'' here.
369
450
Inside literal blocks quotes should be left untouched
370
451
(use only two quotes in test code makes life easier for
371
452
the python interpreter running the test):
372
 
\\begin{quote}{\\ttfamily \\raggedright \\noindent
373
 
"{}"~\\\\
374
 
This~is~left~"untouched"~also~*this*.~\\\\
 
453
%
 
454
\begin{quote}{\ttfamily \raggedright \noindent
 
455
"{}"\\
 
456
This~is~left~"untouched"~also~*this*.\\
375
457
"{}"
376
 
}\\end{quote}
377
 
\\begin{quote}{\\ttfamily \\raggedright \\noindent
378
 
should~get~"quotes"~and~\\emph{italics}.
379
 
}\\end{quote}
380
 
 
381
 
Inline \\texttt{literal "quotes"} should be kept.
382
 
 
383
 
\\end{document}
384
 
"""],
 
458
}
 
459
\end{quote}
 
460
%
 
461
\begin{quote}{\ttfamily \raggedright \noindent
 
462
should~get~"quotes"~and~\emph{italics}.
 
463
}
 
464
\end{quote}
 
465
 
 
466
Inline \texttt{literal "quotes"} should be kept.
 
467
 
 
468
\end{document}
 
469
""")],
385
470
]
386
471
 
387
472
totest['table_caption'] = [
395
480
   |     |     |
396
481
   +-----+-----+
397
482
""",
398
 
latex_head + """\
399
 
\\title{}
400
 
\\author{}
401
 
\\date{}
402
 
\\raggedbottom
403
 
\\begin{document}
404
 
 
405
 
\\setlength{\\locallinewidth}{\\linewidth}
406
 
 
407
 
\\leavevmode
408
 
\\begin{longtable}[c]{|p{0.075\locallinewidth}|p{0.075\locallinewidth}|}
409
 
\\caption{Foo}\\\\
410
 
\\hline
411
 
 &  \\\\
412
 
\hline
413
 
 &  \\\\
414
 
\hline
415
 
\\end{longtable}
416
 
 
417
 
\\end{document}
418
 
"""],
 
483
latex_head_prefix + latex_requirements_table + latex_head + b(r"""
 
484
%%% Body
 
485
\begin{document}
 
486
 
 
487
\leavevmode
 
488
\setlength{\DUtablewidth}{\linewidth}
 
489
\begin{longtable}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
 
490
\caption{Foo}\\
 
491
\hline
 
492
 &  \\
 
493
\hline
 
494
 &  \\
 
495
\hline
 
496
\end{longtable}
 
497
 
 
498
\end{document}
 
499
""")],
419
500
]
420
501
 
421
502
totest['table_class'] = [
430
511
   |  3  |  4  |
431
512
   +-----+-----+
432
513
""",
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}}
 
514
latex_head_prefix + latex_requirements_table + latex_head + b(r"""
 
515
%%% Body
 
516
\begin{document}
 
517
 
 
518
\leavevmode
 
519
\setlength{\DUtablewidth}{\linewidth}
 
520
\begin{longtable}[c]{p{0.075\DUtablewidth}p{0.075\DUtablewidth}}
444
521
 
445
522
1
446
523
 & 
447
524
2
448
 
 \\\\
 
525
 \\
449
526
 
450
527
3
451
528
 & 
452
529
4
453
 
 \\\\
454
 
\\end{longtable}
 
530
 \\
 
531
\end{longtable}
455
532
 
456
 
\\end{document}
457
 
"""],
 
533
\end{document}
 
534
""")],
458
535
]
459
536
 
460
 
# In "\\\n[" the "[" needs to be protected (otherwise it will be seen as an option to "\\").
 
537
# The "[" needs to be protected (otherwise it will be seen as an
 
538
# option to "\\", "\item", etc. ).
 
539
 
461
540
totest['brackett_protection'] = [
462
541
# input
463
542
["""\
469
548
  the empty line gets tested too
470
549
  ]
471
550
""",
472
 
latex_head + """\
473
 
\\title{}
474
 
\\author{}
475
 
\\date{}
476
 
\\raggedbottom
477
 
\\begin{document}
478
 
 
479
 
\\setlength{\\locallinewidth}{\\linewidth}
480
 
\\begin{quote}{\\ttfamily \\raggedright \\noindent
481
 
something~before~to~get~a~end~of~line.~\\\\
482
 
{[}~\\\\
483
 
~\\\\
484
 
the~empty~line~gets~tested~too~\\\\
 
551
latex_head_prefix + latex_head + b(r"""
 
552
%%% Body
 
553
\begin{document}
 
554
%
 
555
\begin{quote}{\ttfamily \raggedright \noindent
 
556
something~before~to~get~a~end~of~line.\\
 
557
{[}\\
 
558
~\\
 
559
the~empty~line~gets~tested~too\\
485
560
{]}
486
 
}\\end{quote}
 
561
}
 
562
\end{quote}
487
563
 
488
 
\\end{document}
489
 
"""],
 
564
\end{document}
 
565
""")],
490
566
]
491
567
 
492
568
totest['raw'] = [
493
 
["""\
494
 
.. raw:: latex
 
569
[r""".. raw:: latex
495
570
 
496
 
   \\noindent
 
571
   \noindent
497
572
 
498
573
A paragraph.
499
574
 
504
579
Foo |sub|
505
580
same paragraph.
506
581
""",
507
 
latex_head + """\
508
 
\\title{}
509
 
\\author{}
510
 
\\date{}
511
 
\\raggedbottom
512
 
\\begin{document}
513
 
 
514
 
\\setlength{\\locallinewidth}{\\linewidth}
515
 
\\noindent
 
582
latex_head_prefix + latex_requirements + latex_head + b(r"""
 
583
%%% Body
 
584
\begin{document}
 
585
\noindent
516
586
A paragraph.
517
587
 
518
588
Foo (some raw text)
519
589
same paragraph.
520
590
 
521
 
\\end{document}
522
 
"""],
 
591
\end{document}
 
592
""")],
523
593
]
524
594
 
525
595
if __name__ == '__main__':