aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-08-10 13:29:37 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2012-08-10 13:29:37 -0700
commit3a17919a46ea17f82ca4d694c22a78c61bbf1e4a (patch)
tree764de5a135c8276b287ba2d445da593e8f5e4bfc /src
parent5a2e601c326586ab26c6168fa514e1a877ada2f3 (diff)
downloadpandoc-3a17919a46ea17f82ca4d694c22a78c61bbf1e4a.tar.gz
Markdown: Allow pipe tables created by emacs orgtbl-mode to work.
The difference is the + separators. Note: only simple org-tables work, with no bottom line. This just allows you to use org-mode's nice table editor to create regular pipe tables. In particular, org-mode's method for determining column alignments implicitly is not enabled. You must put in :s to specify alignments, as stated in the documentation.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 0205e4603..3e95ebbdf 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -993,27 +993,31 @@ pipeTable = try $ do
(heads,aligns) <- try ( pipeBreak >>= \als ->
return (return $ replicate (length als) mempty, als))
<|> ( pipeTableRow >>= \row -> pipeBreak >>= \als ->
+
return (row, als) )
- lines' <- fmap sequence $ many1 pipeTableRow
+ lines' <- sequence <$> many1 pipeTableRow
blanklines
let widths = replicate (length aligns) 0.0
return $ (aligns, widths, heads, lines')
sepPipe :: Parser [Char] ParserState ()
-sepPipe = try $ char '|' >> notFollowedBy blankline
+sepPipe = try $ do
+ char '|' <|> char '+'
+ notFollowedBy blankline
+-- parse a row, also returning probable alignments for org-table cells
pipeTableRow :: Parser [Char] ParserState (F [Blocks])
pipeTableRow = do
nonindentSpaces
optional (char '|')
let cell = mconcat <$>
- many (notFollowedBy (blankline <|> char '|') >> inline)
+ many (notFollowedBy (blankline <|> char '|') >> inline)
first <- cell
sepPipe
rest <- cell `sepBy1` sepPipe
optional (char '|')
blankline
- let cells = sequence (first:rest)
+ let cells = sequence (first:rest)
return $ do
cells' <- cells
return $ map