aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-09-15 01:47:57 -0400
committerJohn MacFarlane <jgm@berkeley.edu>2012-09-15 01:47:57 -0400
commitbc5fe70d155e1d91761da6d88662b1bb3d1d3aca (patch)
tree1f90e45f782a561e557eb4007c5c3f7b3e1f8985 /src
parenta2391b0395479e46ef6eaaea087c9f2ca7435ae2 (diff)
downloadpandoc-bc5fe70d155e1d91761da6d88662b1bb3d1d3aca.tar.gz
MediaWiki reader: Skip inline templates, handle <source>.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/MediaWiki.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs
index e8952f9af..db5252a29 100644
--- a/src/Text/Pandoc/Readers/MediaWiki.hs
+++ b/src/Text/Pandoc/Readers/MediaWiki.hs
@@ -31,6 +31,8 @@ Conversion of mediawiki text to 'Pandoc' document.
{-
TODO:
_ tables - cell alignment and width
+_ wikipedia {{cite}} tags
+_ <references /> {{Reflist}}
_ calculate cell widths when not given??? see html? latex? reader
_ support tables http://www.mediawiki.org/wiki/Help:Tables
- footnotes?
@@ -98,7 +100,7 @@ sym :: String -> MWParser ()
sym s = () <$ try (string s)
newBlockTags :: [String]
-newBlockTags = ["haskell","syntaxhighlight","gallery"]
+newBlockTags = ["haskell","syntaxhighlight","source","gallery"]
isBlockTag' :: Tag String -> Bool
isBlockTag' tag@(TagOpen t _) = isBlockTag tag || t `elem` newBlockTags
@@ -248,7 +250,8 @@ blockTag = do
case tag of
TagOpen "blockquote" _ -> B.blockQuote <$> blocksInTags "blockquote"
TagOpen "pre" _ -> B.codeBlock . trimCode <$> charsInTags "pre"
- TagOpen "syntaxhighlight" attrs -> syntaxhighlight attrs
+ TagOpen "syntaxhighlight" attrs -> syntaxhighlight "syntaxhighlight" attrs
+ TagOpen "source" attrs -> syntaxhighlight "source" attrs
TagOpen "haskell" _ -> B.codeBlockWith ("",["haskell"],[]) . trimCode <$>
charsInTags "haskell"
TagOpen "gallery" _ -> blocksInTags "gallery"
@@ -260,14 +263,14 @@ trimCode :: String -> String
trimCode ('\n':xs) = stripTrailingNewlines xs
trimCode xs = stripTrailingNewlines xs
-syntaxhighlight :: [Attribute String] -> MWParser Blocks
-syntaxhighlight attrs = try $ do
+syntaxhighlight :: String -> [Attribute String] -> MWParser Blocks
+syntaxhighlight tag attrs = try $ do
let mblang = lookup "lang" attrs
let mbstart = lookup "start" attrs
let mbline = lookup "line" attrs
let classes = maybe [] (:[]) mblang ++ maybe [] (const ["numberLines"]) mbline
let kvs = maybe [] (\x -> [("startFrom",x)]) mbstart
- contents <- charsInTags "syntaxhighlight"
+ contents <- charsInTags tag
return $ B.codeBlockWith ("",classes,kvs) $ trimCode contents
hrule :: MWParser Blocks
@@ -400,6 +403,7 @@ inline = whitespace
<|> B.singleton <$> charRef
<|> inlineHtml
<|> variable
+ <|> (mempty <$ template)
<|> special
str :: MWParser Inlines
@@ -450,6 +454,7 @@ endline = () <$ try (newline <*
notFollowedBy' hrule <*
notFollowedBy tableStart <*
notFollowedBy' template <*
+ notFollowedBy' (htmlTag isBlockTag') <*
notFollowedBy anyListStart)
image :: MWParser Inlines