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.
This commit is contained in:
John MacFarlane 2012-08-10 13:29:37 -07:00
parent 5a2e601c32
commit 3a17919a46

View file

@ -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