diff options
author | John MacFarlane <jgm@berkeley.edu> | 2012-09-14 23:29:06 -0400 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2012-09-14 23:29:06 -0400 |
commit | 28d2cf9500c01e57c580be8194018aa7d6109e7a (patch) | |
tree | 9c15825d9e1777b89fb0545be96b8962061385c7 | |
parent | ce509be57a1209367d71a4cd5959f0478a5b2294 (diff) | |
download | pandoc-28d2cf9500c01e57c580be8194018aa7d6109e7a.tar.gz |
MediaWiki reader: Improved table parsing.
-rw-r--r-- | src/Text/Pandoc/Readers/MediaWiki.hs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index 9f78146f8..9bd0af12a 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -193,16 +193,22 @@ cellsep = try $ guardColumnOne <* (char '!' <|> (char '|' <* notFollowedBy (oneOf "-}+"))) tableCaption :: MWParser Inlines -tableCaption = try $ guardColumnOne *> sym "|+" *> skipMany spaceChar *> - (trimInlines . mconcat <$> (many inline)) <* skipMany blankline +tableCaption = try $ do + guardColumnOne + sym "|+" + skipMany spaceChar + res <- manyTill anyChar newline >>= parseFromString (many inline) + return $ trimInlines $ mconcat res tableRow :: MWParser [Blocks] tableRow = try $ many tableCell tableCell :: MWParser Blocks -tableCell = - try $ cellsep *> skipMany spaceChar *> - (mconcat <$> (many $ notFollowedBy (cellsep <|> rowsep <|> tableEnd) *> block)) +tableCell = try $ do + cellsep + skipMany spaceChar + ls <- many (notFollowedBy (cellsep <|> rowsep <|> tableEnd) *> anyLine) + parseFromString (mconcat <$> many block) (unlines ls) template :: MWParser Blocks template = B.rawBlock "mediawiki" <$> doublebrackets @@ -406,8 +412,6 @@ inlineTag = do special :: MWParser Inlines special = B.str <$> count 1 (notFollowedBy' (htmlTag isBlockTag') *> --- notFollowedBy (tableStart <|> tableEnd --- <|> cellsep <|> rowsep) *> oneOf specialChars) inlineHtml :: MWParser Inlines @@ -421,10 +425,7 @@ endline = () <$ try (newline <* notFollowedBy blankline <* notFollowedBy' hrule <* notFollowedBy tableStart <* - notFollowedBy tableEnd <* notFollowedBy' template <* - notFollowedBy cellsep <* - notFollowedBy rowsep <* notFollowedBy anyListStart) image :: MWParser Inlines |