git.iko.soy/typeable/pandoc
on master help sign in
Pipe tables: allow indented columns.

Previously the left-hand column could not start with 4 or more spaces indent. This was inconvenient for right-aligned left columns. Note that the first (header column) must still have 3 or fewer spaces indentation, or the table will be treated as an indented code block.

commit0baaa1080a5e937bf8b3c301fbe5db08145b58b4 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 27 Jul 2015, 10:24 (11 years ago) parent2a4dbc3
3 files changed+19−2
src/Text/Pandoc/Readers/Markdown.hs+3−1 tests/pipe-tables.native+9−1 tests/pipe-tables.txt+7
src/Text/Pandoc/Readers/Markdown.hs+3−1
@@ -1333,6 +1333,8 @@ pipeBreak = try $ do
13331333
13341334pipeTable :: MarkdownParser ([Alignment], [Double], F [Blocks], F [[Blocks]])
13351335pipeTable = try $ do
1336+ nonindentSpaces
1337+ lookAhead nonspaceChar
13361338 (heads,aligns) <- (,) <$> pipeTableRow <*> pipeBreak
13371339 lines' <- sequence <$> many pipeTableRow
13381340 let widths = replicate (length aligns) 0.0
@@ -1346,7 +1348,7 @@ sepPipe = try $ do
13461348-- parse a row, also returning probable alignments for org-table cells
13471349pipeTableRow :: MarkdownParser (F [Blocks])
13481350pipeTableRow = do
1349− nonindentSpaces
1351+ skipMany spaceChar
13501352 openPipe <- (True <$ char '|') <|> return False
13511353 let cell = mconcat <$>
13521354 many (notFollowedBy (blankline <|> char '|') >> inline)
tests/pipe-tables.native+9−1
@@ -75,4 +75,12 @@
7575,Para [Str "Header-less",Space,Str "one-column:"]
7676,Table [] [AlignCenter] [0.0]
7777 [[]]
78− [[[Plain [Str "hi"]]]]]
78+ [[[Plain [Str "hi"]]]]
79+,Para [Str "Indented",Space,Str "left",Space,Str "column:"]
80+,Table [] [AlignRight,AlignLeft] [0.0,0.0]
81+ [[Plain [Str "Number",Space,Str "of",Space,Str "siblings"]]
82+ ,[Plain [Str "Salary"]]]
83+ [[[Plain [Str "3"]]
84+ ,[Plain [Str "33"]]]
85+ ,[[Plain [Str "4"]]
86+ ,[Plain [Str "44"]]]]]
tests/pipe-tables.txt+7
@@ -52,3 +52,10 @@ Header-less one-column:
5252| |
5353|:-:|
5454|hi|
55+
56+Indented left column:
57+
58+Number of siblings | Salary
59+------------------:|:------
60+ 3 | 33
61+ 4 | 44