diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-07-27 10:24:06 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-07-27 10:24:06 -0700 |
commit | 0baaa1080a5e937bf8b3c301fbe5db08145b58b4 (patch) | |
tree | b3cf368684b2e2bd9545b82dbf3bdf93d2572e2d | |
parent | 2a4dbc3dce037d16a65d569ada6be2fb05240e4e (diff) | |
download | pandoc-0baaa1080a5e937bf8b3c301fbe5db08145b58b4.tar.gz |
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.
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 4 | ||||
-rw-r--r-- | tests/pipe-tables.native | 10 | ||||
-rw-r--r-- | tests/pipe-tables.txt | 7 |
3 files changed, 19 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index ae81ae7fc..80a13b3bd 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1333,6 +1333,8 @@ pipeBreak = try $ do pipeTable :: MarkdownParser ([Alignment], [Double], F [Blocks], F [[Blocks]]) pipeTable = try $ do + nonindentSpaces + lookAhead nonspaceChar (heads,aligns) <- (,) <$> pipeTableRow <*> pipeBreak lines' <- sequence <$> many pipeTableRow let widths = replicate (length aligns) 0.0 @@ -1346,7 +1348,7 @@ sepPipe = try $ do -- parse a row, also returning probable alignments for org-table cells pipeTableRow :: MarkdownParser (F [Blocks]) pipeTableRow = do - nonindentSpaces + skipMany spaceChar openPipe <- (True <$ char '|') <|> return False let cell = mconcat <$> many (notFollowedBy (blankline <|> char '|') >> inline) diff --git a/tests/pipe-tables.native b/tests/pipe-tables.native index eafd21d22..9d499c9c2 100644 --- a/tests/pipe-tables.native +++ b/tests/pipe-tables.native @@ -75,4 +75,12 @@ ,Para [Str "Header-less",Space,Str "one-column:"] ,Table [] [AlignCenter] [0.0] [[]] - [[[Plain [Str "hi"]]]]] + [[[Plain [Str "hi"]]]] +,Para [Str "Indented",Space,Str "left",Space,Str "column:"] +,Table [] [AlignRight,AlignLeft] [0.0,0.0] + [[Plain [Str "Number",Space,Str "of",Space,Str "siblings"]] + ,[Plain [Str "Salary"]]] + [[[Plain [Str "3"]] + ,[Plain [Str "33"]]] + ,[[Plain [Str "4"]] + ,[Plain [Str "44"]]]]] diff --git a/tests/pipe-tables.txt b/tests/pipe-tables.txt index 83debd595..a8803724a 100644 --- a/tests/pipe-tables.txt +++ b/tests/pipe-tables.txt @@ -52,3 +52,10 @@ Header-less one-column: | | |:-:| |hi| + +Indented left column: + +Number of siblings | Salary +------------------:|:------ + 3 | 33 + 4 | 44 |