Skip to content

Commit 0544ed6

Browse files
committed
Haddock Writer: Support Haddock tables
See this PR on Haddock for details on the table format: haskell/haddock#718
1 parent 8195d4f commit 0544ed6

File tree

2 files changed

+71
-71
lines changed

2 files changed

+71
-71
lines changed

src/Text/Pandoc/Writers/Haddock.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ blockToHaddock opts (Table caption aligns widths headers rows) = do
125125
(all null headers) strictWrapping
126126
(map (const AlignDefault) aligns)
127127
widths headers rows
128-
return $ prefixed "> " (tbl $$ blankline $$ caption'') $$ blankline
128+
return $ (tbl $$ blankline $$ caption'') $$ blankline
129129
blockToHaddock opts (BulletList items) = do
130130
contents <- mapM (bulletListItemToHaddock opts) items
131131
return $ (if isTightList items then vcat else vsep) contents <> blankline

test/tables.haddock

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,90 @@
11
Simple table with caption:
22

3-
> +-------+------+--------+---------+
4-
> | Right | Left | Center | Default |
5-
> +=======+======+========+=========+
6-
> | 12 | 12 | 12 | 12 |
7-
> +-------+------+--------+---------+
8-
> | 123 | 123 | 123 | 123 |
9-
> +-------+------+--------+---------+
10-
> | 1 | 1 | 1 | 1 |
11-
> +-------+------+--------+---------+
12-
>
13-
> Demonstration of simple table syntax.
3+
+-------+------+--------+---------+
4+
| Right | Left | Center | Default |
5+
+=======+======+========+=========+
6+
| 12 | 12 | 12 | 12 |
7+
+-------+------+--------+---------+
8+
| 123 | 123 | 123 | 123 |
9+
+-------+------+--------+---------+
10+
| 1 | 1 | 1 | 1 |
11+
+-------+------+--------+---------+
12+
13+
Demonstration of simple table syntax.
1414

1515
Simple table without caption:
1616

17-
> +-------+------+--------+---------+
18-
> | Right | Left | Center | Default |
19-
> +=======+======+========+=========+
20-
> | 12 | 12 | 12 | 12 |
21-
> +-------+------+--------+---------+
22-
> | 123 | 123 | 123 | 123 |
23-
> +-------+------+--------+---------+
24-
> | 1 | 1 | 1 | 1 |
25-
> +-------+------+--------+---------+
17+
+-------+------+--------+---------+
18+
| Right | Left | Center | Default |
19+
+=======+======+========+=========+
20+
| 12 | 12 | 12 | 12 |
21+
+-------+------+--------+---------+
22+
| 123 | 123 | 123 | 123 |
23+
+-------+------+--------+---------+
24+
| 1 | 1 | 1 | 1 |
25+
+-------+------+--------+---------+
2626

2727
Simple table indented two spaces:
2828

29-
> +-------+------+--------+---------+
30-
> | Right | Left | Center | Default |
31-
> +=======+======+========+=========+
32-
> | 12 | 12 | 12 | 12 |
33-
> +-------+------+--------+---------+
34-
> | 123 | 123 | 123 | 123 |
35-
> +-------+------+--------+---------+
36-
> | 1 | 1 | 1 | 1 |
37-
> +-------+------+--------+---------+
38-
>
39-
> Demonstration of simple table syntax.
29+
+-------+------+--------+---------+
30+
| Right | Left | Center | Default |
31+
+=======+======+========+=========+
32+
| 12 | 12 | 12 | 12 |
33+
+-------+------+--------+---------+
34+
| 123 | 123 | 123 | 123 |
35+
+-------+------+--------+---------+
36+
| 1 | 1 | 1 | 1 |
37+
+-------+------+--------+---------+
38+
39+
Demonstration of simple table syntax.
4040

4141
Multiline table with caption:
4242

