|
From: <mi...@us...> - 2016-07-26 18:16:01
|
Revision: 7952
http://sourceforge.net/p/docutils/code/7952
Author: milde
Date: 2016-07-26 18:15:59 +0000 (Tue, 26 Jul 2016)
Log Message:
-----------
Implement feature request [ 48 ]
Add :align: option to the table directives.
Thanks to Takeshi KOMIYA for the patch.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/ref/rst/directives.txt
trunk/docutils/docutils/parsers/rst/directives/tables.py
trunk/docutils/docutils/writers/html4css1/__init__.py
trunk/docutils/docutils/writers/html4css1/html4css1.css
trunk/docutils/docutils/writers/html_plain/__init__.py
trunk/docutils/docutils/writers/html_plain/minimal.css
trunk/docutils/docutils/writers/html_plain/plain.css
trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
trunk/docutils/test/functional/expected/standalone_rst_html_plain.html
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/functional/input/data/list_table.txt
trunk/docutils/test/functional/input/data/standard.txt
trunk/docutils/test/functional/input/data/svg_images.txt
trunk/docutils/test/functional/input/data/tables_latex.txt
trunk/docutils/test/functional/input/standalone_rst_html_plain.txt
trunk/docutils/test/functional/input/standalone_rst_latex.txt
trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
trunk/docutils/test/test_writers/test_html4css1_parts.py
trunk/docutils/test/test_writers/test_latex2e.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/HISTORY.txt 2016-07-26 18:15:59 UTC (rev 7952)
@@ -34,6 +34,10 @@
- Patch [ 120 ] tables accept option widths: list of relative widths, 'auto'
or 'grid'.
+ - Implement feature request [ 48 ]
+ Add :align: option to the table directives.
+ Thanks to Takeshi KOMIYA for the patch.
+
* docutils/parsers/rst/roles.py
- Fix [ 295 ] Class argument for custom role inheriting from math.
Modified: trunk/docutils/docs/ref/rst/directives.txt
===================================================================
--- trunk/docutils/docs/ref/rst/directives.txt 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/docs/ref/rst/directives.txt 2016-07-26 18:15:59 UTC (rev 7952)
@@ -223,7 +223,9 @@
``align`` : "top", "middle", "bottom", "left", "center", or "right"
The alignment of the image, equivalent to the HTML ``<img>`` tag's
- "align" attribute. The values "top", "middle", and "bottom"
+ deprecated "align" attribute or the corresponding "vertical-align" and
+ "text-align" CSS properties.
+ The values "top", "middle", and "bottom"
control an image's vertical alignment (relative to the text
baseline); they are only useful for inline images (substitutions).
The values "left", "center", and "right" control an image's
@@ -749,7 +751,7 @@
:Directive Type: "table"
:Doctree Element: table_
:Directive Arguments: 1, optional (table title).
-:Directive Options: `:class:`_, `:name:`_
+:Directive Options: Possible (see below).
:Directive Content: A normal reStructuredText table.
(New in Docutils 0.3.1)
@@ -766,7 +768,14 @@
True False
===== =====
+The following options are recognized:
+``align`` : "left", "center", or "right"
+ The horizontal alignment of the table.
+ (New in Docutils 0.13)
+
+and the common options `:class:`_ and `:name:`_.
+
.. _csv-table:
CSV Table
@@ -880,6 +889,10 @@
.. Add another possible value, "double", to explicitly indicate
the default case?
+``align`` : "left", "center", or "right"
+ The horizontal alignment of the table.
+ (New in Docutils 0.13)
+
and the common options `:class:`_ and `:name:`_.
@@ -935,6 +948,10 @@
The number of table columns to use as stubs (row titles, on the
left). Defaults to 0.
+``align`` : "left", "center", or "right"
+ The horizontal alignment of the table.
+ (New in Docutils 0.13)
+
and the common options `:class:`_ and `:name:`_.
Modified: trunk/docutils/docutils/parsers/rst/directives/tables.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/tables.py 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/docutils/parsers/rst/directives/tables.py 2016-07-26 18:15:59 UTC (rev 7952)
@@ -20,6 +20,10 @@
from docutils.parsers.rst import directives
+def align(argument):
+ return directives.choice(argument, ('left', 'center', 'right'))
+
+
class Table(Directive):
"""
@@ -30,6 +34,7 @@
final_argument_whitespace = True
option_spec = {'class': directives.class_option,
'name': directives.unchanged,
+ 'align': align,
'widths': directives.value_or(('auto', 'grid'),
directives.positive_int_list)}
has_content = True
@@ -140,6 +145,8 @@
return [error]
table_node = node[0]
table_node['classes'] += self.options.get('class', [])
+ if 'align' in self.options:
+ table_node['align'] = self.options.get('align')
tgroup = table_node[0]
if type(self.widths) == list:
colspecs = [child for child in tgroup.children
@@ -168,6 +175,7 @@
'encoding': directives.encoding,
'class': directives.class_option,
'name': directives.unchanged,
+ 'align': align,
# field delimiter char
'delim': directives.single_char_or_whitespace_or_unicode,
# treat whitespace after delimiter as significant
@@ -258,6 +266,8 @@
table_node = self.state.build_table(table, self.content_offset,
stub_columns, widths=widths)
table_node['classes'] += self.options.get('class', [])
+ if 'align' in self.options:
+ table_node['align'] = self.options.get('align')
self.add_name(table_node)
if title:
table_node.insert(0, title)
@@ -384,7 +394,8 @@
'widths': directives.value_or(('auto', ),
directives.positive_int_list),
'class': directives.class_option,
- 'name': directives.unchanged}
+ 'name': directives.unchanged,
+ 'align': align}
def run(self):
if not self.content:
@@ -407,6 +418,8 @@
return [detail.args[0]]
table_node = self.build_table_from_list(table_data, widths, col_widths,
header_rows, stub_columns)
+ if 'align' in self.options:
+ table_node['align'] = self.options.get('align')
table_node['classes'] += self.options.get('class', [])
self.add_name(table_node)
if title:
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2016-07-26 18:15:59 UTC (rev 7952)
@@ -1582,9 +1582,11 @@
def visit_table(self, node):
self.context.append(self.compact_p)
self.compact_p = True
- classes = ' '.join(['docutils', self.settings.table_style]).strip()
+ classes = ['docutils', self.settings.table_style]
+ if 'align' in node:
+ classes.append('align-%s' % node['align'])
self.body.append(
- self.starttag(node, 'table', CLASS=classes, border="1"))
+ self.starttag(node, 'table', CLASS=' '.join(classes), border="1"))
def depart_table(self, node):
self.compact_p = self.context.pop()
Modified: trunk/docutils/docutils/writers/html4css1/html4css1.css
===================================================================
--- trunk/docutils/docutils/writers/html4css1/html4css1.css 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/docutils/writers/html4css1/html4css1.css 2016-07-26 18:15:59 UTC (rev 7952)
@@ -160,12 +160,12 @@
hr.docutils {
width: 75% }
-img.align-left, .figure.align-left, object.align-left {
+img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
-img.align-right, .figure.align-right, object.align-right {
+img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
@@ -176,6 +176,11 @@
margin-right: auto;
}
+table.align-center {
+ margin-left: auto;
+ margin-right: auto;
+}
+
.align-left {
text-align: left }
@@ -193,6 +198,15 @@
/* div.align-center * { */
/* text-align: left } */
+.align-top {
+ vertical-align: top }
+
+.align-middle {
+ vertical-align: middle }
+
+.align-bottom {
+ vertical-align: bottom }
+
ol.simple, ul.simple {
margin-bottom: 1em }
Modified: trunk/docutils/docutils/writers/html_plain/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html_plain/__init__.py 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/docutils/writers/html_plain/__init__.py 2016-07-26 18:15:59 UTC (rev 7952)
@@ -1514,6 +1514,8 @@
def visit_table(self, node):
classes = [cls.strip(u' \t\n')
for cls in self.settings.table_style.split(',')]
+ if 'align' in node:
+ classes.append('align-%s' % node['align'])
tag = self.starttag(node, 'table', CLASS=' '.join(classes))
self.body.append(tag)
Modified: trunk/docutils/docutils/writers/html_plain/minimal.css
===================================================================
--- trunk/docutils/docutils/writers/html_plain/minimal.css 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/docutils/writers/html_plain/minimal.css 2016-07-26 18:15:59 UTC (rev 7952)
@@ -20,10 +20,13 @@
/* .. _CSS2.1: http://www.w3.org/TR/CSS2 */
/* .. _validates: http://jigsaw.w3.org/css-validator/validator$link */
-/* Figure/table alignment */
-.align-left { text-align: left; }
-.align-right { text-align: right; }
-.align-center { clear: both; text-align: center;}
+/* alignment of text and inline objects inside block objects*/
+.align-left { text-align: left; }
+.align-right { text-align: right; }
+.align-center { clear: both; text-align: center; }
+.align-top { vertical-align: top; }
+.align-middle { vertical-align: middle; }
+.align-bottom { vertical-align: bottom; }
/* titles */
h1.title, p.subtitle {
@@ -176,28 +179,34 @@
margin-left: 40px;
}
-/* Images and Figures */
+/* Figures, Images, and Tables */
+.figure.align-left,
img.align-left,
-.figure.align-left,
-object.align-left {
- display: block;
+object.align-left,
+table.align-left {
margin-right: auto;
}
+.figure.align-center,
img.align-center,
-.figure.align-center,
object.align-center {
+ margin-left: auto;
+ margin-right: auto;
display: block;
+}
+table.align-center {
margin-left: auto;
margin-right: auto;
}
+.figure.align-right,
img.align-right,
-.figure.align-right,
-object.align-right {
- display: block;
+object.align-right,
+table.align-right {
margin-left: auto;
}
-/* reset inner alignment in figures */
-div.align-right { text-align: inherit }
+/* reset inner alignment in figures and tables */
+div.align-left, div.align-center, div.align-right,
+table.align-left, table.align-center, table.align-right
+{ text-align: inherit }
/* Admonitions and System Messages */
div.admonition,
Modified: trunk/docutils/docutils/writers/html_plain/plain.css
===================================================================
--- trunk/docutils/docutils/writers/html_plain/plain.css 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/docutils/writers/html_plain/plain.css 2016-07-26 18:15:59 UTC (rev 7952)
@@ -153,6 +153,8 @@
/* th { vertical-align: bottom; } */
+table tr { text-align: left; }
+
/* "booktabs" style (no vertical lines) */
table.booktabs {
border: 0;
@@ -165,7 +167,6 @@
}
table.booktabs th {
border-bottom: thin solid;
- text-align: left;
}
/* numbered tables (counter defined in div.document) */
@@ -195,16 +196,20 @@
/* ~~~~~~~~~~~~~ */
/* Images and Figures */
+
+/* let content flow to the side of aligned images and figures */
+.figure.align-left,
img.align-left,
-.figure.align-left,
object.align-left {
+ display: block;
clear: left;
float: left;
margin-right: 1em
}
+.figure.align-right,
img.align-right,
-.figure.align-right,
object.align-right {
+ display: block;
clear: right;
float: right;
margin-left: 1em
Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2016-07-26 18:15:59 UTC (rev 7952)
@@ -662,6 +662,68 @@
</div>
<p>This paragraph might flow around the figure. The specific behavior depends
upon the style sheet and the browser or rendering software used.</p>
+<p>Tables may be given titles and additional arguments with the <em>table</em>
+directive:</p>
+<table border="1" class="docutils align-left">
+<caption>left-aligned table</caption>
+<colgroup>
+<col width="50%" />
+<col width="50%" />
+</colgroup>
+<thead valign="bottom">
+<tr><th class="head">A</th>
+<th class="head">not A</th>
+</tr>
+</thead>
+<tbody valign="top">
+<tr><td>False</td>
+<td>True</td>
+</tr>
+<tr><td>True</td>
+<td>False</td>
+</tr>
+</tbody>
+</table>
+<table border="1" class="docutils align-center">
+<caption>center-aligned table</caption>
+<colgroup>
+<col width="50%" />
+<col width="50%" />
+</colgroup>
+<thead valign="bottom">
+<tr><th class="head">A</th>
+<th class="head">not A</th>
+</tr>
+</thead>
+<tbody valign="top">
+<tr><td>False</td>
+<td>True</td>
+</tr>
+<tr><td>True</td>
+<td>False</td>
+</tr>
+</tbody>
+</table>
+<table border="1" class="docutils align-right">
+<caption>right-aligned table</caption>
+<colgroup>
+<col width="50%" />
+<col width="50%" />
+</colgroup>
+<thead valign="bottom">
+<tr><th class="head">A</th>
+<th class="head">not A</th>
+</tr>
+</thead>
+<tbody valign="top">
+<tr><td>False</td>
+<td>True</td>
+</tr>
+<tr><td>True</td>
+<td>False</td>
+</tr>
+</tbody>
+</table>
</div>
<div class="section" id="admonitions">
<h3><a class="toc-backref" href="#id79">2.14.3 Admonitions</a></h3>
@@ -1055,6 +1117,24 @@
</tr>
</tbody>
</table>
+<table border="1" class="docutils align-center">
+<caption>center aligned list table</caption>
+<colgroup>
+<col width="50%" />
+<col width="50%" />
+</colgroup>
+<tbody valign="top">
+<tr><td>Albatross</td>
+<td>2.99</td>
+</tr>
+<tr><td>Crunchy Frog</td>
+<td>1.49</td>
+</tr>
+<tr><td>Gannet Ripple</td>
+<td>1.99</td>
+</tr>
+</tbody>
+</table>
</div>
<div class="section" id="custom-roles">
<h2><a class="toc-backref" href="#id73">2.23 Custom Roles</a></h2>
@@ -1111,8 +1191,8 @@
<li>including within SVG using the SVG <tt class="docutils literal"><image></tt> tag,</li>
<li>embedd the SVG code within HTML (inlining).</li>
</ul>
-<p>The <cite>html4css1</cite> writer uses <tt class="docutils literal"><object></tt> tags, the <cite>html-base</cite> and <cite>xhtml11</cite>
-writers use <tt class="docutils literal"><img></tt> tags.</p>
+<p>The <cite>html4css1</cite> writer uses <tt class="docutils literal"><object></tt> tags, the <cite>html5</cite>
+writer uses <tt class="docutils literal"><img></tt> tags.</p>
<!-- cf. http://edutechwiki.unige.ch/en/Using_SVG_with_HTML5_tutorial -->
</li>
<li><p class="first">The viewing agent.</p>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html_plain.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html_plain.html 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/test/functional/expected/standalone_rst_html_plain.html 2016-07-26 18:15:59 UTC (rev 7952)
@@ -644,6 +644,68 @@
</div>
<p>This paragraph might flow around the figure. The specific behavior depends
upon the style sheet and the browser or rendering software used.</p>
+<p>Tables may be given titles and additional arguments with the <em>table</em>
+directive:</p>
+<table class="align-left">
+<caption>left-aligned table</caption>
+<colgroup>
+<col style="width: 50%" />
+<col style="width: 50%" />
+</colgroup>
+<thead>
+<tr><th class="head"><p>A</p></th>
+<th class="head"><p>not A</p></th>
+</tr>
+</thead>
+<tbody>
+<tr><td><p>False</p></td>
+<td><p>True</p></td>
+</tr>
+<tr><td><p>True</p></td>
+<td><p>False</p></td>
+</tr>
+</tbody>
+</table>
+<table class="align-center">
+<caption>center-aligned table</caption>
+<colgroup>
+<col style="width: 50%" />
+<col style="width: 50%" />
+</colgroup>
+<thead>
+<tr><th class="head"><p>A</p></th>
+<th class="head"><p>not A</p></th>
+</tr>
+</thead>
+<tbody>
+<tr><td><p>False</p></td>
+<td><p>True</p></td>
+</tr>
+<tr><td><p>True</p></td>
+<td><p>False</p></td>
+</tr>
+</tbody>
+</table>
+<table class="align-right">
+<caption>right-aligned table</caption>
+<colgroup>
+<col style="width: 50%" />
+<col style="width: 50%" />
+</colgroup>
+<thead>
+<tr><th class="head"><p>A</p></th>
+<th class="head"><p>not A</p></th>
+</tr>
+</thead>
+<tbody>
+<tr><td><p>False</p></td>
+<td><p>True</p></td>
+</tr>
+<tr><td><p>True</p></td>
+<td><p>False</p></td>
+</tr>
+</tbody>
+</table>
</div>
<div class="section" id="admonitions">
<h3><a class="toc-backref" href="#id89"><span class="sectnum">2.14.3</span> Admonitions</a></h3>
@@ -1024,6 +1086,24 @@
</tr>
</tbody>
</table>
+<table class="align-center">
+<caption>center aligned list table</caption>
+<colgroup>
+<col style="width: 50%" />
+<col style="width: 50%" />
+</colgroup>
+<tbody>
+<tr><td><p>Albatross</p></td>
+<td><p>2.99</p></td>
+</tr>
+<tr><td><p>Crunchy Frog</p></td>
+<td><p>1.49</p></td>
+</tr>
+<tr><td><p>Gannet Ripple</p></td>
+<td><p>1.99</p></td>
+</tr>
+</tbody>
+</table>
</div>
<div class="section" id="custom-roles">
<h2><a class="toc-backref" href="#id77"><span class="sectnum">2.23</span> Custom Roles</a></h2>
@@ -1075,8 +1155,8 @@
<li><p>including within SVG using the SVG <span class="docutils literal"><image></span> tag,</p></li>
<li><p>embedd the SVG code within HTML (inlining).</p></li>
</ul>
-<p>The <cite>html4css1</cite> writer uses <span class="docutils literal"><object></span> tags, the <cite>html-base</cite> and <cite>xhtml11</cite>
-writers use <span class="docutils literal"><img></span> tags.</p>
+<p>The <cite>html4css1</cite> writer uses <span class="docutils literal"><object></span> tags, the <cite>html5</cite>
+writer uses <span class="docutils literal"><img></span> tags.</p>
<!-- cf. http://edutechwiki.unige.ch/en/Using_SVG_with_HTML5_tutorial -->
</li>
<li><p>The viewing agent.</p>
@@ -1359,9 +1439,9 @@
</tr>
</tbody>
</table>
-<p>This table also uses the "align-left" class argument, to left-align
-the headers:</p>
-<table class="booktabs align-left">
+<p>This table also uses the "align-right" class argument, to right-align
+the table:</p>
+<table class="booktabs align-right">
<colgroup>
<col style="width: 29%" />
<col style="width: 29%" />
@@ -1392,8 +1472,8 @@
</tr>
</tbody>
</table>
-<p>Of course, also "booktabs" style tables can be numbered:</p>
-<table class="numbered booktabs">
+<p>"Booktabs" style table, numbered and centre-aligned:</p>
+<table class="numbered booktabs align-center">
<caption>I/O values</caption>
<colgroup>
<col style="width: 31%" />
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2016-07-26 18:15:59 UTC (rev 7952)
@@ -988,7 +988,121 @@
This paragraph might flow around the figure. The specific behavior depends
upon the style sheet and the browser or rendering software used.
+Tables may be given titles and additional arguments with the \emph{table}
+directive:
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable}[l]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\caption{left-aligned table}\\
+\hline
+\textbf{%
+A
+} & \textbf{%
+not A
+} \\
+\hline
+\endfirsthead
+\caption[]{left-aligned table (... continued)}\\
+\hline
+\textbf{%
+A
+} & \textbf{%
+not A
+} \\
+\hline
+\endhead
+\multicolumn{2}{c}{\hfill ... continued on next page} \\
+\endfoot
+\endlastfoot
+
+False
+ &
+True
+ \\
+\hline
+
+True
+ &
+False
+ \\
+\hline
+\end{longtable}
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\caption{center-aligned table}\\
+\hline
+\textbf{%
+A
+} & \textbf{%
+not A
+} \\
+\hline
+\endfirsthead
+\caption[]{center-aligned table (... continued)}\\
+\hline
+\textbf{%
+A
+} & \textbf{%
+not A
+} \\
+\hline
+\endhead
+\multicolumn{2}{c}{\hfill ... continued on next page} \\
+\endfoot
+\endlastfoot
+
+False
+ &
+True
+ \\
+\hline
+
+True
+ &
+False
+ \\
+\hline
+\end{longtable}
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable}[r]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\caption{right-aligned table}\\
+\hline
+\textbf{%
+A
+} & \textbf{%
+not A
+} \\
+\hline
+\endfirsthead
+\caption[]{right-aligned table (... continued)}\\
+\hline
+\textbf{%
+A
+} & \textbf{%
+not A
+} \\
+\hline
+\endhead
+\multicolumn{2}{c}{\hfill ... continued on next page} \\
+\endfoot
+\endlastfoot
+
+False
+ &
+True
+ \\
+\hline
+
+True
+ &
+False
+ \\
+\hline
+\end{longtable}
+
+
\subsubsection{2.14.3~~~Admonitions%
\label{admonitions}%
}
@@ -1701,7 +1815,7 @@
\label{more-tables}%
}
-A multicolumn table with multi-paragraph rowspanning cells:
+A table with multi-paragraph multicolumn cells:
\setlength{\DUtablewidth}{\linewidth}
\begin{longtable*}[c]{|p{0.133\DUtablewidth}|p{0.179\DUtablewidth}|p{0.179\DUtablewidth}|p{0.110\DUtablewidth}|p{0.121\DUtablewidth}|p{0.145\DUtablewidth}|}
@@ -1758,7 +1872,10 @@
\hline
\end{longtable*}
-A table with multirow header
+Tables with multi-paragraph multirow cells currently fail due to a LaTeX
+limitation (see \url{https://sourceforge.net/p/docutils/bugs/225/}).
+
+A table with multirow header:
%
\begin{quote}
@@ -2523,8 +2640,8 @@
an unsupported level.
-% unusual combinations (from newlatex, for interactive testing)
-% .. include:: data/latex.txt
+% unusual combinations (currently separately tested)
+% .. include:: data/latex_cornercases.txt
% Preface for System Messages:
Modified: trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2016-07-26 18:15:59 UTC (rev 7952)
@@ -1361,6 +1361,99 @@
<paragraph>
This paragraph might flow around the figure. The specific behavior depends
upon the style sheet and the browser or rendering software used.
+ <paragraph>
+ Tables may be given titles and additional arguments with the
+ <emphasis>
+ table
+
+ directive:
+ <table align="left">
+ <title>
+ left-aligned table
+ <tgroup cols="2" colwidths="auto">
+ <colspec colwidth="5">
+ <colspec colwidth="5">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ A
+ <entry>
+ <paragraph>
+ not A
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ False
+ <entry>
+ <paragraph>
+ True
+ <row>
+ <entry>
+ <paragraph>
+ True
+ <entry>
+ <paragraph>
+ False
+ <table align="center">
+ <title>
+ center-aligned table
+ <tgroup cols="2" colwidths="auto">
+ <colspec colwidth="5">
+ <colspec colwidth="5">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ A
+ <entry>
+ <paragraph>
+ not A
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ False
+ <entry>
+ <paragraph>
+ True
+ <row>
+ <entry>
+ <paragraph>
+ True
+ <entry>
+ <paragraph>
+ False
+ <table align="right">
+ <title>
+ right-aligned table
+ <tgroup cols="2" colwidths="auto">
+ <colspec colwidth="5">
+ <colspec colwidth="5">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ A
+ <entry>
+ <paragraph>
+ not A
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ False
+ <entry>
+ <paragraph>
+ True
+ <row>
+ <entry>
+ <paragraph>
+ True
+ <entry>
+ <paragraph>
+ False
<section ids="admonitions" names="admonitions">
<title auto="1" refid="id76">
<generated classes="sectnum">
@@ -2036,6 +2129,34 @@
<entry>
<paragraph>
On a stick!
+ <table align="center">
+ <title>
+ center aligned list table
+ <tgroup cols="2" colwidths="auto">
+ <colspec colwidth="50">
+ <colspec colwidth="50">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ Albatross
+ <entry>
+ <paragraph>
+ 2.99
+ <row>
+ <entry>
+ <paragraph>
+ Crunchy Frog
+ <entry>
+ <paragraph>
+ 1.49
+ <row>
+ <entry>
+ <paragraph>
+ Gannet Ripple
+ <entry>
+ <paragraph>
+ 1.99
<section ids="error-handling" names="error\ handling">
<title auto="1" refid="id73">
<generated classes="sectnum">
@@ -2081,9 +2202,9 @@
<system_message level="1" line="475" source="functional/input/data/standard.txt" type="INFO">
<paragraph>
Hyperlink target "image-target-3" is not referenced.
- <system_message level="1" line="632" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="667" source="functional/input/data/standard.txt" type="INFO">
<paragraph>
Hyperlink target "docutils" is not referenced.
- <system_message level="1" line="753" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="788" source="functional/input/data/standard.txt" type="INFO">
<paragraph>
Hyperlink target "hyperlink targets" is not referenced.
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2016-07-26 18:15:59 UTC (rev 7952)
@@ -988,7 +988,121 @@
This paragraph might flow around the figure. The specific behavior depends
upon the style sheet and the browser or rendering software used.
+Tables may be given titles and additional arguments with the \emph{table}
+directive:
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable}[l]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\caption{left-aligned table}\\
+\hline
+\textbf{%
+A
+} & \textbf{%
+not A
+} \\
+\hline
+\endfirsthead
+\caption[]{left-aligned table (... continued)}\\
+\hline
+\textbf{%
+A
+} & \textbf{%
+not A
+} \\
+\hline
+\endhead
+\multicolumn{2}{c}{\hfill ... continued on next page} \\
+\endfoot
+\endlastfoot
+
+False
+ &
+True
+ \\
+\hline
+
+True
+ &
+False
+ \\
+\hline
+\end{longtable}
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable}[c]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\caption{center-aligned table}\\
+\hline
+\textbf{%
+A
+} & \textbf{%
+not A
+} \\
+\hline
+\endfirsthead
+\caption[]{center-aligned table (... continued)}\\
+\hline
+\textbf{%
+A
+} & \textbf{%
+not A
+} \\
+\hline
+\endhead
+\multicolumn{2}{c}{\hfill ... continued on next page} \\
+\endfoot
+\endlastfoot
+
+False
+ &
+True
+ \\
+\hline
+
+True
+ &
+False
+ \\
+\hline
+\end{longtable}
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable}[r]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\caption{right-aligned table}\\
+\hline
+\textbf{%
+A
+} & \textbf{%
+not A
+} \\
+\hline
+\endfirsthead
+\caption[]{right-aligned table (... continued)}\\
+\hline
+\textbf{%
+A
+} & \textbf{%
+not A
+} \\
+\hline
+\endhead
+\multicolumn{2}{c}{\hfill ... continued on next page} \\
+\endfoot
+\endlastfoot
+
+False
+ &
+True
+ \\
+\hline
+
+True
+ &
+False
+ \\
+\hline
+\end{longtable}
+
+
\subsubsection{2.14.3 Admonitions%
\label{admonitions}%
}
Modified: trunk/docutils/test/functional/input/data/list_table.txt
===================================================================
--- trunk/docutils/test/functional/input/data/list_table.txt 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/test/functional/input/data/list_table.txt 2016-07-26 18:15:59 UTC (rev 7952)
@@ -22,3 +22,13 @@
* - Gannet Ripple
- 1.99
- On a stick!
+
+.. list-table:: center aligned list table
+ :align: center
+
+ * - Albatross
+ - 2.99
+ * - Crunchy Frog
+ - 1.49
+ * - Gannet Ripple
+ - 1.99
Modified: trunk/docutils/test/functional/input/data/standard.txt
===================================================================
--- trunk/docutils/test/functional/input/data/standard.txt 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/test/functional/input/data/standard.txt 2016-07-26 18:15:59 UTC (rev 7952)
@@ -597,6 +597,41 @@
upon the style sheet and the browser or rendering software used.
+Tables may be given titles and additional arguments with the *table*
+directive:
+
+.. Table:: left-aligned table
+ :align: left
+
+ ===== =====
+ A not A
+ ===== =====
+ False True
+ True False
+ ===== =====
+
+.. Table:: center-aligned table
+ :align: center
+
+ ===== =====
+ A not A
+ ===== =====
+ False True
+ True False
+ ===== =====
+
+.. Table:: right-aligned table
+ :align: right
+
+ ===== =====
+ A not A
+ ===== =====
+ False True
+ True False
+ ===== =====
+
+
+
Admonitions
```````````
Modified: trunk/docutils/test/functional/input/data/svg_images.txt
===================================================================
--- trunk/docutils/test/functional/input/data/svg_images.txt 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/test/functional/input/data/svg_images.txt 2016-07-26 18:15:59 UTC (rev 7952)
@@ -28,8 +28,8 @@
* including within SVG using the SVG ``<image>`` tag,
* embedd the SVG code within HTML (inlining).
- The `html4css1` writer uses ``<object>`` tags, the `html-base` and `xhtml11`
- writers use ``<img>`` tags.
+ The `html4css1` writer uses ``<object>`` tags, the `html5`
+ writer uses ``<img>`` tags.
.. cf. http://edutechwiki.unige.ch/en/Using_SVG_with_HTML5_tutorial
Modified: trunk/docutils/test/functional/input/data/tables_latex.txt
===================================================================
--- trunk/docutils/test/functional/input/data/tables_latex.txt 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/test/functional/input/data/tables_latex.txt 2016-07-26 18:15:59 UTC (rev 7952)
@@ -1,7 +1,7 @@
More Tables
-----------
-A multicolumn table with multi-paragraph rowspanning cells:
+A table with multi-paragraph multicolumn cells:
+----------+--------------+---------------------------------+-----------+
| test | **bold hd** | multicolumn 1 | *emph hd* |
@@ -19,9 +19,12 @@
| cell | cell | cell | Short multicolumn 4 |
+----------+--------------+--------------+------------------------------+
-A table with multirow header
+Tables with multi-paragraph multirow cells currently fail due to a LaTeX
+limitation (see https://sourceforge.net/p/docutils/bugs/225/).
+A table with multirow header:
+
+------------+-------------------+
| XXX | Variable Summary |
| +-------------------+
Modified: trunk/docutils/test/functional/input/standalone_rst_html_plain.txt
===================================================================
--- trunk/docutils/test/functional/input/standalone_rst_html_plain.txt 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/test/functional/input/standalone_rst_html_plain.txt 2016-07-26 18:15:59 UTC (rev 7952)
@@ -174,10 +174,10 @@
True True True
===== ===== ======
-This table also uses the "align-left" class argument, to left-align
-the headers:
+This table also uses the "align-right" class argument, to right-align
+the table:
-.. class:: booktabs align-left
+.. class:: booktabs align-right
===== ===== =======
A B A or B
@@ -189,9 +189,10 @@
===== ===== =======
-Of course, also "booktabs" style tables can be numbered:
+"Booktabs" style table, numbered and centre-aligned:
.. table:: I/O values
+ :align: center
:class: numbered booktabs
===== ===== ======
Modified: trunk/docutils/test/functional/input/standalone_rst_latex.txt
===================================================================
--- trunk/docutils/test/functional/input/standalone_rst_latex.txt 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/test/functional/input/standalone_rst_latex.txt 2016-07-26 18:15:59 UTC (rev 7952)
@@ -21,8 +21,8 @@
.. include:: data/hyperlinking.txt
.. include:: data/urls.txt
.. include:: data/section_titles.txt
-.. unusual combinations (from newlatex, for interactive testing)
- .. include:: data/latex.txt
+.. unusual combinations (currently separately tested)
+ .. include:: data/latex_cornercases.txt
.. Preface for System Messages:
.. include:: data/errors.txt
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2016-07-26 18:15:59 UTC (rev 7952)
@@ -276,6 +276,29 @@
<paragraph>
automatic widths.
"""],
+["""\
+.. table::
+ :align: center
+
+ ====== =====
+ Simple table
+ ====== =====
+""",
+"""\
+<document source="test data">
+ <table align="center">
+ <tgroup cols="2" colwidths="auto">
+ <colspec colwidth="6">
+ <colspec colwidth="5">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ Simple
+ <entry>
+ <paragraph>
+ table
+"""],
]
totest['csv-table'] = [
@@ -541,6 +564,37 @@
Heiz\xf6lr\xfccksto\xdfabd\xe4mpfung
"""],
["""\
+.. csv-table:: center aligned
+ :align: center
+
+ 11, 12
+ 21, 22
+""",
+"""\
+<document source="test data">
+ <table align="center">
+ <title>
+ center aligned
+ <tgroup cols="2" colwidths="auto">
+ <colspec colwidth="50">
+ <colspec colwidth="50">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ 11
+ <entry>
+ <paragraph>
+ 12
+ <row>
+ <entry>
+ <paragraph>
+ 21
+ <entry>
+ <paragraph>
+ 22
+"""],
+["""\
.. csv-table:: empty
""",
"""\
@@ -1171,6 +1225,39 @@
On a stick!
"""],
["""\
+.. list-table:: center aligned
+ :align: center
+
+ * - 11
+ - 12
+ * - 21
+ - 22
+""",
+"""\
+<document source="test data">
+ <table align="center">
+ <title>
+ center aligned
+ <tgroup cols="2" colwidths="auto">
+ <colspec colwidth="50">
+ <colspec colwidth="50">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ 11
+ <entry>
+ <paragraph>
+ 12
+ <row>
+ <entry>
+ <paragraph>
+ 21
+ <entry>
+ <paragraph>
+ 22
+"""],
+["""\
.. list-table::
not a bullet list
Modified: trunk/docutils/test/test_writers/test_html4css1_parts.py
===================================================================
--- trunk/docutils/test/test_writers/test_html4css1_parts.py 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/test/test_writers/test_html4css1_parts.py 2016-07-26 18:15:59 UTC (rev 7952)
@@ -317,6 +317,49 @@
'html_head': '''...<title></title>\\n'''}
"""],
["""\
+.. table::
+ :align: right
+
+ +-----+-----+
+ | 1 | 2 |
+ +-----+-----+
+ | 3 | 4 |
+ +-----+-----+
+""",
+"""\
+{'fragment': '''<table border="1" class="docutils align-right">
+<colgroup>
+<col width="50%%" />
+<col width="50%%" />
+</colgroup>
+<tbody valign="top">
+<tr><td>1</td>
+<td>2</td>
+</tr>
+<tr><td>3</td>
+<td>4</td>
+</tr>
+</tbody>
+</table>\\n''',
+ 'html_body': '''<div class="document">
+<table border="1" class="docutils align-right">
+<colgroup>
+<col width="50%%" />
+<col width="50%%" />
+</colgroup>
+<tbody valign="top">
+<tr><td>1</td>
+<td>2</td>
+</tr>
+<tr><td>3</td>
+<td>4</td>
+</tr>
+</tbody>
+</table>
+</div>\\n''',
+ 'html_head': '''...<title></title>\\n'''}
+"""],
+["""\
Not a docinfo.
:This: .. _target:
Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py 2016-07-26 12:30:31 UTC (rev 7951)
+++ trunk/docutils/test/test_writers/test_latex2e.py 2016-07-26 18:15:59 UTC (rev 7952)
@@ -542,6 +542,40 @@
"""],
]
+totest['table_align'] = [
+# input
+["""\
+.. table::
+ :align: right
+
+ +-----+-----+
+ | 1 | 2 |
+ +-----+-----+
+ | 3 | 4 |
+ +-----+-----+
+""",
+head_table + r"""
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[r]{|p{0.075\DUtablewidth}|p{0.075\DUtablewidth}|}
+\hline
+
+1
+ &
+2
+ \\
+\hline
+
+3
+ &
+4
+ \\
+\hline
+\end{longtable*}
+
+\end{document}
+"""],
+]
+
totest['table_empty_thead_entry'] = [
# input
["""\
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|