diff options
author | John MacFarlane <jgm@berkeley.edu> | 2012-09-12 16:47:30 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2012-09-12 16:47:30 -0700 |
commit | bf2666331d84fff400d75c63f0d8ed3a6d8fc855 (patch) | |
tree | fe2c2cfa98fc95943a7e7115c3fb6630a2a46820 /src/Text/Pandoc | |
parent | 0fdc6deb089182defba667de73692ec17448f940 (diff) | |
download | pandoc-bf2666331d84fff400d75c63f0d8ed3a6d8fc855.tar.gz |
MediaWiki reader: Support skipped level in lists.
For example:
# one
# two
### skip!
### skip
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/MediaWiki.hs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index 5774baac2..cb5782f0b 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -30,7 +30,6 @@ Conversion of mediawiki text to 'Pandoc' document. -} {- TODO: -_ correctly handle skipped level in list, e.g. # to ### _ tests for lists _ support HTML lists _ support list style attributes and start values in ol lists, also @@ -199,10 +198,27 @@ listStartChar :: MWParser Char listStartChar = oneOf "*#;:" anyListStart :: MWParser () -anyListStart = listStart '*' <|> listStart '#' <|> listStart ';' +anyListStart = skipMany1 (char '*') + <|> skipMany1 (char '#') + <|> (() <$ char ';') listItem :: Char -> MWParser Blocks listItem c = try $ do + extras <- many (try $ char c <* lookAhead listStartChar) + if null extras + then listItem' c + else do + first <- manyTill anyChar newline + rest <- many (try $ string extras *> manyTill anyChar newline) + contents <- parseFromString (many1 $ listItem' c) + (unlines (first : rest)) + case c of + '*' -> return $ B.bulletList contents + '#' -> return $ B.orderedList contents + _ -> mzero + +listItem' :: Char -> MWParser Blocks +listItem' c = try $ do listStart c first <- manyTill anyChar newline rest <- many (try $ char c *> lookAhead listStartChar *> |