From cf15b929f833ea31b35bafb40f782e113546caa0 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 18 Jun 2014 17:55:21 -0700 Subject: Added haddock writer tests. --- tests/tables.haddock | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 tests/tables.haddock (limited to 'tests/tables.haddock') diff --git a/tests/tables.haddock b/tests/tables.haddock new file mode 100644 index 000000000..e054dc072 --- /dev/null +++ b/tests/tables.haddock @@ -0,0 +1,72 @@ +Simple table with caption: + +> Right Left Center Default +> ------- ------ -------- --------- +> 12 12 12 12 +> 123 123 123 123 +> 1 1 1 1 +> +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 +> +Multiline table with caption: + +> -------------------------------------------------------------- +> Centered Left Right Default aligned +> Header Aligned 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. +> -------------------------------------------------------------- +> +Multiline table without caption: + +> -------------------------------------------------------------- +> Centered Left Right Default aligned +> Header Aligned 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 without column headers: + +> ----- ----- ----- ----- +> 12 12 12 12 +> 123 123 123 123 +> 1 1 1 1 +> ----- ----- ----- ----- +> +Multiline table without column headers: + +> ----------- ---------- ------------ -------------------------- +> 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. +> ----------- ---------- ------------ -------------------------- +> + -- cgit v1.2.3 From c4182b39ca009f02fc4e0768056d37d64b93df7c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 18 Jun 2014 18:08:41 -0700 Subject: Small fix to haddock "tables". --- src/Text/Pandoc/Writers/Haddock.hs | 4 ++-- tests/tables.haddock | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'tests/tables.haddock') diff --git a/src/Text/Pandoc/Writers/Haddock.hs b/src/Text/Pandoc/Writers/Haddock.hs index 36f57c2b7..1939d3a6d 100644 --- a/src/Text/Pandoc/Writers/Haddock.hs +++ b/src/Text/Pandoc/Writers/Haddock.hs @@ -129,7 +129,7 @@ blockToHaddock opts (BlockQuote blocks) = -- Haddock doesn't have tables. Use haddock tables in code. blockToHaddock opts (Table caption aligns widths headers rows) = do caption' <- inlineListToHaddock opts caption - let caption'' = if null caption || not (isEnabled Ext_table_captions opts) + let caption'' = if null caption then empty else blankline <> caption' <> blankline rawHeaders <- mapM (blockListToHaddock opts) headers @@ -148,7 +148,7 @@ blockToHaddock opts (Table caption aligns widths headers rows) = do | otherwise -> fmap (id,) $ gridTable opts (all null headers) aligns widths rawHeaders rawRows - return $ prefixed "> " $ nst $ tbl $$ blankline $$ caption'' $$ blankline + return $ (prefixed "> " $ nst $ tbl $$ blankline $$ caption'') $$ blankline blockToHaddock opts (BulletList items) = do contents <- mapM (bulletListItemToHaddock opts) items return $ cat contents <> blankline diff --git a/tests/tables.haddock b/tests/tables.haddock index e054dc072..413ec97ad 100644 --- a/tests/tables.haddock +++ b/tests/tables.haddock @@ -6,6 +6,8 @@ Simple table with caption: > 123 123 123 123 > 1 1 1 1 > +> Demonstration of simple table syntax. + Simple table without caption: > Right Left Center Default @@ -13,7 +15,7 @@ Simple table without caption: > 12 12 12 12 > 123 123 123 123 > 1 1 1 1 -> + Simple table indented two spaces: > Right Left Center Default @@ -22,6 +24,8 @@ Simple table indented two spaces: > 123 123 123 123 > 1 1 1 1 > +> Demonstration of simple table syntax. + Multiline table with caption: > -------------------------------------------------------------- @@ -36,6 +40,8 @@ Multiline table with caption: > rows. > -------------------------------------------------------------- > +> Here\'s the caption. It may span multiple lines. + Multiline table without caption: > -------------------------------------------------------------- @@ -49,7 +55,7 @@ Multiline table without caption: > the blank line between > rows. > -------------------------------------------------------------- -> + Table without column headers: > ----- ----- ----- ----- @@ -57,7 +63,7 @@ Table without column headers: > 123 123 123 123 > 1 1 1 1 > ----- ----- ----- ----- -> + Multiline table without column headers: > ----------- ---------- ------------ -------------------------- @@ -68,5 +74,4 @@ Multiline table without column headers: > the blank line between > rows. > ----------- ---------- ------------ -------------------------- -> -- cgit v1.2.3