summaryrefslogtreecommitdiff
path: root/docutils
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2016-07-26 12:24:58 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2016-07-26 12:24:58 +0000
commit65a4715f1951ebfa2ccd7b60d01ab09bcda5a4aa (patch)
treea015274fd5977dde70d07b9e8e42b6dc17fd597c /docutils
parent3ddb1e2b521605ed49dad6bc49bbe878930a4bb7 (diff)
downloaddocutils-65a4715f1951ebfa2ccd7b60d01ab09bcda5a4aa.tar.gz
LaTeX writer tests for multirow tables.
Also some more corner case test for LaTeX. (Functional test, so that the visual appearence in PDF can be easily checked.) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7950 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
-rw-r--r--docutils/test/functional/expected/latex_cornercases.tex357
-rw-r--r--docutils/test/functional/expected/standalone_rst_latex.tex4
-rw-r--r--docutils/test/functional/expected/standalone_rst_xetex.tex2
-rw-r--r--docutils/test/functional/input/data/latex-problematic.txt (renamed from docutils/test/functional/input/data/latex.txt)115
-rw-r--r--docutils/test/functional/input/data/tables_latex.txt4
-rw-r--r--docutils/test/functional/input/latex_cornercases.txt138
-rw-r--r--docutils/test/functional/tests/latex_cornercases.py10
7 files changed, 524 insertions, 106 deletions
diff --git a/docutils/test/functional/expected/latex_cornercases.tex b/docutils/test/functional/expected/latex_cornercases.tex
new file mode 100644
index 000000000..a5ef5a09b
--- /dev/null
+++ b/docutils/test/functional/expected/latex_cornercases.tex
@@ -0,0 +1,357 @@
+\documentclass[a4paper]{article}
+% generated by Docutils <http://docutils.sourceforge.net/>
+\usepackage{fixltx2e} % LaTeX patches, \textsubscript
+\usepackage{cmap} % fix search and cut-and-paste in Acrobat
+\usepackage{ifthen}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{graphicx}
+\usepackage{multirow}
+\setcounter{secnumdepth}{0}
+\usepackage{longtable,ltcaption,array}
+\setlength{\extrarowheight}{2pt}
+\newlength{\DUtablewidth} % internal use in tables
+
+%%% Custom LaTeX preamble
+% PDF Standard Fonts
+\usepackage{mathptmx} % Times
+\usepackage[scaled=.90]{helvet}
+\usepackage{courier}
+
+%%% User specified packages and stylesheets
+
+%%% Fallback definitions for Docutils-specific commands
+
+% transition (break, fancybreak, anonymous section)
+\providecommand*{\DUtransition}[1][class-arg]{%
+ \hspace*{\fill}\hrulefill\hspace*{\fill}
+ \vskip 0.5\baselineskip
+}
+
+% hyperlinks:
+\ifthenelse{\isundefined{\hypersetup}}{
+ \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+ \usepackage{bookmark}
+ \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
+}{}
+\hypersetup{
+ pdftitle={Some Tests for the LaTeX Writer},
+}
+
+%%% Title Data
+\title{\phantomsection%
+ Some Tests for the LaTeX Writer%
+ \label{some-tests-for-the-latex-writer}}
+\author{}
+\date{}
+
+%%% Body
+\begin{document}
+\maketitle
+
+These tests contain unusual combinations of syntax elements which may cause
+trouble for the LaTeX writer but do not need to be tested with other writers.
+
+
+\section{Block Quotes%
+ \label{block-quotes}%
+}
+%
+\begin{quote}
+
+This block quote comes directly after the section heading and is
+followed by a paragraph.
+
+This is the second paragraph of the block quote and it contains
+some more text filling up some space which would otherwise be
+empty.
+\nopagebreak
+
+\raggedleft —Attribution
+
+\end{quote}
+
+This is a paragraph.
+%
+\begin{quote}
+
+This block quote does not have an attribution.
+
+\end{quote}
+
+This is another paragraph.
+%
+\begin{quote}
+
+Another block quote at the end of the section.
+
+\end{quote}
+
+
+\section{More Block Quotes%
+ \label{more-block-quotes}%
+}
+%
+\begin{quote}
+
+Block quote followed by a transition.
+
+\end{quote}
+
+
+%___________________________________________________________________________
+\DUtransition
+
+%
+\begin{quote}
+
+Another block quote.
+
+\end{quote}
+
+
+\section{Images%
+ \label{images}%
+}
+
+Image with 20\% width:
+
+\includegraphics[width=0.200\linewidth]{../../../docs/user/rst/images/title.png}
+
+Image with 100\% width:
+
+\includegraphics[width=1.000\linewidth]{../../../docs/user/rst/images/title.png}
+
+
+\section{Rowspanning tables%
+ \label{rowspanning-tables}%
+}
+
+Several rowspanning cells in a table.
+
+Problem:
+
+In LaTeX, \textquotedbl{}overwritten\textquotedbl{} cells need to be defined as empty cells.
+
+Docutils (similarily to HTML) uses is the \textquotedbl{}Exchange Table Model\textquotedbl{} (also known
+as CALS tables, see docs/ref/soextblx.dtd) which defines only the remaining
+cells in a row \textquotedbl{}affected\textquotedbl{} by multirow cells.
+
+Therefore, visit\_entry() is only called for the remaining cells and the
+LaTeX writer needs bookkeeping to write out the required number of extra
+'\&'s.
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{|p{0.075\DUtablewidth}|p{0.133\DUtablewidth}|p{0.133\DUtablewidth}|p{0.086\DUtablewidth}|}
+\hline
+
+11
+ &
+12
+ &
+13
+ &
+14
+ \\
+\hline
+
+21
+ & \multirow{2}{0.13\DUtablewidth}{%
+2/3 2
+} & \multirow{3}{0.13\DUtablewidth}{%
+2…4 3
+} &
+24
+ \\
+\cline{1-1}
+\cline{4-4}
+
+31
+ & & &
+34
+ \\
+\cline{1-1}
+\cline{2-2}
+\cline{4-4}
+
+41
+ &
+42
+ & &
+14
+ \\
+\hline
+\end{longtable*}
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{|p{0.098\DUtablewidth}|p{0.098\DUtablewidth}|p{0.063\DUtablewidth}|}
+\hline
+
+11
+ &
+12
+ &
+13
+ \\
+\hline
+\multirow{2}{0.10\DUtablewidth}{%
+2/3 1
+} & \multirow{2}{0.10\DUtablewidth}{%
+2/3 2
+} &
+23
+ \\
+\cline{3-3}
+ & &
+33
+ \\
+\hline
+\end{longtable*}
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{|p{0.098\DUtablewidth}|p{0.063\DUtablewidth}|}
+\hline
+
+11
+ &
+12
+ \\
+\hline
+\multirow{2}{0.10\DUtablewidth}{%
+2/3 1
+} &
+22
+ \\
+\cline{2-2}
+ &
+32
+ \\
+\hline
+\end{longtable*}
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.110\DUtablewidth}|p{0.063\DUtablewidth}|}
+\hline
+
+11
+ &
+12
+ &
+13
+ \\
+\hline
+
+21
+ & \multirow{2}{0.11\DUtablewidth}{%
+2/3 2
+} &
+23
+ \\
+\cline{1-1}
+\cline{3-3}
+
+31
+ & &
+33
+ \\
+\hline
+\end{longtable*}
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.110\DUtablewidth}|}
+\hline
+
+11
+ &
+12
+ \\
+\hline
+
+21
+ & \multirow{2}{0.11\DUtablewidth}{%
+2/3 1
+} \\
+\cline{1-1}
+
+31
+ & \\
+\hline
+\end{longtable*}
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.110\DUtablewidth}|}
+\hline
+
+11
+ & \multirow{2}{0.11\DUtablewidth}{%
+1/2 1
+} \\
+\cline{1-1}
+
+21
+ & \\
+\hline
+
+31
+ &
+32
+ \\
+\hline
+\end{longtable*}
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.156\DUtablewidth}|p{0.110\DUtablewidth}|}
+\hline
+
+11
+ & \multirow{2}{0.16\DUtablewidth}{%
+1/2 2
+} & \multirow{2}{0.11\DUtablewidth}{%
+1/2 3
+} \\
+\cline{1-1}
+
+21
+ & & \\
+\hline
+\end{longtable*}
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{|p{0.098\DUtablewidth}|p{0.063\DUtablewidth}|p{0.110\DUtablewidth}|}
+\hline
+\multirow{2}{0.10\DUtablewidth}{%
+1/2 3
+} &
+12
+ & \multirow{2}{0.11\DUtablewidth}{%
+1/2 3
+} \\
+\cline{2-2}
+ &
+22
+ & \\
+\hline
+\end{longtable*}
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{|p{0.098\DUtablewidth}|p{0.063\DUtablewidth}|}
+\hline
+\multirow{2}{0.10\DUtablewidth}{%
+1/2 3
+} &
+12
+ \\
+\cline{2-2}
+ &
+22
+ \\
+\hline
+
+31
+ &
+32
+ \\
+\hline
+\end{longtable*}
+
+\end{document}
diff --git a/docutils/test/functional/expected/standalone_rst_latex.tex b/docutils/test/functional/expected/standalone_rst_latex.tex
index cd6bede51..9fe8d85d0 100644
--- a/docutils/test/functional/expected/standalone_rst_latex.tex
+++ b/docutils/test/functional/expected/standalone_rst_latex.tex
@@ -1468,7 +1468,7 @@ cell.
\cline{1-1}
body row 3
- & \\
+ & & \\
\hline
\end{longtable*}
@@ -1794,7 +1794,7 @@ Description
\endfoot
\endlastfoot
\multicolumn{2}{|p{0.39\DUtablewidth}|}{
-multirow header breaks latex
+multicollumn cell
} \\
\hline
\end{longtable*}
diff --git a/docutils/test/functional/expected/standalone_rst_xetex.tex b/docutils/test/functional/expected/standalone_rst_xetex.tex
index 29dc54c2b..d068e0b38 100644
--- a/docutils/test/functional/expected/standalone_rst_xetex.tex
+++ b/docutils/test/functional/expected/standalone_rst_xetex.tex
@@ -1468,7 +1468,7 @@ cell.
\cline{1-1}
body row 3
- & \\
+ & & \\
\hline
\end{longtable*}
diff --git a/docutils/test/functional/input/data/latex.txt b/docutils/test/functional/input/data/latex-problematic.txt
index 0926f842a..acaefc2b7 100644
--- a/docutils/test/functional/input/data/latex.txt
+++ b/docutils/test/functional/input/data/latex-problematic.txt
@@ -1,44 +1,13 @@
-Some Tests for the LaTeX Writer
-===============================
+Problematic Cases for the LaTeX Writer
+======================================
-These tests have been written to exercise some unusual combinations of
-syntax elements which may cause trouble for the LaTeX writer but do
-not need to be tested with other writers (e.g. the HTML writer).
-
-This file is not yet used by any automated test. It is currently only
-used to control the visual appearance of the output.
-
-
-Block Quotes
-------------
-
- This block quote comes directly after the section heading and is
- followed by a paragraph.
-
- This is the second paragraph of the block quote and it contains
- some more text filling up some space which would otherwise be
- empty.
-
- -- Attribution
-
-This is a paragraph.
-
- This block quote does not have an attribution.
-
-This is another paragraph.
-
- Another block quote at the end of the section.
-
-
-More Block Quotes
------------------
-
- Block quote followed by a transition.
-
-----------
-
- Another block quote.
+These tests contain unusual combinations of syntax elements which may cause
+trouble for the LaTeX writer but do not need to be tested with other writers
+(e.g. the HTML writer).
+The file `latex-problematic.txt` contains the cases with non unsatisfying
+results. It is only used to control the visual appearance of the output, not
+by any automated test
Sidebars
--------
@@ -77,7 +46,6 @@ This is some text. This is some text. This is some text. This is
some text. This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
-
Nested Elements
---------------
@@ -188,81 +156,28 @@ Too deeply nested lists fail. TODO: generate an error or provide a workaround.
| paragraph. |
+-----------------+
-
-Images
-------
-
-Image with 20% width:
-
-.. image:: ../../../../docs/user/rst/images/title.png
- :width: 20%
-
-Image with 100% width:
-
-.. image:: ../../../../docs/user/rst/images/title.png
- :width: 100%
-
-
Vertical alignment of inline images
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. |top| image:: ../../../../docs/user/rst/images/biohazard.png
:align: top
+ :width: 3em
.. |middle| image:: ../../../../docs/user/rst/images/biohazard.png
:align: middle
+ :width: 2em
.. |bottom| image:: ../../../../docs/user/rst/images/biohazard.png
:align: bottom
+ :width: 2.5em
-A paragraph containing top |top|, middle |middle|, and bottom |bottom|
+A paragraph with top |top|, middle |middle|, and bottom |bottom|
aligned images.
+A paragraph with top |top| aligned image.
-Rowspanning tables
-------------------
-
-Several rowspanning cells in a table.
-
-.. Problem:
-
- In the LaTeX `multicol` package, if there are multirow cells, the
- "overwritten" cells need to be defined as empty cells.
-
- Docutils (similarily to HTML) uses is the "Exchange Table Model" (also
- known as CALS tables, see docs/ref/soextblx.dtd) which defines only the
- remaining cells in a row "affected" by multirow cells.
-
- Therefore, visit_entry() is only called for the remaining cells and the
- LaTeX writer needs bookkeeping to write out the required number of extra
- '&'s.
-
-.. class:: standard
-
-+-----------+------------+------------------+-----------+
-| cell 11 | cell 12 | cell 13 | cell 41 |
-+-----------+------------+------------------+-----------+
-| cell 12 | Cell a | | cell 42 |
-+-----------+ | +-----------+
-| cell 13 | | cell b | cell 43 |
-+-----------+------------+------------------+-----------+
-
-.. class:: standard
+A paragraph with middle |middle| aligned image.
-+------------+------------------+-----------+
-| cell 12 | cell 13 | cell 41 |
-+------------+------------------+-----------+
-| Cell a | | cell 42 |
-+ | +-----------+
-| | cell b | cell 43 |
-+------------+------------------+-----------+
+A paragraph with bottom |bottom| aligned image.
-.. class:: standard
-+-----------+------------+-----------+
-| cell 11 | cell 12 | cell 41 |
-+-----------+------------+-----------+
-| cell 12 | Cell a | cell 42 |
-+-----------+ +-----------+
-| cell 13 | | cell 43 |
-+-----------+------------+-----------+
diff --git a/docutils/test/functional/input/data/tables_latex.txt b/docutils/test/functional/input/data/tables_latex.txt
index f0e0179b5..1e8550ca1 100644
--- a/docutils/test/functional/input/data/tables_latex.txt
+++ b/docutils/test/functional/input/data/tables_latex.txt
@@ -27,7 +27,5 @@ A table with multirow header
| +-------------------+
| | Description |
+============+===================+
- | multirow header breaks latex |
+ | multicollumn cell |
+--------------------------------+
-
-
diff --git a/docutils/test/functional/input/latex_cornercases.txt b/docutils/test/functional/input/latex_cornercases.txt
new file mode 100644
index 000000000..ebb3d4d8d
--- /dev/null
+++ b/docutils/test/functional/input/latex_cornercases.txt
@@ -0,0 +1,138 @@
+Some Tests for the LaTeX Writer
+===============================
+
+These tests contain unusual combinations of syntax elements which may cause
+trouble for the LaTeX writer but do not need to be tested with other writers.
+
+Block Quotes
+------------
+
+ This block quote comes directly after the section heading and is
+ followed by a paragraph.
+
+ This is the second paragraph of the block quote and it contains
+ some more text filling up some space which would otherwise be
+ empty.
+
+ -- Attribution
+
+This is a paragraph.
+
+ This block quote does not have an attribution.
+
+This is another paragraph.
+
+ Another block quote at the end of the section.
+
+
+More Block Quotes
+-----------------
+
+ Block quote followed by a transition.
+
+----------
+
+ Another block quote.
+
+
+Images
+------
+
+Image with 20% width:
+
+.. image:: ../../../docs/user/rst/images/title.png
+ :width: 20%
+
+Image with 100% width:
+
+.. image:: ../../../docs/user/rst/images/title.png
+ :width: 100%
+
+
+Rowspanning tables
+------------------
+
+Several rowspanning cells in a table.
+
+Problem:
+
+In LaTeX, "overwritten" cells need to be defined as empty cells.
+
+Docutils (similarily to HTML) uses is the "Exchange Table Model" (also known
+as CALS tables, see docs/ref/soextblx.dtd) which defines only the remaining
+cells in a row "affected" by multirow cells.
+
+Therefore, visit_entry() is only called for the remaining cells and the
+LaTeX writer needs bookkeeping to write out the required number of extra
+'&'s.
+
++-----+----------+----------+------+
+| 11 | 12 | 13 | 14 |
++-----+----------+----------+------+
+| 21 | 2/3 2 | | 24 |
++-----+ | +------+
+| 31 | | 2…4 3 | 34 |
++-----+----------+ +------+
+| 41 | 42 | | 14 |
++-----+----------+----------+------+
+
++-------+-------+----+
+| 11 | 12 | 13 |
++-------+-------+----+
+| 2/3 1 | | 23 |
+| | +----+
+| | 2/3 2 | 33 |
++-------+-------+----+
+
++-------+----+
+| 11 | 12 |
++-------+----+
+| 2/3 1 | 22 |
+| +----+
+| | 32 |
++-------+----+
+
++----+--------+----+
+| 11 | 12 | 13 |
++----+--------+----+
+| 21 | 2/3 2 | 23 |
++----+ +----+
+| 31 | | 33 |
++----+--------+----+
+
++----+--------+
+| 11 | 12 |
++----+--------+
+| 21 | 2/3 1 |
++----+ |
+| 31 | |
++----+--------+
+
+
++----+--------+
+| 11 | 1/2 1 |
++----+ |
+| 21 | |
++----+--------+
+| 31 | 32 |
++----+--------+
+
++----+------------+--------+
+| 11 | 1/2 2 | |
++----+ | 1/2 3 |
+| 21 | | |
++----+------------+--------+
+
++-------+----+--------+
+| | 12 | 1/2 3 |
+| 1/2 3 +----+ |
+| | 22 | |
++-------+----+--------+
+
++-------+----+
+| | 12 |
+| 1/2 3 +----+
+| | 22 |
++-------+----+
+| 31 | 32 |
++-------+----+
diff --git a/docutils/test/functional/tests/latex_cornercases.py b/docutils/test/functional/tests/latex_cornercases.py
new file mode 100644
index 000000000..396f0cc6d
--- /dev/null
+++ b/docutils/test/functional/tests/latex_cornercases.py
@@ -0,0 +1,10 @@
+# Source and destination file names.
+test_source = "latex_cornercases.txt"
+test_destination = "latex_cornercases.tex"
+
+# Keyword parameters passed to publish_file.
+reader_name = "standalone"
+parser_name = "rst"
+writer_name = "latex"
+
+# Extra setting we need