git.iko.soy/typeable/pandoc
on master help sign in
MediaWiki reader: Parse templates etc. as raw mediawiki.

They can be postprocessed with a pandoc script.

commit4e1a45467cb404434880cd796ea62031deb0995b authorJohn MacFarlane <jgm@berkeley.edu> dateThu 13 Sep 2012, 11:25 (14 years ago) parente3abc25
1 file changed+10−4
src/Text/Pandoc/Readers/MediaWiki.hs+10−4
src/Text/Pandoc/Readers/MediaWiki.hs+10−4
@@ -37,10 +37,8 @@ _ support internal links http://www.mediawiki.org/wiki/Help:Links
3737_ support external links (partially implemented)
3838_ support images http://www.mediawiki.org/wiki/Help:Images
3939_ support tables http://www.mediawiki.org/wiki/Help:Tables
40−_ raw mediawiki:
41− _ templates or anything in {{}} (can be postprocessed)
42− _ category links
4340_ gallery tag?
41+_ tests for templates (should be -> raw mediawiki)
4442-}
4543module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where
4644
@@ -75,7 +73,7 @@ type MWParser = Parser [Char] ParserState
7573--
7674
7775specialChars :: [Char]
78−specialChars = "'[]<=&*"
76+specialChars = "'[]<=&*{}"
7977
8078spaceChars :: [Char]
8179spaceChars = " \n\t"
@@ -132,11 +130,19 @@ block = mempty <$ skipMany1 blankline
132130 <|> blockTag
133131 <|> pTag
134132 <|> blockHtml
133+ <|> rawMediaWiki
135134 <|> para
136135
137136para :: MWParser Blocks
138137para = B.para . trimInlines . mconcat <$> many1 inline
139138
139+rawMediaWiki :: MWParser Blocks
140+rawMediaWiki = B.rawBlock "mediawiki" <$> doublebrackets
141+ where doublebrackets = try $ do
142+ string "{{"
143+ contents <- manyTill anyChar (try $ string "}}")
144+ return $ "{{" ++ contents ++ "}}"
145+
140146blockTag :: MWParser Blocks
141147blockTag = do
142148 (TagOpen t attrs, raw) <- htmlTag (\x -> isBlockTag' x && isTagOpen x)