From 3a17919a46ea17f82ca4d694c22a78c61bbf1e4a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 10 Aug 2012 13:29:37 -0700 Subject: 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. --- src/Text/Pandoc/Readers/Markdown.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') 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 -- cgit v1.2.3