@@ -91,14 +91,13 @@ import Text.Pandoc.Parsing (F, ParserState, ParserT, blanklines, emailAddress,
9191 registerHeader, runF, spaceChar, stateMeta',
9292 stateOptions, uri)
9393import Text.Pandoc.Shared (crFilter, splitBy, stringify, stripFirstAndLast)
94−import Text.Parsec.Char (alphaNum, anyChar, char, newline, noneOf, spaces,
95− string)
96−import Text.Parsec.Char (oneOf, space)
97−import Text.Parsec.Combinator (choice, count, eof, many1, manyTill,
98− notFollowedBy, option, skipMany1)
99−import Text.Parsec.Combinator (between, lookAhead)
100−import Text.Parsec.Prim (getState, many, try, updateState)
101−import Text.Parsec.Prim ((<|>))
94+import Text.Parsec.Char
95+ (alphaNum, anyChar, char, newline, noneOf, spaces, string, oneOf,
96+ space)
97+import Text.Parsec.Combinator
98+ (choice, count, eof, many1, manyTill, notFollowedBy, option,
99+ skipMany1, between, lookAhead)
100+import Text.Parsec.Prim (getState, many, try, updateState, (<|>))
102101
103102readVimwiki :: PandocMonad m => ReaderOptions -> Text -> m Pandoc
104103readVimwiki opts s = do
@@ -161,9 +160,9 @@ header = try $ do
161160 let lev = length eqs
162161 guard $ lev <= 6
163162 contents <- trimInlines . mconcat <$> manyTill inline (try $ spaceChar
164− >> (string eqs) >> many spaceChar >> newline)
163+ >> string eqs >> many spaceChar >> newline)
165164 attr <- registerHeader (makeId contents,
166− (if sp == "" then [] else ["justcenter"]), []) contents
165+ if sp == "" then [] else ["justcenter"], []) contents
167166 return $ B.headerWith attr lev contents
168167
169168para :: PandocMonad m => VwParser m Blocks
@@ -191,22 +190,22 @@ blockQuote = try $ do
191190
192191definitionList :: PandocMonad m => VwParser m Blocks
193192definitionList = try $
194− B.definitionList <$> (many1 (dlItemWithDT <|> dlItemWithoutDT))
193+ B.definitionList <$> many1 (dlItemWithDT <|> dlItemWithoutDT)
195194
196195dlItemWithDT :: PandocMonad m => VwParser m (Inlines, [Blocks])
197196dlItemWithDT = do
198197 dt <- definitionTerm
199198 dds <- many definitionDef
200− return $ (dt, dds)
199+ return (dt, dds)
201200
202201dlItemWithoutDT :: PandocMonad m => VwParser m (Inlines, [Blocks])
203202dlItemWithoutDT = do
204203 dds <- many1 definitionDef
205− return $ (mempty, dds)
204+ return (mempty, dds)
206205
207206definitionDef :: PandocMonad m => VwParser m Blocks
208207definitionDef = try $
209− (notFollowedBy definitionTerm) >> many spaceChar
208+ notFollowedBy definitionTerm >> many spaceChar
210209 >> (definitionDef1 <|> definitionDef2)
211210
212211definitionDef1 :: PandocMonad m => VwParser m Blocks
@@ -220,16 +219,16 @@ definitionDef2 = try $ B.plain <$>
220219definitionTerm :: PandocMonad m => VwParser m Inlines
221220definitionTerm = try $ do
222221 x <- definitionTerm1 <|> definitionTerm2
223− guard $ (stringify x /= "")
222+ guard (stringify x /= "")
224223 return x
225224
226225definitionTerm1 :: PandocMonad m => VwParser m Inlines
227226definitionTerm1 = try $
228− trimInlines . mconcat <$> manyTill inline' (try $ defMarkerE)
227+ trimInlines . mconcat <$> manyTill inline' (try defMarkerE)
229228
230229definitionTerm2 :: PandocMonad m => VwParser m Inlines
231230definitionTerm2 = try $ trimInlines . mconcat <$> manyTill inline'
232− (try $ lookAhead $ (defMarkerM >> notFollowedBy hasDefMarkerM))
231+ (try $lookAhead (defMarkerM >> notFollowedBy hasDefMarkerM))
233232
234233defMarkerM :: PandocMonad m => VwParser m Char
235234defMarkerM = string "::" >> spaceChar
@@ -247,14 +246,14 @@ preformatted = try $ do
247246 lookAhead newline
248247 contents <- manyTill anyChar (try (char '\n' >> many spaceChar >> string "}}}"
249248 >> many spaceChar >> newline))
250− if (not $ contents == "") && (head contents == '\n')
249+ if not (contents == "") && (head contents == '\n')
251250 then return $ B.codeBlockWith (makeAttr attrText) (tail contents)
252251 else return $ B.codeBlockWith (makeAttr attrText) contents
253252
254253makeAttr :: String -> Attr
255254makeAttr s =
256255 let xs = splitBy (`elem` " \t") s in
257− ("", [], catMaybes $ map nameValue xs)
256+ ("", [], mapMaybe nameValue xs)
258257
259258nameValue :: String -> Maybe (String, String)
260259nameValue s =
@@ -262,7 +261,7 @@ nameValue s =
262261 if length t /= 2
263262 then Nothing
264263 else let (a, b) = (head t, last t) in
265− if ((length b) < 2) || ((head b, last b) /= ('"', '"'))
264+ if (length b < 2) || ((head b, last b) /= ('"', '"'))
266265 then Nothing
267266 else Just (a, stripFirstAndLast b)
268267
@@ -317,12 +316,12 @@ mixedList' prevInd = do
317316 if lowInd >= curInd
318317 then do
319318 (sameIndList, endInd) <- (mixedList' lowInd)
320− let curList = (combineList curLine subList) ++ sameIndList
319+ let curList = combineList curLine subList ++ sameIndList
321320 if curInd > prevInd
322321 then return ([listBuilder curList], endInd)
323322 else return (curList, endInd)
324323 else do
325− let (curList, endInd) = ((combineList curLine subList),
324+ let (curList, endInd) = (combineList curLine subList,
326325 lowInd)
327326 if curInd > prevInd
328327 then return ([listBuilder curList], endInd)
@@ -335,7 +334,7 @@ plainInlineML' w = do
335334 return $ B.plain $ trimInlines $ mconcat $ w:xs
336335
337336plainInlineML :: PandocMonad m => VwParser m Blocks
338−plainInlineML = (notFollowedBy listStart) >> spaceChar >> plainInlineML' mempty
337+plainInlineML = notFollowedBy listStart >> spaceChar >> plainInlineML' mempty
339338
340339
341340listItemContent :: PandocMonad m => VwParser m Blocks
@@ -372,9 +371,9 @@ makeListMarkerSpan x =
372371
373372combineList :: Blocks -> [Blocks] -> [Blocks]
374373combineList x [y] = case toList y of
375− [BulletList z] -> [fromList $ (toList x)
374+ [BulletList z] -> [fromList $ toList x
376375 ++ [BulletList z]]
377− [OrderedList attr z] -> [fromList $ (toList x)
376+ [OrderedList attr z] -> [fromList $ toList x
378377 ++ [OrderedList attr z]]
379378 _ -> x:[y]
380379combineList x xs = x:xs
@@ -391,7 +390,7 @@ bulletListMarkers = "ul" <$ (char '*' <|> char '-')
391390
392391orderedListMarkers :: PandocMonad m => VwParser m String
393392orderedListMarkers =
394− ("ol" <$ (choice $ (orderedListMarker Decimal Period):(($OneParen)
393+ ("ol" <$choice ((orderedListMarker Decimal Period):(($OneParen)
395394 <$> orderedListMarker
396395 <$> [Decimal, LowerRoman, UpperRoman, LowerAlpha, UpperAlpha])))
397396 <|> ("ol" <$ char '#')
@@ -418,11 +417,11 @@ table1 = try $ do
418417table2 :: PandocMonad m => VwParser m ([Blocks], [[Blocks]])
419418table2 = try $ do
420419 trs <- many1 tableRow
421− return (take (length $ head trs) $ repeat mempty, trs)
420+ return (replicate (length $ head trs) mempty, trs)
422421
423422tableHeaderSeparator :: PandocMonad m => VwParser m ()
424423tableHeaderSeparator = try $ do
425− many spaceChar >> char '|' >> many1 ((many1 $ char '-') >> char '|')
424+ many spaceChar >> char '|' >> many1 (many1 (char '-') >> char '|')
426425 >> many spaceChar >> newline
427426 return ()
428427
@@ -438,16 +437,16 @@ tableRow = try $ do
438437
439438tableCell :: PandocMonad m => VwParser m Blocks
440439tableCell = try $
441− B.plain <$> trimInlines . mconcat <$> (manyTill inline' (char '|'))
440+ B.plain . trimInlines . mconcat <$> (manyTill inline' (char '|'))
442441
443442placeholder :: PandocMonad m => VwParser m ()
444443placeholder = try $
445− (choice (ph <$> ["title", "date"])) <|> noHtmlPh <|> templatePh
444+ choice (ph <$> ["title", "date"]) <|> noHtmlPh <|> templatePh
446445
447446ph :: PandocMonad m => String -> VwParser m ()
448447ph s = try $ do
449− many spaceChar >> (string $ '%':s) >> spaceChar
450− contents <- (trimInlines . mconcat <$> (manyTill inline (lookAhead newline)))
448+ many spaceChar >>string ('%':s) >> spaceChar
449+ contents <- trimInlines . mconcat <$> (manyTill inline (lookAhead newline))
451450 --use lookAhead because of placeholder in the whitespace parser
452451 let meta' = return $ B.setMeta s contents nullMeta :: F Meta
453452 updateState $ \st -> st { stateMeta' = stateMeta' st <> meta' }
@@ -455,17 +454,17 @@ ph s = try $ do
455454noHtmlPh :: PandocMonad m => VwParser m ()
456455noHtmlPh = try $
457456 () <$ (many spaceChar >> string "%nohtml" >> many spaceChar
458− >> (lookAhead newline))
457+ >> lookAhead newline)
459458
460459templatePh :: PandocMonad m => VwParser m ()
461460templatePh = try $
462− () <$ (many spaceChar >> string "%template" >> (many $ noneOf "\n")
463− >> (lookAhead newline))
461+ () <$ (many spaceChar >> string "%template" >>many (noneOf "\n")
462+ >> lookAhead newline)
464463
465464-- inline parser
466465
467466inline :: PandocMonad m => VwParser m Inlines
468−inline = choice $ (whitespace endlineP):inlineList
467+inline = choice $ whitespace endlineP:inlineList
469468
470469inlineList :: PandocMonad m => [VwParser m Inlines]
471470inlineList = [ bareURL
@@ -490,18 +489,18 @@ inline' = choice $ whitespace':inlineList
490489
491490-- inline parser for blockquotes
492491inlineBQ :: PandocMonad m => VwParser m Inlines
493−inlineBQ = choice $ (whitespace endlineBQ):inlineList
492+inlineBQ = choice $ whitespace endlineBQ:inlineList
494493
495494-- inline parser for mixedlists
496495inlineML :: PandocMonad m => VwParser m Inlines
497−inlineML = choice $ (whitespace endlineML):inlineList
496+inlineML = choice $ whitespace endlineML:inlineList
498497
499498str :: PandocMonad m => VwParser m Inlines
500−str = B.str <$> (many1 $ noneOf $ spaceChars ++ specialChars)
499+str = B.str <$>many1 (noneOf $ spaceChars ++ specialChars)
501500
502501whitespace :: PandocMonad m => VwParser m () -> VwParser m Inlines
503502whitespace endline = B.space <$ (skipMany1 spaceChar <|>
504− (try (newline >> (comment <|> placeholder))))
503+ try (newline >> (comment <|> placeholder)))
505504 <|> B.softbreak <$ endline
506505
507506whitespace' :: PandocMonad m => VwParser m Inlines
@@ -518,31 +517,31 @@ bareURL = try $ do
518517strong :: PandocMonad m => VwParser m Inlines
519518strong = try $ do
520519 s <- lookAhead $ between (char '*') (char '*') (many1 $ noneOf "*")
521− guard $ (not $ (head s) `elem` spaceChars)
522− && (not $ (last s) `elem` spaceChars)
520+ guard $ not ((head s) `elem` spaceChars)
521+ &¬ ((last s) `elem` spaceChars)
523522 char '*'
524− contents <- mconcat <$> (manyTill inline' $ char '*'
523+ contents <- mconcat <$>manyTill inline' (char '*'
525524 >> notFollowedBy alphaNum)
526− return $ (B.spanWith ((makeId contents), [], []) mempty)
527− <> (B.strong contents)
525+ return $ B.spanWith ((makeId contents), [], []) mempty
526+ <> B.strong contents
528527
529528makeId :: Inlines -> String
530−makeId i = concat (stringify <$> (toList i))
529+makeId i = concat (stringify <$> toList i)
531530
532531emph :: PandocMonad m => VwParser m Inlines
533532emph = try $ do
534533 s <- lookAhead $ between (char '_') (char '_') (many1 $ noneOf "_")
535− guard $ (not $ (head s) `elem` spaceChars)
536− && (not $ (last s) `elem` spaceChars)
534+ guard $ not ((head s) `elem` spaceChars)
535+ &¬ ((last s) `elem` spaceChars)
537536 char '_'
538− contents <- mconcat <$> (manyTill inline' $ char '_'
537+ contents <- mconcat <$>manyTill inline' (char '_'
539538 >> notFollowedBy alphaNum)
540539 return $ B.emph contents
541540
542541strikeout :: PandocMonad m => VwParser m Inlines
543542strikeout = try $ do
544543 string "~~"
545− contents <- mconcat <$> (many1Till inline' $ string $ "~~")
544+ contents <- mconcat <$>many1Till inline' (string $ "~~")
546545 return $ B.strikeout contents
547546
548547code :: PandocMonad m => VwParser m Inlines
@@ -553,11 +552,11 @@ code = try $ do
553552
554553superscript :: PandocMonad m => VwParser m Inlines
555554superscript = try $
556− B.superscript <$> mconcat <$> (char '^' >> many1Till inline' (char '^'))
555+ B.superscript . mconcat <$> (char '^' >> many1Till inline' (char '^'))
557556
558557subscript :: PandocMonad m => VwParser m Inlines
559558subscript = try $
560− B.subscript <$> mconcat <$> (string ",,"
559+ B.subscript . mconcat <$> (string ",,"
561560 >> many1Till inline' (try $ string ",,"))
562561
563562link :: PandocMonad m => VwParser m Inlines
@@ -587,29 +586,29 @@ images k
587586 return $ B.image (procImgurl imgurl) "" (B.str "")
588587 | k == 1 = do
589588 imgurl <- manyTill anyChar (char '|')
590− alt <- mconcat <$> (manyTill inline $ (try $ string "}}"))
589+ alt <- mconcat <$> (manyTill inline (try $ string "}}"))
591590 return $ B.image (procImgurl imgurl) "" alt
592591 | k == 2 = do
593592 imgurl <- manyTill anyChar (char '|')
594− alt <- mconcat <$> (manyTill inline $ char '|')
593+ alt <- mconcat <$>manyTill inline (char '|')
595594 attrText <- manyTill anyChar (try $ string "}}")
596595 return $ B.imageWith (makeAttr attrText) (procImgurl imgurl) "" alt
597596 | otherwise = do
598597 imgurl <- manyTill anyChar (char '|')
599− alt <- mconcat <$> (manyTill inline $ char '|')
598+ alt <- mconcat <$>manyTill inline (char '|')
600599 attrText <- manyTill anyChar (char '|')
601600 manyTill anyChar (try $ string "}}")
602601 return $ B.imageWith (makeAttr attrText) (procImgurl imgurl) "" alt
603602
604603procLink' :: String -> String
605604procLink' s
606− | ((take 6 s) == "local:") = "file" ++ (drop 5 s)
607− | ((take 6 s) == "diary:") = "diary/" ++ (drop 6 s) ++ ".html"
605+ | (take 6 s) == "local:" = "file" ++ drop 5 s
606+ | (take 6 s) == "diary:" = "diary/" ++ drop 6 s ++ ".html"
608607 | or ((`isPrefixOf` s) <$> [ "http:", "https:", "ftp:", "file:", "mailto:",
609608 "news:", "telnet:" ])
610609 = s
611610 | s == "" = ""
612− | (last s) == '/' = s
611+ | last s == '/' = s
613612 | otherwise = s ++ ".html"
614613
615614procLink :: String -> String
@@ -617,7 +616,7 @@ procLink s = procLink' x ++ y
617616 where (x, y) = break (=='#') s
618617
619618procImgurl :: String -> String
620−procImgurl s = if ((take 6 s) == "local:") then "file" ++ (drop 5 s) else s
619+procImgurl s = if (take 6 s) == "local:" then "file" ++ drop 5 s else s
621620
622621inlineMath :: PandocMonad m => VwParser m Inlines
623622inlineMath = try $ do
@@ -628,10 +627,10 @@ inlineMath = try $ do
628627tag :: PandocMonad m => VwParser m Inlines
629628tag = try $ do
630629 char ':'
631− s <- manyTill (noneOf spaceChars) (try (char ':' >> (lookAhead space)))
630+ s <- manyTill (noneOf spaceChars) (try (char ':' >> lookAhead space))
632631 guard $ not $ "::" `isInfixOf` (":" ++ s ++ ":")
633632 let ss = splitBy (==':') s
634− return $ mconcat $ (makeTagSpan' $ head ss):(makeTagSpan <$> (tail ss))
633+ return $ mconcat $ makeTagSpan' (head ss):(makeTagSpan <$> tail ss)
635634
636635todoMark :: PandocMonad m => VwParser m Inlines
637636todoMark = try $ do
@@ -661,18 +660,18 @@ nFBTTBSB =
661660 notFollowedBy hasDefMarker
662661
663662hasDefMarker :: PandocMonad m => VwParser m ()
664−hasDefMarker = () <$ (manyTill (noneOf "\n") (string "::" >> oneOf spaceChars))
663+hasDefMarker = () <$ manyTill (noneOf "\n") (string "::" >> oneOf spaceChars)
665664
666665makeTagSpan' :: String -> Inlines
667666makeTagSpan' s = B.spanWith ('-' : s, [], []) (B.str "") <>
668667 B.spanWith (s, ["tag"], []) (B.str s)
669668
670669makeTagSpan :: String -> Inlines
671−makeTagSpan s = (B.space) <> (makeTagSpan' s)
670+makeTagSpan s = B.space <> makeTagSpan' s
672671
673672mathTagParser :: PandocMonad m => VwParser m String
674673mathTagParser = do
675− s <- try $ lookAhead (char '%' >> (manyTill (noneOf spaceChars)
676− (try $ char '%' >> many (noneOf $ '%':spaceChars) >> space)))
674+ s <- try $ lookAhead (char '%' >> manyTill (noneOf spaceChars)
675+ (try $ char '%' >> many (noneOf $ '%':spaceChars) >> space))
677676 char '%' >> string s >> char '%'
678677 return $ mathTagLaTeX s