43-
> +----------+---------+-----------+--------------------------+
44-
> | Centered | Left | Right | Default aligned |
45-
> | Header | Aligned | Aligned | |
46-
> +==========+=========+===========+==========================+
47-
> | First | row | 12.0 | Example of a row that |
48-
> | | | | spans multiple lines. |
49-
> +----------+---------+-----------+--------------------------+
50-
> | Second | row | 5.0 | Here’s another one. Note |
51-
> | | | | the blank line between |
52-
> | | | | rows. |
53-
> +----------+---------+-----------+--------------------------+
54-
>
55-
> Here’s the caption. It may span multiple lines.
43+
+----------+---------+-----------+--------------------------+
44+
| Centered | Left | Right | Default aligned |
45+
| Header | Aligned | Aligned | |
46+
+==========+=========+===========+==========================+
47+
| First | row | 12.0 | Example of a row that |
48+
| | | | spans multiple lines. |
49+
+----------+---------+-----------+--------------------------+
50+
| Second | row | 5.0 | Here’s another one. Note |
51+
| | | | the blank line between |
52+
| | | | rows. |
53+
+----------+---------+-----------+--------------------------+
54+
55+
Here’s the caption. It may span multiple lines.
5656

5757
Multiline table without caption:
5858

59-
> +----------+---------+-----------+--------------------------+
60-
> | Centered | Left | Right | Default aligned |
61-
> | Header | Aligned | Aligned | |
62-
> +==========+=========+===========+==========================+
63-
> | First | row | 12.0 | Example of a row that |
64-
> | | | | spans multiple lines. |
65-
> +----------+---------+-----------+--------------------------+
66-
> | Second | row | 5.0 | Here’s another one. Note |
67-
> | | | | the blank line between |
68-
> | | | | rows. |
69-
> +----------+---------+-----------+--------------------------+
59+
+----------+---------+-----------+--------------------------+
60+
| Centered | Left | Right | Default aligned |
61+
| Header | Aligned | Aligned | |
62+
+==========+=========+===========+==========================+
63+
| First | row | 12.0 | Example of a row that |
64+
| | | | spans multiple lines. |
65+
+----------+---------+-----------+--------------------------+
66+
| Second | row | 5.0 | Here’s another one. Note |
67+
| | | | the blank line between |
68+
| | | | rows. |
69+
+----------+---------+-----------+--------------------------+
7070

7171
Table without column headers:
7272

73-
> +-----+-----+-----+-----+
74-
> | 12 | 12 | 12 | 12 |
75-
> +-----+-----+-----+-----+
76-
> | 123 | 123 | 123 | 123 |
77-
> +-----+-----+-----+-----+
78-
> | 1 | 1 | 1 | 1 |
79-
> +-----+-----+-----+-----+
73+
+-----+-----+-----+-----+
74+
| 12 | 12 | 12 | 12 |
75+
+-----+-----+-----+-----+
76+
| 123 | 123 | 123 | 123 |
77+
+-----+-----+-----+-----+
78+
| 1 | 1 | 1 | 1 |
79+
+-----+-----+-----+-----+
8080

8181
Multiline table without column headers:
8282

83-
> +----------+---------+-----------+--------------------------+
84-
> | First | row | 12.0 | Example of a row that |
85-
> | | | | spans multiple lines. |
86-
> +----------+---------+-----------+--------------------------+
87-
> | Second | row | 5.0 | Here’s another one. Note |
88-
> | | | | the blank line between |
89-
> | | | | rows. |
90-
> +----------+---------+-----------+--------------------------+
83+
+----------+---------+-----------+--------------------------+
84+
| First | row | 12.0 | Example of a row that |
85+
| | | | spans multiple lines. |
86+
+----------+---------+-----------+--------------------------+
87+
| Second | row | 5.0 | Here’s another one. Note |
88+
| | | | the blank line between |
89+
| | | | rows. |
90+
+----------+---------+-----------+--------------------------+

0 commit comments

Comments
 (0)