diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/runtests.pl | 19 | ||||
-rw-r--r-- | tests/tables.db | 286 | ||||
-rw-r--r-- | tests/tables.html | 138 | ||||
-rw-r--r-- | tests/tables.native | 11 | ||||
-rw-r--r-- | tests/tables.tex | 139 | ||||
-rw-r--r-- | tests/tables.txt | 57 | ||||
-rw-r--r-- | tests/writer.latex | 4 |
7 files changed, 653 insertions, 1 deletions
diff --git a/tests/runtests.pl b/tests/runtests.pl index 754b6e75e..44b56f844 100644 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -4,7 +4,7 @@ $verbose = 1; my $diffexists = `which diff`; if ($diffexists eq "") { die "diff not found in path.\n"; } -my $script = "./pandoc"; +my $script = "COLUMNS=78 ./pandoc"; use Getopt::Long; GetOptions("script=s" => \$script); @@ -73,12 +73,29 @@ print "Testing -H -B -A -c options..."; `$script -r native -s -w html -H insert -B insert -A insert -c main.css s5.native > tmp.html`; test_results("-B, -A, -H, -c options", "tmp.html", "s5.inserts.html"); +print "Testing tables:\n"; +print " html writer..."; +`$script -r native -w html tables.native > tmp.html`; +test_results("html table writer", "tmp.html", "tables.html"); + +print " latex writer..."; +`$script -r native -w latex tables.native > tmp.tex`; +test_results("latex table writer", "tmp.tex", "tables.tex"); + +print " docbook writer..."; +`$script -r native -w docbook tables.native > tmp.db`; +test_results("docbook table writer", "tmp.db", "tables.db"); + print "\nReader tests:\n"; print "Testing markdown reader..."; `$script -r markdown -w native -s -S testsuite.txt > tmp.native`; test_results("markdown reader", "tmp.native", "testsuite.native"); +print " tables..."; +`$script -r markdown -w native tables.txt > tmp.native`; +test_results("markdown table reader", "tmp.native", "tables.native"); + print "Testing rst reader..."; `$script -r rst -w native -s rst-reader.rst > tmp.native`; test_results("rst reader", "tmp.native", "rst-reader.native"); diff --git a/tests/tables.db b/tests/tables.db new file mode 100644 index 000000000..0bb094307 --- /dev/null +++ b/tests/tables.db @@ -0,0 +1,286 @@ +<para> + Simple table with caption: +</para> +<table> + <caption> + Demonstration of simple table syntax. + </caption> + <tr> + <th align="right" style="{width: 15%;}"> + Right + </th> + <th align="left" style="{width: 8%;}"> + Left + </th> + <th align="center" style="{width: 16%;}"> + Center + </th> + <th align="left" style="{width: 12%;}"> + Default + </th> + </tr> + <tr> + <td align="right"> + 12 + </td> + <td align="left"> + 12 + </td> + <td align="center"> + 12 + </td> + <td align="left"> + 12 + </td> + </tr> + <tr> + <td align="right"> + 123 + </td> + <td align="left"> + 123 + </td> + <td align="center"> + 123 + </td> + <td align="left"> + 123 + </td> + </tr> + <tr> + <td align="right"> + 1 + </td> + <td align="left"> + 1 + </td> + <td align="center"> + 1 + </td> + <td align="left"> + 1 + </td> + </tr> +</table> +<para> + Simple table without caption: +</para> +<informaltable> + <tr> + <th align="right" style="{width: 15%;}"> + Right + </th> + <th align="left" style="{width: 8%;}"> + Left + </th> + <th align="center" style="{width: 16%;}"> + Center + </th> + <th align="left" style="{width: 12%;}"> + Default + </th> + </tr> + <tr> + <td align="right"> + 12 + </td> + <td align="left"> + 12 + </td> + <td align="center"> + 12 + </td> + <td align="left"> + 12 + </td> + </tr> + <tr> + <td align="right"> + 123 + </td> + <td align="left"> + 123 + </td> + <td align="center"> + 123 + </td> + <td align="left"> + 123 + </td> + </tr> + <tr> + <td align="right"> + 1 + </td> + <td align="left"> + 1 + </td> + <td align="center"> + 1 + </td> + <td align="left"> + 1 + </td> + </tr> +</informaltable> +<para> + Simple table indented two spaces: +</para> +<table> + <caption> + Demonstration of simple table syntax. + </caption> + <tr> + <th align="right" style="{width: 15%;}"> + Right + </th> + <th align="left" style="{width: 8%;}"> + Left + </th> + <th align="center" style="{width: 16%;}"> + Center + </th> + <th align="left" style="{width: 12%;}"> + Default + </th> + </tr> + <tr> + <td align="right"> + 12 + </td> + <td align="left"> + 12 + </td> + <td align="center"> + 12 + </td> + <td align="left"> + 12 + </td> + </tr> + <tr> + <td align="right"> + 123 + </td> + <td align="left"> + 123 + </td> + <td align="center"> + 123 + </td> + <td align="left"> + 123 + </td> + </tr> + <tr> + <td align="right"> + 1 + </td> + <td align="left"> + 1 + </td> + <td align="center"> + 1 + </td> + <td align="left"> + 1 + </td> + </tr> +</table> +<para> + Multiline table with caption: +</para> +<table> + <caption> + Here's the caption. It may span multiple lines. + </caption> + <tr> + <th align="center" style="{width: 15%;}"> + Centered Header + </th> + <th align="left" style="{width: 13%;}"> + Left Aligned + </th> + <th align="right" style="{width: 16%;}"> + Right Aligned + </th> + <th align="left" style="{width: 33%;}"> + Default aligned + </th> + </tr> + <tr> + <td align="center"> + First + </td> + <td align="left"> + row + </td> + <td align="right"> + 12.0 + </td> + <td align="left"> + Example of a row that spans multiple lines. + </td> + </tr> + <tr> + <td align="center"> + Second + </td> + <td align="left"> + row + </td> + <td align="right"> + 5.0 + </td> + <td align="left"> + Here's another one. Note the blank line between rows. + </td> + </tr> +</table> +<para> + Multiline table without caption: +</para> +<informaltable> + <tr> + <th align="center" style="{width: 15%;}"> + Centered Header + </th> + <th align="left" style="{width: 13%;}"> + Left Aligned + </th> + <th align="right" style="{width: 16%;}"> + Right Aligned + </th> + <th align="left" style="{width: 33%;}"> + Default aligned + </th> + </tr> + <tr> + <td align="center"> + First + </td> + <td align="left"> + row + </td> + <td align="right"> + 12.0 + </td> + <td align="left"> + Example of a row that spans multiple lines. + </td> + </tr> + <tr> + <td align="center"> + Second + </td> + <td align="left"> + row + </td> + <td align="right"> + 5.0 + </td> + <td align="left"> + Here's another one. Note the blank line between rows. + </td> + </tr> +</informaltable> diff --git a/tests/tables.html b/tests/tables.html new file mode 100644 index 000000000..e145088d2 --- /dev/null +++ b/tests/tables.html @@ -0,0 +1,138 @@ +<p> + Simple table with caption: +</p> +<table> + <caption>Demonstration of simple table syntax.</caption> + <tr> + <th align="right" style="{width: 15%;}">Right</th> + <th align="left" style="{width: 8%;}">Left</th> + <th align="center" style="{width: 16%;}">Center</th> + <th align="left" style="{width: 12%;}">Default</th> + </tr> + <tr> + <td align="right">12</td> + <td align="left">12</td> + <td align="center">12</td> + <td align="left">12</td> + </tr> + <tr> + <td align="right">123</td> + <td align="left">123</td> + <td align="center">123</td> + <td align="left">123</td> + </tr> + <tr> + <td align="right">1</td> + <td align="left">1</td> + <td align="center">1</td> + <td align="left">1</td> + </tr> +</table> +<p> + Simple table without caption: +</p> +<table> + <tr> + <th align="right" style="{width: 15%;}">Right</th> + <th align="left" style="{width: 8%;}">Left</th> + <th align="center" style="{width: 16%;}">Center</th> + <th align="left" style="{width: 12%;}">Default</th> + </tr> + <tr> + <td align="right">12</td> + <td align="left">12</td> + <td align="center">12</td> + <td align="left">12</td> + </tr> + <tr> + <td align="right">123</td> + <td align="left">123</td> + <td align="center">123</td> + <td align="left">123</td> + </tr> + <tr> + <td align="right">1</td> + <td align="left">1</td> + <td align="center">1</td> + <td align="left">1</td> + </tr> +</table> +<p> + Simple table indented two spaces: +</p> +<table> + <caption>Demonstration of simple table syntax.</caption> + <tr> + <th align="right" style="{width: 15%;}">Right</th> + <th align="left" style="{width: 8%;}">Left</th> + <th align="center" style="{width: 16%;}">Center</th> + <th align="left" style="{width: 12%;}">Default</th> + </tr> + <tr> + <td align="right">12</td> + <td align="left">12</td> + <td align="center">12</td> + <td align="left">12</td> + </tr> + <tr> + <td align="right">123</td> + <td align="left">123</td> + <td align="center">123</td> + <td align="left">123</td> + </tr> + <tr> + <td align="right">1</td> + <td align="left">1</td> + <td align="center">1</td> + <td align="left">1</td> + </tr> +</table> +<p> + Multiline table with caption: +</p> +<table> + <caption>Here's the caption. It may span multiple lines.</caption> + <tr> + <th align="center" style="{width: 15%;}">Centered Header</th> + <th align="left" style="{width: 13%;}">Left Aligned</th> + <th align="right" style="{width: 16%;}">Right Aligned</th> + <th align="left" style="{width: 33%;}">Default aligned</th> + </tr> + <tr> + <td align="center">First</td> + <td align="left">row</td> + <td align="right">12.0</td> + <td align="left">Example of a row that spans multiple lines.</td> + </tr> + <tr> + <td align="center">Second</td> + <td align="left">row</td> + <td align="right">5.0</td> + <td align="left">Here's another one. Note the blank line between + rows.</td> + </tr> +</table> +<p> + Multiline table without caption: +</p> +<table> + <tr> + <th align="center" style="{width: 15%;}">Centered Header</th> + <th align="left" style="{width: 13%;}">Left Aligned</th> + <th align="right" style="{width: 16%;}">Right Aligned</th> + <th align="left" style="{width: 33%;}">Default aligned</th> + </tr> + <tr> + <td align="center">First</td> + <td align="left">row</td> + <td align="right">12.0</td> + <td align="left">Example of a row that spans multiple lines.</td> + </tr> + <tr> + <td align="center">Second</td> + <td align="left">row</td> + <td align="right">5.0</td> + <td align="left">Here's another one. Note the blank line between + rows.</td> + </tr> +</table> diff --git a/tests/tables.native b/tests/tables.native new file mode 100644 index 000000000..7572dfdc2 --- /dev/null +++ b/tests/tables.native @@ -0,0 +1,11 @@ +Pandoc (Meta [] [] "") +[ Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption:"] +, Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax",Str "."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.15,8.75e-2,0.1625,0.125] [[Plain [Str "Right"]],[Plain [Str "Left"]],[Plain [Str "Center"]],[Plain [Str "Default"]]] [[[Plain [Str "12"]],[Plain [Str "12"]],[Plain [Str "12"]],[Plain [Str "12"]]],[[Plain [Str "123"]],[Plain [Str "123"]],[Plain [Str "123"]],[Plain [Str "123"]]],[[Plain [Str "1"]],[Plain [Str "1"]],[Plain [Str "1"]],[Plain [Str "1"]]]] +, Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption:"] +, Table [] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.15,8.75e-2,0.1625,0.125] [[Plain [Str "Right"]],[Plain [Str "Left"]],[Plain [Str "Center"]],[Plain [Str "Default"]]] [[[Plain [Str "12"]],[Plain [Str "12"]],[Plain [Str "12"]],[Plain [Str "12"]]],[[Plain [Str "123"]],[Plain [Str "123"]],[Plain [Str "123"]],[Plain [Str "123"]]],[[Plain [Str "1"]],[Plain [Str "1"]],[Plain [Str "1"]],[Plain [Str "1"]]]] +, Para [Str "Simple",Space,Str "table",Space,Str "indented",Space,Str "two",Space,Str "spaces:"] +, Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax",Str "."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.15,8.75e-2,0.1625,0.125] [[Plain [Str "Right"]],[Plain [Str "Left"]],[Plain [Str "Center"]],[Plain [Str "Default"]]] [[[Plain [Str "12"]],[Plain [Str "12"]],[Plain [Str "12"]],[Plain [Str "12"]]],[[Plain [Str "123"]],[Plain [Str "123"]],[Plain [Str "123"]],[Plain [Str "123"]]],[[Plain [Str "1"]],[Plain [Str "1"]],[Plain [Str "1"]],[Plain [Str "1"]]]] +, Para [Str "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption:"] +, Table [Str "Here",Str "'",Str "s",Space,Str "the",Space,Str "caption",Str ".",Space,Str "It",Space,Str "may",Space,Str "span",Space,Str "multiple",Space,Str "lines",Str "."] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.15,0.1375,0.1625,0.3375] [[Plain [Str "Centered",Space,Str "Header"]],[Plain [Str "Left",Space,Str "Aligned"]],[Plain [Str "Right",Space,Str "Aligned"]],[Plain [Str "Default",Space,Str "aligned"]]] [[[Plain [Str "First"]],[Plain [Str "row"]],[Plain [Str "12",Str ".",Str "0"]],[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]],[[Plain [Str "Second"]],[Plain [Str "row"]],[Plain [Str "5",Str ".",Str "0"]],[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]] +, Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "caption:"] +, Table [] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.15,0.1375,0.1625,0.3375] [[Plain [Str "Centered",Space,Str "Header"]],[Plain [Str "Left",Space,Str "Aligned"]],[Plain [Str "Right",Space,Str "Aligned"]],[Plain [Str "Default",Space,Str "aligned"]]] [[[Plain [Str "First"]],[Plain [Str "row"]],[Plain [Str "12",Str ".",Str "0"]],[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]],[[Plain [Str "Second"]],[Plain [Str "row"]],[Plain [Str "5",Str ".",Str "0"]],[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]] ] diff --git a/tests/tables.tex b/tests/tables.tex new file mode 100644 index 000000000..4cbb27385 --- /dev/null +++ b/tests/tables.tex @@ -0,0 +1,139 @@ +Simple table with caption: + +\begin{table}[h] +\begin{center} +\begin{tabular}{>{\PBS\raggedleft\hspace{0pt}}p{0.15\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.09\textwidth}>{\PBS\centering\hspace{0pt}}p{0.16\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.13\textwidth}} +Right + & Left + & Center + & Default +\\ +\hline +12 + & 12 + & 12 + & 12 +\\ +123 + & 123 + & 123 + & 123 +\\ +1 + & 1 + & 1 + & 1 +\\ +\end{tabular} +\end{center} +\caption{Demonstration of simple table syntax.} +\end{table} + +Simple table without caption: + +\begin{center} +\begin{tabular}{>{\PBS\raggedleft\hspace{0pt}}p{0.15\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.09\textwidth}>{\PBS\centering\hspace{0pt}}p{0.16\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.13\textwidth}} +Right + & Left + & Center + & Default +\\ +\hline +12 + & 12 + & 12 + & 12 +\\ +123 + & 123 + & 123 + & 123 +\\ +1 + & 1 + & 1 + & 1 +\\ +\end{tabular} +\end{center} + +Simple table indented two spaces: + +\begin{table}[h] +\begin{center} +\begin{tabular}{>{\PBS\raggedleft\hspace{0pt}}p{0.15\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.09\textwidth}>{\PBS\centering\hspace{0pt}}p{0.16\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.13\textwidth}} +Right + & Left + & Center + & Default +\\ +\hline +12 + & 12 + & 12 + & 12 +\\ +123 + & 123 + & 123 + & 123 +\\ +1 + & 1 + & 1 + & 1 +\\ +\end{tabular} +\end{center} +\caption{Demonstration of simple table syntax.} +\end{table} + +Multiline table with caption: + +\begin{table}[h] +\begin{center} +\begin{tabular}{>{\PBS\centering\hspace{0pt}}p{0.15\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.14\textwidth}>{\PBS\raggedleft\hspace{0pt}}p{0.16\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.34\textwidth}} +Centered Header + & Left Aligned + & Right Aligned + & Default aligned +\\ +\hline +First + & row + & 12.0 + & Example of a row that spans multiple lines. +\\ +Second + & row + & 5.0 + & Here's another one. Note the blank line between rows. +\\ +\end{tabular} +\end{center} +\caption{Here's the caption. It may span multiple lines.} +\end{table} + +Multiline table without caption: + +\begin{center} +\begin{tabular}{>{\PBS\centering\hspace{0pt}}p{0.15\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.14\textwidth}>{\PBS\raggedleft\hspace{0pt}}p{0.16\textwidth}>{\PBS\raggedright\hspace{0pt}}p{0.34\textwidth}} +Centered Header + & Left Aligned + & Right Aligned + & Default aligned +\\ +\hline +First + & row + & 12.0 + & Example of a row that spans multiple lines. +\\ +Second + & row + & 5.0 + & Here's another one. Note the blank line between rows. +\\ +\end{tabular} +\end{center} + diff --git a/tests/tables.txt b/tests/tables.txt new file mode 100644 index 000000000..73b3b9cd7 --- /dev/null +++ b/tests/tables.txt @@ -0,0 +1,57 @@ +Simple table with caption: + + Right Left Center Default +------- ------ ---------- ------- + 12 12 12 12 + 123 123 123 123 + 1 1 1 1 + +Table: Demonstration of simple table syntax. + +Simple table without caption: + + Right Left Center Default +------- ------ ---------- ------- + 12 12 12 12 + 123 123 123 123 + 1 1 1 1 + +Simple table indented two spaces: + + Right Left Center Default + ------- ------ ---------- ------- + 12 12 12 12 + 123 123 123 123 + 1 1 1 1 + + Table: Demonstration of simple table syntax. + +Multiline table with caption: + +--------------------------------------------------------------- + Centered Left Right + Header Aligned Aligned Default aligned +---------- --------- ----------- --------------------------- + First row 12.0 Example of a row that spans + multiple lines. + + Second row 5.0 Here's another one. Note + the blank line between rows. +--------------------------------------------------------------- + +Table: Here's the caption. +It may span multiple lines. + +Multiline table without caption: + +--------------------------------------------------------------- + Centered Left Right + Header Aligned Aligned Default aligned +---------- --------- ----------- --------------------------- + First row 12.0 Example of a row that spans + multiple lines. + + Second row 5.0 Here's another one. Note + the blank line between rows. +--------------------------------------------------------------- + diff --git a/tests/writer.latex b/tests/writer.latex index af9aad6f9..f3ffeed62 100644 --- a/tests/writer.latex +++ b/tests/writer.latex @@ -3,11 +3,15 @@ \usepackage{ucs} \usepackage[utf8x]{inputenc} \usepackage{graphicx} +\usepackage{array} \setlength{\parindent}{0pt} \setlength{\parskip}{6pt plus 2pt minus 1pt} % This is needed for code blocks in footnotes: \usepackage{fancyvrb} \VerbatimFootnotes +% This is needed because raggedright in table elements redefines //: +\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp} +\let\PBS=\PreserveBackslash \setcounter{secnumdepth}{0} \title{Pandoc Test Suite} \author{John MacFarlane\\Anonymous} |