@@ -44,7 +44,7 @@ import Data.Char (isDigit, isSpace)
44import qualified Data.Foldable as F
44import qualified Data.Foldable as F
45import Data.List (intercalate, intersperse, isPrefixOf)
45import Data.List (intercalate, intersperse, isPrefixOf)
46import qualified Data.Map as M
46import qualified Data.Map as M
47−import Data.Maybe (fromMaybe)
47+import Data.Maybe (fromMaybe, maybeToList)
48import Data.Monoid ((<>))
48import Data.Monoid ((<>))
49import Data.Sequence (ViewL (..), viewl, (<|))
49import Data.Sequence (ViewL (..), viewl, (<|))
50import qualified Data.Set as Set
50import qualified Data.Set as Set
@@ -239,7 +239,7 @@ table = do
239 Nothing -> 1.0
239 Nothing -> 1.0
240 caption <- option mempty tableCaption
240 caption <- option mempty tableCaption
241 optional rowsep
241 optional rowsep
242− hasheader <- option False $ True <$ (lookAhead (skipSpaces *> char '!'))
242+ hasheader <- option False $ True <$ lookAhead (skipSpaces *> char '!')
243 (cellspecs',hdr) <- unzip <$> tableRow
243 (cellspecs',hdr) <- unzip <$> tableRow
244 let widths = map ((tableWidth *) . snd) cellspecs'
244 let widths = map ((tableWidth *) . snd) cellspecs'
245 let restwidth = tableWidth - sum widths
245 let restwidth = tableWidth - sum widths
@@ -358,7 +358,7 @@ syntaxhighlight tag attrs = try $ do
358 let mblang = lookup "lang" attrs
358 let mblang = lookup "lang" attrs
359 let mbstart = lookup "start" attrs
359 let mbstart = lookup "start" attrs
360 let mbline = lookup "line" attrs
360 let mbline = lookup "line" attrs
361− let classes = maybe [] (:[]) mblang ++ maybe [] (const ["numberLines"]) mbline
361+ let classes = maybeToList mblang ++ maybe [] (const ["numberLines"]) mbline
362 let kvs = maybe [] (\x -> [("startFrom",x)]) mbstart
362 let kvs = maybe [] (\x -> [("startFrom",x)]) mbstart
363 contents <- charsInTags tag
363 contents <- charsInTags tag
364 return $ B.codeBlockWith ("",classes,kvs) $ trimCode contents
364 return $ B.codeBlockWith ("",classes,kvs) $ trimCode contents
@@ -373,7 +373,7 @@ preformatted :: PandocMonad m => MWParser m Blocks
373preformatted = try $ do
373preformatted = try $ do
374 guardColumnOne
374 guardColumnOne
376− let endline' = B.linebreak <$ (try $ newline <* char ' ')
376+ let endline' = B.linebreak <$ try (newline <* char ' ')
377 let whitespace' = B.str <$> many1 ('\160' <$ spaceChar)
377 let whitespace' = B.str <$> many1 ('\160' <$ spaceChar)
378 let spToNbsp ' ' = '\160'
378 let spToNbsp ' ' = '\160'
379 spToNbsp x = x
379 spToNbsp x = x
@@ -382,7 +382,7 @@ preformatted = try $ do
382 (htmlTag (~== TagOpen "nowiki" []) *>
382 (htmlTag (~== TagOpen "nowiki" []) *>
383 manyTill anyChar (htmlTag (~== TagClose "nowiki")))
383 manyTill anyChar (htmlTag (~== TagClose "nowiki")))
384 let inline' = whitespace' <|> endline' <|> nowiki'
384 let inline' = whitespace' <|> endline' <|> nowiki'
385− <|> (try $ notFollowedBy newline *> inline)
385+ <|> try (notFollowedBy newline *> inline)
386 contents <- mconcat <$> many1 inline'
386 contents <- mconcat <$> many1 inline'
387 let spacesStr (Str xs) = all isSpace xs
387 let spacesStr (Str xs) = all isSpace xs
388 spacesStr _ = False
388 spacesStr _ = False
@@ -397,7 +397,7 @@ encode = B.fromList . normalizeCode . B.toList . walk strToCode
397 strToCode x = x
397 strToCode x = x
398 normalizeCode [] = []
398 normalizeCode [] = []
399 normalizeCode (Code a1 x : Code a2 y : zs) | a1 == a2 =
399 normalizeCode (Code a1 x : Code a2 y : zs) | a1 == a2 =
400− normalizeCode $ (Code a1 (x ++ y)) : zs
400+ normalizeCode $ Code a1 (x ++ y) : zs
401 normalizeCode (x:xs) = x : normalizeCode xs
401 normalizeCode (x:xs) = x : normalizeCode xs
403header :: PandocMonad m => MWParser m Blocks
403header :: PandocMonad m => MWParser m Blocks
@@ -510,8 +510,8 @@ listItem' c = try $ do
510firstParaToPlain :: Blocks -> Blocks
510firstParaToPlain :: Blocks -> Blocks
511firstParaToPlain contents =
511firstParaToPlain contents =
512 case viewl (B.unMany contents) of
512 case viewl (B.unMany contents) of
513− (Para xs) :< ys -> B.Many $ (Plain xs) <| ys
513+ Para xs :< ys -> B.Many $ Plain xs <| ys
514− _ -> contents
514+ _ -> contents
517-- inline parsers
517-- inline parsers
@@ -612,13 +612,13 @@ image = try $ do
612 choice imageIdentifiers
612 choice imageIdentifiers
613 fname <- addUnderscores <$> many1 (noneOf "|]")
613 fname <- addUnderscores <$> many1 (noneOf "|]")
614 _ <- many imageOption
614 _ <- many imageOption
615− dims <- try (char '|' *> (sepBy (many digit) (char 'x')) <* string "px")
615+ dims <- try (char '|' *> sepBy (many digit) (char 'x') <* string "px")
616 <|> return []
616 <|> return []
617 _ <- many imageOption
617 _ <- many imageOption
618 let kvs = case dims of
618 let kvs = case dims of
619− w:[] -> [("width", w)]
619+ [w] -> [("width", w)]
620− w:(h:[]) -> [("width", w), ("height", h)]
620+ [w, h] -> [("width", w), ("height", h)]
622 let attr = ("", [], kvs)
622 let attr = ("", [], kvs)
623 caption <- (B.str fname <$ sym "]]")
623 caption <- (B.str fname <$ sym "]]")
624 <|> try (char '|' *> (mconcat <$> manyTill inline (sym "]]")))
624 <|> try (char '|' *> (mconcat <$> manyTill inline (sym "]]")))
@@ -651,7 +651,7 @@ internalLink = try $ do
651 ( (mconcat <$> many1 (notFollowedBy (char ']') *> inline))
651 ( (mconcat <$> many1 (notFollowedBy (char ']') *> inline))
652 -- the "pipe trick"
652 -- the "pipe trick"
653 -- [[Help:Contents|] -> "Contents"
653 -- [[Help:Contents|] -> "Contents"
654− <|> (return $ B.text $ drop 1 $ dropWhile (/=':') pagename) )
654+ <|> return (B.text $ drop 1 $ dropWhile (/=':') pagename) )
656 linktrail <- B.text <$> many letter
656 linktrail <- B.text <$> many letter
657 let link = B.link (addUnderscores pagename) "wikilink" (label <> linktrail)
657 let link = B.link (addUnderscores pagename) "wikilink" (label <> linktrail)