From bb6fcf1dac79943c84dacb4a27ee163911b03bff Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 12 Sep 2012 19:05:15 -0700 Subject: MediaWiki reader: Support `` tag. --- src/Text/Pandoc/Readers/MediaWiki.hs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index 7a22d21d4..97747ecee 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -36,9 +36,6 @@ _ support list style attributes and start values in ol lists, also value attribute on li _ support preformatted text (lines starting with space) _ support preformatted text blocks -_ code highlighting: http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi (alternativel, ) - if 'line' attribute present, number lines - if 'start' present, set starting line number _ support internal links http://www.mediawiki.org/wiki/Help:Links _ support external links _ support automatic linkification of URLs @@ -137,6 +134,7 @@ block = header <|> definitionList <|> blockquote <|> codeblock + <|> syntaxhighlight <|> haskell <|> mempty <$ skipMany1 blankline <|> mempty <$ try (spaces *> htmlComment) @@ -167,6 +165,18 @@ trimCode :: String -> String trimCode ('\n':xs) = stripTrailingNewlines xs trimCode xs = stripTrailingNewlines xs +syntaxhighlight :: MWParser Blocks +syntaxhighlight = try $ do + (tag@(TagOpen _ attrs), _) <- lookAhead + $ htmlTag (~== TagOpen "syntaxhighlight" []) + 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" + return $ B.codeBlockWith ("",classes,kvs) contents + haskell :: MWParser Blocks haskell = B.codeBlockWith ("",["haskell"],[]) . trimCode <$> charsInTags "haskell" -- cgit v1.2.3