git.iko.soy/typeable/pandoc
on master help sign in
Small fix to haddock "tables".
c4182b3John MacFarlane
src/Text/Pandoc/Writers/Haddock.hs+2−2
@@ -129,7 +129,7 @@ blockToHaddock opts (BlockQuote blocks) =
129-- Haddock doesn't have tables. Use haddock tables in code.
129-- Haddock doesn't have tables. Use haddock tables in code.
130blockToHaddock opts (Table caption aligns widths headers rows) = do
130blockToHaddock opts (Table caption aligns widths headers rows) = do
131 caption' <- inlineListToHaddock opts caption
131 caption' <- inlineListToHaddock opts caption
132− let caption'' = if null caption || not (isEnabled Ext_table_captions opts)
132+ let caption'' = if null caption
133 then empty
133 then empty
134 else blankline <> caption' <> blankline
134 else blankline <> caption' <> blankline
135 rawHeaders <- mapM (blockListToHaddock opts) headers
135 rawHeaders <- mapM (blockListToHaddock opts) headers
@@ -148,7 +148,7 @@ blockToHaddock opts (Table caption aligns widths headers rows) = do
148 | otherwise -> fmap (id,) $
148 | otherwise -> fmap (id,) $
149 gridTable opts (all null headers) aligns widths
149 gridTable opts (all null headers) aligns widths
150 rawHeaders rawRows
150 rawHeaders rawRows
151− return $ prefixed "> " $ nst $ tbl $$ blankline $$ caption'' $$ blankline
151+ return $ (prefixed "> " $ nst $ tbl $$ blankline $$ caption'') $$ blankline
152blockToHaddock opts (BulletList items) = do
152blockToHaddock opts (BulletList items) = do
153 contents <- mapM (bulletListItemToHaddock opts) items
153 contents <- mapM (bulletListItemToHaddock opts) items
154 return $ cat contents <> blankline
154 return $ cat contents <> blankline
tests/tables.haddock+9−4
@@ -6,6 +6,8 @@ Simple table with caption:
6> 123 123 123 123
6> 123 123 123 123
7> 1 1 1 1
7> 1 1 1 1
8>
8>
9+> Demonstration of simple table syntax.
10+
9Simple table without caption:
11Simple table without caption:
10
12
11> Right Left Center Default
13> Right Left Center Default
@@ -13,7 +15,7 @@ Simple table without caption:
13> 12 12 12 12
15> 12 12 12 12
14> 123 123 123 123
16> 123 123 123 123
15> 1 1 1 1
17> 1 1 1 1
16−>
18+
17Simple table indented two spaces:
19Simple table indented two spaces:
18
20
19> Right Left Center Default
21> Right Left Center Default
@@ -22,6 +24,8 @@ Simple table indented two spaces:
22> 123 123 123 123
24> 123 123 123 123
23> 1 1 1 1
25> 1 1 1 1
24>
26>
27+> Demonstration of simple table syntax.
28+
25Multiline table with caption:
29Multiline table with caption:
26
30
27> --------------------------------------------------------------
31> --------------------------------------------------------------
@@ -36,6 +40,8 @@ Multiline table with caption:
36> rows.
40> rows.
37> --------------------------------------------------------------
41> --------------------------------------------------------------
38>
42>
43+> Here\'s the caption. It may span multiple lines.
44+
39Multiline table without caption:
45Multiline table without caption:
40
46
41> --------------------------------------------------------------
47> --------------------------------------------------------------
@@ -49,7 +55,7 @@ Multiline table without caption:
49> the blank line between
55> the blank line between
50> rows.
56> rows.
51> --------------------------------------------------------------
57> --------------------------------------------------------------
52−>
58+
53Table without column headers:
59Table without column headers:
54
60
55> ----- ----- ----- -----
61> ----- ----- ----- -----
@@ -57,7 +63,7 @@ Table without column headers:
57> 123 123 123 123
63> 123 123 123 123
58> 1 1 1 1
64> 1 1 1 1
59> ----- ----- ----- -----
65> ----- ----- ----- -----
60−>
66+
61Multiline table without column headers:
67Multiline table without column headers:
62
68
63> ----------- ---------- ------------ --------------------------
69> ----------- ---------- ------------ --------------------------
@@ -68,5 +74,4 @@ Multiline table without column headers:
68> the blank line between
74> the blank line between
69> rows.
75> rows.
70> ----------- ---------- ------------ --------------------------
76> ----------- ---------- ------------ --------------------------
71−>
72
77