@@ -33,7 +33,7 @@ module Text.Pandoc.Writers.ConTeXt ( writeConTeXt ) where
3333import Control.Monad.State.Strict
3434import Data.Char (ord)
3535import Data.List (intercalate, intersperse)
36−import Data.Maybe (catMaybes)
36+import Data.Maybe (mapMaybe)
3737import Data.Text (Text)
3838import Network.URI (unEscapeString)
3939import Text.Pandoc.BCP47
@@ -82,8 +82,7 @@ pandocToConTeXt options (Pandoc meta blocks) = do
8282 meta
8383 body <- mapM (elementToConTeXt options) $ hierarchicalize blocks
8484 let main = (render' . vcat) body
85− let layoutFromMargins = intercalate [','] $ catMaybes $
86− map (\(x,y) ->
85+ let layoutFromMargins = intercalate [','] $ mapMaybe (\(x,y) ->
8786 ((x ++ "=") ++) <$> getField y metadata)
8887 [("leftmargin","margin-left")
8988 ,("rightmargin","margin-right")
@@ -107,8 +106,7 @@ pandocToConTeXt options (Pandoc meta blocks) = do
107106 $ (case getField "papersize" metadata of
108107 Just ("a4" :: String) -> resetField "papersize"
109108 ("A4" :: String)
110− _ -> id)
111− $ metadata
109+ _ -> id) metadata
112110 let context' = defField "context-dir" (toContextDir
113111 $ getField "dir" context) context
114112 case writerTemplate options of
@@ -150,7 +148,7 @@ stringToConTeXt opts = concatMap (escapeCharForConTeXt opts)
150148toLabel :: String -> String
151149toLabel z = concatMap go z
152150 where go x
153− | elem x ("\\#[]\",{}%()|=" :: String) = "ux" ++ printf "%x" (ord x)
151+ | x `elem` ("\\#[]\",{}%()|=" :: String) = "ux" ++ printf "%x" (ord x)
154152 | otherwise = [x]
155153
156154-- | Convert Elements to ConTeXt
@@ -206,7 +204,7 @@ blockToConTeXt (Div (ident,_,kvs) bs) = do
206204 <> text lng <> "]" $$ txt $$ "\\stop"
207205 Nothing -> txt
208206 wrapBlank txt = blankline <> txt <> blankline
209− fmap (wrapBlank . wrapLang . wrapDir . wrapRef) $ blockListToConTeXt bs
207+ (wrapBlank . wrapLang . wrapDir . wrapRef) <$> blockListToConTeXt bs
210208blockToConTeXt (BulletList lst) = do
211209 contents <- mapM listItemToConTeXt lst
212210 return $ ("\\startitemize" <> if isTightList lst
@@ -261,7 +259,7 @@ blockToConTeXt (Table caption aligns widths heads rows) = do
261259 if colWidth == 0
262260 then "|"
263261 else ("p(" ++ printf "%.2f" colWidth ++ "\\textwidth)|")
264− let colDescriptors = "|" ++ (concat $
262+ let colDescriptors = "|" ++ concat (
265263 zipWith colDescriptor widths aligns)
266264 headers <- if all null heads
267265 then return empty
@@ -279,11 +277,11 @@ blockToConTeXt (Table caption aligns widths heads rows) = do
279277tableRowToConTeXt :: PandocMonad m => [[Block]] -> WM m Doc
280278tableRowToConTeXt cols = do
281279 cols' <- mapM blockListToConTeXt cols
282− return $ (vcat (map ("\\NC " <>) cols')) $$ "\\NC\\AR"
280+ return $ vcat (map ("\\NC " <>) cols') $$ "\\NC\\AR"
283281
284282listItemToConTeXt :: PandocMonad m => [Block] -> WM m Doc
285283listItemToConTeXt list = blockListToConTeXt list >>=
286− return . ("\\item" $$) . (nest 2)
284+ return . ("\\item" $$) . nest 2
287285
288286defListItemToConTeXt :: PandocMonad m => ([Inline], [[Block]]) -> WM m Doc
289287defListItemToConTeXt (term, defs) = do
@@ -358,7 +356,7 @@ inlineToConTeXt (RawInline "tex" str) = return $ text str
358356inlineToConTeXt il@(RawInline _ _) = do
359357 report $ InlineNotRendered il
360358 return empty
361−inlineToConTeXt (LineBreak) = return $ text "\\crlf" <> cr
359+inlineToConTeXt LineBreak = return $ text "\\crlf" <> cr
362360inlineToConTeXt SoftBreak = do
363361 wrapText <- gets (writerWrapText . stOptions)
364362 return $ case wrapText of
@@ -367,7 +365,7 @@ inlineToConTeXt SoftBreak = do
367365 WrapPreserve -> cr
368366inlineToConTeXt Space = return space
369367-- Handle HTML-like internal document references to sections
370−inlineToConTeXt (Link _ txt (('#' : ref), _)) = do
368+inlineToConTeXt (Link _ txt ('#' : ref, _)) = do
371369 opts <- gets stOptions
372370 contents <- inlineListToConTeXt txt
373371 let ref' = toLabel $ stringToConTeXt opts ref
@@ -393,7 +391,7 @@ inlineToConTeXt (Link _ txt (src, _)) = do
393391inlineToConTeXt (Image attr@(_,cls,_) _ (src, _)) = do
394392 opts <- gets stOptions
395393 let showDim dir = let d = text (show dir) <> "="
396− in case (dimension dir attr) of
394+ in case dimension dir attr of
397395 Just (Pixel a) ->
398396 [d <> text (showInInch opts (Pixel a)) <> "in"]
399397 Just (Percent a) ->
@@ -432,7 +430,7 @@ inlineToConTeXt (Span (_,_,kvs) ils) = do
432430 Just lng -> "\\start\\language[" <> text lng
433431 <> "]" <> txt <> "\\stop "
434432 Nothing -> txt
435− fmap (wrapLang . wrapDir) $ inlineListToConTeXt ils
433+ (wrapLang . wrapDir) <$> inlineListToConTeXt ils
436434
437435-- | Craft the section header, inserting the section reference, if supplied.
438436sectionHeader :: PandocMonad m