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.
This commit is contained in:
parent
6a8fa53f6c
commit
7d687684aa
7 changed files with 19 additions and 15 deletions
5
README
5
README
|
@ -824,7 +824,8 @@ to the dashed line below it:[^4]
|
|||
The table must end with a blank line, or a line of dashes followed by
|
||||
a blank line. A caption may optionally be provided (as illustrated in
|
||||
the example above). A caption is a paragraph beginning with the string
|
||||
`Table:`, which will be stripped off.
|
||||
`Table:` (or just `:`), which will be stripped off. It may appear either
|
||||
before or after the table.
|
||||
|
||||
The column headers may be omitted, provided a dashed line is used
|
||||
to end the table. For example:
|
||||
|
@ -880,7 +881,7 @@ Headers may be omitted in multiline tables as well as simple tables:
|
|||
rows.
|
||||
-------------------------------------------------------------
|
||||
|
||||
Table: Here's a multiline table without headers.
|
||||
: Here's a multiline table without headers.
|
||||
|
||||
It is possible for a multiline table to have just one row, but the row
|
||||
should be followed by a blank line (and then the row of dashes that ends
|
||||
|
|
|
@ -415,10 +415,13 @@ tableWith :: GenParser Char ParserState ([[Block]], [Alignment], [Int])
|
|||
-> GenParser Char ParserState [Inline]
|
||||
-> GenParser Char ParserState Block
|
||||
tableWith headerParser rowParser lineParser footerParser captionParser = try $ do
|
||||
caption' <- option [] captionParser
|
||||
(heads, aligns, indices) <- headerParser
|
||||
lines' <- rowParser indices `sepEndBy` lineParser
|
||||
footerParser
|
||||
caption <- option [] captionParser
|
||||
caption <- if null caption'
|
||||
then option [] captionParser
|
||||
else return caption'
|
||||
state <- getState
|
||||
let numColumns = stateColumns state
|
||||
let widths = widthsFromIndices numColumns indices
|
||||
|
|
|
@ -775,7 +775,7 @@ multilineRow indices = do
|
|||
tableCaption :: GenParser Char ParserState [Inline]
|
||||
tableCaption = try $ do
|
||||
skipNonindentSpaces
|
||||
string "Table:"
|
||||
string ":" <|> string "Table:"
|
||||
result <- many1 inline
|
||||
blanklines
|
||||
return $ normalizeSpaces result
|
||||
|
|
|
@ -239,7 +239,7 @@ blockToMarkdown opts (Table caption aligns widths headers rows) = do
|
|||
caption' <- inlineListToMarkdown opts caption
|
||||
let caption'' = if null caption
|
||||
then empty
|
||||
else text "" $+$ (text "Table: " <> caption')
|
||||
else text "" $+$ (text ": " <> caption')
|
||||
headers' <- mapM (blockListToMarkdown opts) headers
|
||||
let alignHeader alignment = case alignment of
|
||||
AlignLeft -> leftAlignBlock
|
||||
|
|
|
@ -6,7 +6,7 @@ Simple table with caption:
|
|||
123 123 123 123
|
||||
1 1 1 1
|
||||
|
||||
Table: Demonstration of simple table syntax.
|
||||
: Demonstration of simple table syntax.
|
||||
|
||||
Simple table without caption:
|
||||
|
||||
|
@ -24,7 +24,7 @@ Simple table indented two spaces:
|
|||
123 123 123 123
|
||||
1 1 1 1
|
||||
|
||||
Table: Demonstration of simple table syntax.
|
||||
: Demonstration of simple table syntax.
|
||||
|
||||
Multiline table with caption:
|
||||
|
||||
|
@ -40,7 +40,7 @@ Multiline table with caption:
|
|||
rows.
|
||||
--------------------------------------------------------------
|
||||
|
||||
Table: Here's the caption. It may span multiple lines.
|
||||
: Here's the caption. It may span multiple lines.
|
||||
|
||||
Multiline table without caption:
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ Simple table with caption:
|
|||
123 123 123 123
|
||||
1 1 1 1
|
||||
|
||||
Table: Demonstration of simple table syntax.
|
||||
: Demonstration of simple table syntax.
|
||||
|
||||
Simple table without caption:
|
||||
|
||||
|
@ -24,7 +24,7 @@ Simple table indented two spaces:
|
|||
123 123 123 123
|
||||
1 1 1 1
|
||||
|
||||
Table: Demonstration of simple table syntax.
|
||||
: Demonstration of simple table syntax.
|
||||
|
||||
Multiline table with caption:
|
||||
|
||||
|
@ -40,7 +40,7 @@ Multiline table with caption:
|
|||
rows.
|
||||
--------------------------------------------------------------
|
||||
|
||||
Table: Here's the caption. It may span multiple lines.
|
||||
: Here's the caption. It may span multiple lines.
|
||||
|
||||
Multiline table without caption:
|
||||
|
||||
|
|
|
@ -24,10 +24,13 @@ Simple table indented two spaces:
|
|||
123 123 123 123
|
||||
1 1 1 1
|
||||
|
||||
Table: Demonstration of simple table syntax.
|
||||
: Demonstration of simple table syntax.
|
||||
|
||||
Multiline table with caption:
|
||||
|
||||
: Here's the caption.
|
||||
It may span multiple lines.
|
||||
|
||||
---------------------------------------------------------------
|
||||
Centered Left Right
|
||||
Header Aligned Aligned Default aligned
|
||||
|
@ -39,9 +42,6 @@ Multiline table with caption:
|
|||
the blank line between rows.
|
||||
---------------------------------------------------------------
|
||||
|
||||
Table: Here's the caption.
|
||||
It may span multiple lines.
|
||||
|
||||
Multiline table without caption:
|
||||
|
||||
---------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue