mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #3377: Add support for Docutils 0.13 `:align:
` option for tables
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -48,6 +48,7 @@ Features added
|
||||
(refs: #3379, #3381)
|
||||
* #3402: Allow to suppress "download file not readable" warnings using
|
||||
:confval:`suppress_warnings`.
|
||||
* #3377: latex: Add support for Docutils 0.13 ``:align:`` option for tables
|
||||
|
||||
Bugs fixed
|
||||
----------
|
||||
|
@@ -1,4 +1,12 @@
|
||||
\begin{longtable}<%= table.get_colspec() %>
|
||||
\begin{longtable}
|
||||
<%- if table.align == 'center' -%>
|
||||
[c]
|
||||
<%- elif table.align == 'left' -%>
|
||||
[l]
|
||||
<%- elif table.align == 'right' -%>
|
||||
[r]
|
||||
<%- endif -%>
|
||||
<%= table.get_colspec() %>
|
||||
<%- if table.caption -%>
|
||||
\caption{<%= ''.join(table.caption) %>}<%= labels %>\\
|
||||
<% endif -%>
|
||||
|
@@ -1,3 +1,10 @@
|
||||
<%- if table.align %>
|
||||
<%- if table.align == 'center' -%>
|
||||
\begin{center}
|
||||
<%- elif table.align in ('left', 'right') -%>
|
||||
\begin{flush<%= table.align%>}
|
||||
<%- endif -%>
|
||||
<% endif -%>
|
||||
<%- if table.caption -%>
|
||||
\begin{threeparttable}
|
||||
\capstart\caption{<%= ''.join(table.caption) %>}<%= labels %>
|
||||
@@ -10,3 +17,10 @@
|
||||
<%- if table.caption %>
|
||||
\end{threeparttable}
|
||||
<%- endif %>
|
||||
<%- if table.align %>
|
||||
<%- if table.align == 'center' -%>
|
||||
\end{center}
|
||||
<%- elif table.align in ('left', 'right') -%>
|
||||
\end{flush<%= table.align%>}
|
||||
<% endif -%>
|
||||
<% endif -%>
|
||||
|
@@ -1,3 +1,10 @@
|
||||
<%- if table.align %>
|
||||
<%- if table.align == 'center' -%>
|
||||
\begin{center}
|
||||
<%- elif table.align in ('left', 'right') -%>
|
||||
\begin{flush<%= table.align%>}
|
||||
<%- endif -%>
|
||||
<% endif -%>
|
||||
<%- if table.caption -%>
|
||||
\begin{threeparttable}
|
||||
\capstart\caption{<%= ''.join(table.caption) %>}<%= labels %>
|
||||
@@ -7,6 +14,13 @@
|
||||
<%= ''.join(table.header) %>
|
||||
<%=- ''.join(table.body) %>
|
||||
\end{tabulary}
|
||||
<%- if table.align %>
|
||||
<%- if table.align == 'center' -%>
|
||||
\end{center}
|
||||
<%- elif table.align in ('left', 'right') -%>
|
||||
\end{flush<%= table.align%>}
|
||||
<% endif -%>
|
||||
<% endif -%>
|
||||
<%- if table.caption %>
|
||||
\end{threeparttable}
|
||||
<%- endif %>
|
||||
|
@@ -320,6 +320,7 @@ class Table(object):
|
||||
# type: (nodes.table) -> None
|
||||
self.header = [] # type: List[unicode]
|
||||
self.body = [] # type: List[unicode]
|
||||
self.align = node.get('align')
|
||||
self.colcount = 0
|
||||
self.colspec = None # type: unicode
|
||||
self.colwidths = [] # type: List[int]
|
||||
|
@@ -30,6 +30,21 @@ longtable having :widths: option
|
||||
cell3-1 cell3-2
|
||||
======= =======
|
||||
|
||||
longtable having :align: option
|
||||
-------------------------------
|
||||
|
||||
.. table::
|
||||
:align: right
|
||||
:class: longtable
|
||||
|
||||
======= =======
|
||||
header1 header2
|
||||
======= =======
|
||||
cell1-1 cell1-2
|
||||
cell2-1 cell2-2
|
||||
cell3-1 cell3-2
|
||||
======= =======
|
||||
|
||||
longtable with tabularcolumn
|
||||
----------------------------
|
||||
|
||||
|
@@ -43,6 +43,35 @@ table having :widths: option
|
||||
cell3-1 cell3-2
|
||||
======= =======
|
||||
|
||||
table having :align: option (tabulary)
|
||||
--------------------------------------
|
||||
|
||||
.. table::
|
||||
:align: center
|
||||
|
||||
======= =======
|
||||
header1 header2
|
||||
======= =======
|
||||
cell1-1 cell1-2
|
||||
cell2-1 cell2-2
|
||||
cell3-1 cell3-2
|
||||
======= =======
|
||||
|
||||
table having :align: option (tabular)
|
||||
-------------------------------------
|
||||
|
||||
.. table::
|
||||
:align: left
|
||||
:widths: 30,70
|
||||
|
||||
======= =======
|
||||
header1 header2
|
||||
======= =======
|
||||
cell1-1 cell1-2
|
||||
cell2-1 cell2-2
|
||||
cell3-1 cell3-2
|
||||
======= =======
|
||||
|
||||
table with tabularcolumn
|
||||
------------------------
|
||||
|
||||
|
@@ -862,6 +862,17 @@ def test_latex_table_tabulars(app, status, warning):
|
||||
assert ('\\noindent\\begin{tabular}{|\\X{30}{100}|\\X{70}{100}|}' in table)
|
||||
assert ('\\hline\n\\end{tabular}' in table)
|
||||
|
||||
# table having :align: option (tabulary)
|
||||
table = tables['table having :align: option (tabulary)']
|
||||
assert ('\\begin{center}\\noindent\\begin{tabulary}{\\linewidth}{|L|L|}\n' in table)
|
||||
assert ('\\hline\n\\end{tabulary}\\end{center}' in table)
|
||||
|
||||
# table having :align: option (tabular)
|
||||
table = tables['table having :align: option (tabular)']
|
||||
assert ('\\begin{flushleft}'
|
||||
'\\noindent\\begin{tabular}{|\X{30}{100}|\X{70}{100}|}\n' in table)
|
||||
assert ('\\hline\n\\end{tabular}\\end{flushleft}' in table)
|
||||
|
||||
# table with tabularcolumn
|
||||
table = tables['table with tabularcolumn']
|
||||
assert ('\\noindent\\begin{tabulary}{\\linewidth}{|c|c|}' in table)
|
||||
@@ -923,6 +934,11 @@ def test_latex_table_longtable(app, status, warning):
|
||||
table = tables['longtable having :widths: option']
|
||||
assert ('\\begin{longtable}{|\\X{30}{100}|\\X{70}{100}|}' in table)
|
||||
|
||||
# longtable having :align: option
|
||||
table = tables['longtable having :align: option']
|
||||
assert ('\\begin{longtable}[r]{|l|l|}\n' in table)
|
||||
assert ('\\hline\n\\end{longtable}' in table)
|
||||
|
||||
# longtable with tabularcolumn
|
||||
table = tables['longtable with tabularcolumn']
|
||||
assert ('\\begin{longtable}{|c|c|}' in table)
|
||||
|
Reference in New Issue
Block a user