mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add testcases for latex tables
This commit is contained in:
parent
4f8b3f94d4
commit
40a957009d
@ -41,6 +41,57 @@ table having caption
|
||||
* - cell3-1
|
||||
- cell3-2
|
||||
|
||||
table having verbatim
|
||||
---------------------
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - header1
|
||||
- header2
|
||||
* - ::
|
||||
|
||||
hello world
|
||||
|
||||
- cell1-2
|
||||
* - cell2-1
|
||||
- cell2-2
|
||||
* - cell3-1
|
||||
- cell3-2
|
||||
|
||||
table having both :widths: and problematic cell
|
||||
-----------------------------------------------
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
:widths: 30,70
|
||||
|
||||
* - header1
|
||||
- header2
|
||||
* - + item1
|
||||
+ item2
|
||||
- cell1-2
|
||||
* - cell2-1
|
||||
- cell2-2
|
||||
* - cell3-1
|
||||
- cell3-2
|
||||
|
||||
table having problematic cell
|
||||
-----------------------------
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - header1
|
||||
- header2
|
||||
* - + item1
|
||||
+ item2
|
||||
- cell1-2
|
||||
* - cell2-1
|
||||
- cell2-2
|
||||
* - cell3-1
|
||||
- cell3-2
|
||||
|
||||
longtable
|
||||
---------
|
||||
|
||||
@ -54,3 +105,88 @@ longtable
|
||||
cell2-1 cell2-2
|
||||
cell3-1 cell3-2
|
||||
======= =======
|
||||
|
||||
longtable having :widths: option
|
||||
--------------------------------
|
||||
|
||||
.. table::
|
||||
:class: longtable
|
||||
:widths: 30,70
|
||||
|
||||
======= =======
|
||||
header1 header2
|
||||
======= =======
|
||||
cell1-1 cell1-2
|
||||
cell2-1 cell2-2
|
||||
cell3-1 cell3-2
|
||||
======= =======
|
||||
|
||||
longtable having caption
|
||||
------------------------
|
||||
|
||||
.. list-table:: caption for longtable
|
||||
:class: longtable
|
||||
:header-rows: 1
|
||||
|
||||
* - header1
|
||||
- header2
|
||||
* - cell1-1
|
||||
- cell1-2
|
||||
* - cell2-1
|
||||
- cell2-2
|
||||
* - cell3-1
|
||||
- cell3-2
|
||||
|
||||
longtable having verbatim
|
||||
-------------------------
|
||||
|
||||
.. list-table::
|
||||
:class: longtable
|
||||
:header-rows: 1
|
||||
|
||||
* - header1
|
||||
- header2
|
||||
* - ::
|
||||
|
||||
hello world
|
||||
|
||||
- cell1-2
|
||||
* - cell2-1
|
||||
- cell2-2
|
||||
* - cell3-1
|
||||
- cell3-2
|
||||
|
||||
longtable having both :widths: and problematic cell
|
||||
---------------------------------------------------
|
||||
|
||||
.. list-table::
|
||||
:class: longtable
|
||||
:header-rows: 1
|
||||
:widths: 30,70
|
||||
|
||||
* - header1
|
||||
- header2
|
||||
* - + item1
|
||||
+ item2
|
||||
- cell1-2
|
||||
* - cell2-1
|
||||
- cell2-2
|
||||
* - cell3-1
|
||||
- cell3-2
|
||||
|
||||
longtable having problematic cell
|
||||
---------------------------------
|
||||
|
||||
.. list-table::
|
||||
:class: longtable
|
||||
:header-rows: 1
|
||||
|
||||
* - header1
|
||||
- header2
|
||||
* - + item1
|
||||
+ item2
|
||||
- cell1-2
|
||||
* - cell2-1
|
||||
- cell2-2
|
||||
* - cell3-1
|
||||
- cell3-2
|
||||
|
@ -865,6 +865,26 @@ def test_latex_table(app, status, warning):
|
||||
assert ('\\hline\ncell2-1\n&\ncell2-2\n\\\\' in table)
|
||||
assert ('\\hline\ncell3-1\n&\ncell3-2\n\\\\' in table)
|
||||
assert ('\\hline\\end{tabulary}' in table)
|
||||
assert ('\\end{threeparttable}' in table)
|
||||
|
||||
# table having verbatim
|
||||
table = tables['table having verbatim']
|
||||
assert ('\\noindent\\begin{tabular}{|*{2}{'
|
||||
'p{\\dimexpr(\\linewidth-\\arrayrulewidth)/2-2\\tabcolsep-\\arrayrulewidth\\relax}|}}\n'
|
||||
'\\hline' in table)
|
||||
|
||||
# table having problematic cell
|
||||
table = tables['table having problematic cell']
|
||||
assert ('\\noindent\\begin{tabular}{|*{2}{'
|
||||
'p{\\dimexpr(\\linewidth-\\arrayrulewidth)/2-2\\tabcolsep-\\arrayrulewidth\\relax}|}}\n'
|
||||
'\\hline' in table)
|
||||
|
||||
# table having both :widths: and problematic cell
|
||||
table = tables['table having both :widths: and problematic cell']
|
||||
assert ('\\noindent\\begin{tabular}{'
|
||||
'|p{\\dimexpr(\\linewidth-\\arrayrulewidth)*30/100-2\\tabcolsep-\\arrayrulewidth\\relax}'
|
||||
'|p{\\dimexpr(\\linewidth-\\arrayrulewidth)*70/100-2\\tabcolsep-\\arrayrulewidth\\relax}|}'
|
||||
in table)
|
||||
|
||||
# longtable
|
||||
table = tables['longtable']
|
||||
@ -886,3 +906,34 @@ def test_latex_table(app, status, warning):
|
||||
assert ('\\hline\ncell2-1\n&\ncell2-2\n\\\\' in table)
|
||||
assert ('\\hline\ncell3-1\n&\ncell3-2\n\\\\' in table)
|
||||
assert ('\\hline\\end{longtable}' in table)
|
||||
|
||||
# longtable having :widths: option
|
||||
table = tables['longtable having :widths: option']
|
||||
assert ('\\begin{longtable}{'
|
||||
'|p{\\dimexpr(\\linewidth-\\arrayrulewidth)*30/100-2\\tabcolsep-\\arrayrulewidth\\relax}'
|
||||
'|p{\\dimexpr(\\linewidth-\\arrayrulewidth)*70/100-2\\tabcolsep-\\arrayrulewidth\\relax}|}'
|
||||
in table)
|
||||
|
||||
# longtable having caption
|
||||
table = tables['longtable having caption']
|
||||
assert ('\\begin{longtable}{|l|l|}\n\\caption{caption for longtable}'
|
||||
'\\label{\\detokenize{index:id2}}\\\\\n\\hline' in table)
|
||||
|
||||
# longtable having verbatim
|
||||
table = tables['longtable having verbatim']
|
||||
assert ('\\begin{longtable}{|*{2}{'
|
||||
'p{\\dimexpr(\\linewidth-\\arrayrulewidth)/2-2\\tabcolsep-\\arrayrulewidth\\relax}|}}\n'
|
||||
'\\hline' in table)
|
||||
|
||||
# longtable having problematic cell
|
||||
table = tables['longtable having problematic cell']
|
||||
assert ('\\begin{longtable}{|*{2}{'
|
||||
'p{\\dimexpr(\\linewidth-\\arrayrulewidth)/2-2\\tabcolsep-\\arrayrulewidth\\relax}|}}\n'
|
||||
'\\hline' in table)
|
||||
|
||||
# longtable having both :widths: and problematic cell
|
||||
table = tables['longtable having both :widths: and problematic cell']
|
||||
assert ('\\begin{longtable}{'
|
||||
'|p{\\dimexpr(\\linewidth-\\arrayrulewidth)*30/100-2\\tabcolsep-\\arrayrulewidth\\relax}'
|
||||
'|p{\\dimexpr(\\linewidth-\\arrayrulewidth)*70/100-2\\tabcolsep-\\arrayrulewidth\\relax}|}'
|
||||
in table)
|
||||
|
Loading…
Reference in New Issue
Block a user