git.iko.soy/typeable/pandoc
on master help sign in
Allow language-neutral table captions.

+ Captions may now begin simply with ':', instead of 'Table:' + Captions may now appear either above or below the table. + Resolves Issue #227.

commit7d687684aa4ca0ebbdf4d9a0bcaa1d3ea1a8b7b3 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 6 Jul 2010, 21:01 (16 years ago) parent6a8fa53
7 files changed+19−15
README+3−2 src/Text/Pandoc/Parsing.hs+4−1 src/Text/Pandoc/Readers/Markdown.hs+1−1 src/Text/Pandoc/Writers/Markdown.hs+1−1 tests/tables.markdown+3−3 tests/tables.plain+3−3 tests/tables.txt+4−4
README+3−2
@@ -824,7 +824,8 @@ to the dashed line below it:[^4]
824824The table must end with a blank line, or a line of dashes followed by
825825a blank line. A caption may optionally be provided (as illustrated in
826826the example above). A caption is a paragraph beginning with the string
827−`Table:`, which will be stripped off.
827+`Table:` (or just `:`), which will be stripped off. It may appear either
828+before or after the table.
828829
829830The column headers may be omitted, provided a dashed line is used
830831to end the table. For example:
@@ -880,7 +881,7 @@ Headers may be omitted in multiline tables as well as simple tables:
880881 rows.
881882 -------------------------------------------------------------
882883
883− Table: Here's a multiline table without headers.
884+ : Here's a multiline table without headers.
884885
885886It is possible for a multiline table to have just one row, but the row
886887should be followed by a blank line (and then the row of dashes that ends
src/Text/Pandoc/Parsing.hs+4−1
@@ -415,10 +415,13 @@ tableWith :: GenParser Char ParserState ([[Block]], [Alignment], [Int])
415415 -> GenParser Char ParserState [Inline]
416416 -> GenParser Char ParserState Block
417417tableWith headerParser rowParser lineParser footerParser captionParser = try $ do
418+ caption' <- option [] captionParser
418419 (heads, aligns, indices) <- headerParser
419420 lines' <- rowParser indices `sepEndBy` lineParser
420421 footerParser
421− caption <- option [] captionParser
422+ caption <- if null caption'
423+ then option [] captionParser
424+ else return caption'
422425 state <- getState
423426 let numColumns = stateColumns state
424427 let widths = widthsFromIndices numColumns indices
src/Text/Pandoc/Readers/Markdown.hs+1−1
@@ -775,7 +775,7 @@ multilineRow indices = do
775775tableCaption :: GenParser Char ParserState [Inline]
776776tableCaption = try $ do
777777 skipNonindentSpaces
778− string "Table:"
778+ string ":" <|> string "Table:"
779779 result <- many1 inline
780780 blanklines
781781 return $ normalizeSpaces result
src/Text/Pandoc/Writers/Markdown.hs+1−1
@@ -239,7 +239,7 @@ blockToMarkdown opts (Table caption aligns widths headers rows) = do
239239 caption' <- inlineListToMarkdown opts caption
240240 let caption'' = if null caption
241241 then empty
242− else text "" $+$ (text "Table: " <> caption')
242+ else text "" $+$ (text ": " <> caption')
243243 headers' <- mapM (blockListToMarkdown opts) headers
244244 let alignHeader alignment = case alignment of
245245 AlignLeft -> leftAlignBlock
tests/tables.markdown+3−3
@@ -6,7 +6,7 @@ Simple table with caption:
66 123 123 123 123
77 1 1 1 1
88
9− Table: Demonstration of simple table syntax.
9+ : Demonstration of simple table syntax.
1010
1111Simple table without caption:
1212
@@ -24,7 +24,7 @@ Simple table indented two spaces:
2424 123 123 123 123
2525 1 1 1 1
2626
27− Table: Demonstration of simple table syntax.
27+ : Demonstration of simple table syntax.
2828
2929Multiline table with caption:
3030
@@ -40,7 +40,7 @@ Multiline table with caption:
4040 rows.
4141 --------------------------------------------------------------
4242
43− Table: Here's the caption. It may span multiple lines.
43+ : Here's the caption. It may span multiple lines.
4444
4545Multiline table without caption:
4646
tests/tables.plain+3−3
@@ -6,7 +6,7 @@ Simple table with caption:
66 123 123 123 123
77 1 1 1 1
88
9− Table: Demonstration of simple table syntax.
9+ : Demonstration of simple table syntax.
1010
1111Simple table without caption:
1212
@@ -24,7 +24,7 @@ Simple table indented two spaces:
2424 123 123 123 123
2525 1 1 1 1
2626
27− Table: Demonstration of simple table syntax.
27+ : Demonstration of simple table syntax.
2828
2929Multiline table with caption:
3030
@@ -40,7 +40,7 @@ Multiline table with caption:
4040 rows.
4141 --------------------------------------------------------------
4242
43− Table: Here's the caption. It may span multiple lines.
43+ : Here's the caption. It may span multiple lines.
4444
4545Multiline table without caption:
4646
tests/tables.txt+4−4
@@ -24,10 +24,13 @@ Simple table indented two spaces:
2424 123 123 123 123
2525 1 1 1 1
2626
27− Table: Demonstration of simple table syntax.
27+ : Demonstration of simple table syntax.
2828
2929Multiline table with caption:
3030
31+: Here's the caption.
32+It may span multiple lines.
33+
3134---------------------------------------------------------------
3235 Centered Left Right
3336 Header Aligned Aligned Default aligned
@@ -39,9 +42,6 @@ Multiline table with caption:
3942 the blank line between rows.
4043---------------------------------------------------------------
4144
42−Table: Here's the caption.
43−It may span multiple lines.
44−
4545Multiline table without caption:
4646
4747---------------------------------------------------------------