From 4e1a45467cb404434880cd796ea62031deb0995b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 13 Sep 2012 11:25:55 -0700 Subject: MediaWiki reader: Parse templates etc. as raw mediawiki. They can be postprocessed with a pandoc script. --- src/Text/Pandoc/Readers/MediaWiki.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index 5e742470c..3c44650c2 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -37,10 +37,8 @@ _ support internal links http://www.mediawiki.org/wiki/Help:Links _ support external links (partially implemented) _ support images http://www.mediawiki.org/wiki/Help:Images _ support tables http://www.mediawiki.org/wiki/Help:Tables -_ raw mediawiki: - _ templates or anything in {{}} (can be postprocessed) - _ category links _ gallery tag? +_ tests for templates (should be -> raw mediawiki) -} module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where @@ -75,7 +73,7 @@ type MWParser = Parser [Char] ParserState -- specialChars :: [Char] -specialChars = "'[]<=&*" +specialChars = "'[]<=&*{}" spaceChars :: [Char] spaceChars = " \n\t" @@ -132,11 +130,19 @@ block = mempty <$ skipMany1 blankline <|> blockTag <|> pTag <|> blockHtml + <|> rawMediaWiki <|> para para :: MWParser Blocks para = B.para . trimInlines . mconcat <$> many1 inline +rawMediaWiki :: MWParser Blocks +rawMediaWiki = B.rawBlock "mediawiki" <$> doublebrackets + where doublebrackets = try $ do + string "{{" + contents <- manyTill anyChar (try $ string "}}") + return $ "{{" ++ contents ++ "}}" + blockTag :: MWParser Blocks blockTag = do (TagOpen t attrs, raw) <- htmlTag (\x -> isBlockTag' x && isTagOpen x) -- cgit v1.2.3