aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-09-15 16:17:52 -0400
committerJohn MacFarlane <jgm@berkeley.edu>2012-09-15 16:17:52 -0400
commitc9faa2740b5ab632a2dce3965ea8a3719407933b (patch)
treeb4aaf0ca8c83f70b8c831ffe8d1d2ec32ec8a8f2 /src/Text
parent887fc14f3d6f2909a2201769e4b8a54a8f6c8793 (diff)
downloadpandoc-c9faa2740b5ab632a2dce3965ea8a3719407933b.tar.gz
MediaWiki reader: Properly handle templates in list items.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/MediaWiki.hs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs
index 3d17e245b..e65a4dc70 100644
--- a/src/Text/Pandoc/Readers/MediaWiki.hs
+++ b/src/Text/Pandoc/Readers/MediaWiki.hs
@@ -397,8 +397,9 @@ listItem c = try $ do
then listItem' c
else do
skipMany spaceChar
- first <- manyTill anyChar newline
- rest <- many (try $ string extras *> manyTill anyChar newline)
+ first <- concat <$> manyTill listChunk newline
+ rest <- many
+ (try $ string extras *> (concat <$> manyTill listChunk newline))
contents <- parseFromString (many1 $ listItem' c)
(unlines (first : rest))
case c of
@@ -407,13 +408,23 @@ listItem c = try $ do
':' -> return $ B.definitionList [(mempty, contents)]
_ -> mzero
+-- The point of this is to handle stuff like
+-- * {{cite book
+-- | blah
+-- | blah
+-- }}
+-- * next list item
+-- which seems to be valid mediawiki.
+listChunk :: MWParser String
+listChunk = template <|> count 1 anyChar
+
listItem' :: Char -> MWParser Blocks
listItem' c = try $ do
listStart c
skipMany spaceChar
- first <- manyTill anyChar newline
+ first <- concat <$> manyTill listChunk newline
rest <- many (try $ char c *> lookAhead listStartChar *>
- manyTill anyChar newline)
+ (concat <$> manyTill listChunk newline))
parseFromString (firstParaToPlain . mconcat <$> many1 block)
$ unlines $ first : rest