git.iko.soy/typeable/pandoc
on master help sign in
Apply linter suggestions. Add fix_spacing to lint target in Makefile.
commit4c3db9273fc8e92c2c23d4455a6ab178472be06d authorJohn MacFarlane <jgm@berkeley.edu> dateFri 7 Feb 2020, 08:32 (7 years ago) parent6cd77d4
51 files changed+247−279
Makefile+10−4 benchmark/weigh-pandoc.hs−2 src/Text/Pandoc/App.hs+1−1 src/Text/Pandoc/App/Opt.hs+2−2 src/Text/Pandoc/Lua.hs−1 src/Text/Pandoc/Lua/Marshaling/Context.hs−1 src/Text/Pandoc/Lua/Marshaling/Version.hs−1 src/Text/Pandoc/Parsing.hs+1−1 src/Text/Pandoc/Readers/CSV.hs+1−2 src/Text/Pandoc/Readers/DocBook.hs+1−2 src/Text/Pandoc/Readers/Docx/Fields.hs+2−2 src/Text/Pandoc/Readers/HTML.hs+3−3 src/Text/Pandoc/Readers/Markdown.hs+6−7 src/Text/Pandoc/Readers/Metadata.hs+6−9 src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs+2−2 src/Text/Pandoc/Readers/Odt/ContentReader.hs+1−1 src/Text/Pandoc/Readers/Odt/Generic/XMLConverter.hs+4−4 src/Text/Pandoc/Readers/Odt/StyleReader.hs+1−1 src/Text/Pandoc/Readers/RST.hs+6−8 src/Text/Pandoc/Readers/TikiWiki.hs+1−1 src/Text/Pandoc/Readers/Vimwiki.hs+1−1 src/Text/Pandoc/SelfContained.hs+1−1 src/Text/Pandoc/Shared.hs+9−9 src/Text/Pandoc/Writers/AsciiDoc.hs+1−1 src/Text/Pandoc/Writers/CommonMark.hs+6−10 src/Text/Pandoc/Writers/Docbook.hs+2−6 src/Text/Pandoc/Writers/FB2.hs+2−6 src/Text/Pandoc/Writers/HTML.hs+4−4 src/Text/Pandoc/Writers/ICML.hs+1−1 src/Text/Pandoc/Writers/LaTeX.hs+2−4 src/Text/Pandoc/Writers/Man.hs+1−2 src/Text/Pandoc/Writers/Math.hs−1 src/Text/Pandoc/Writers/MediaWiki.hs+10−6 src/Text/Pandoc/Writers/Muse.hs+1−1 src/Text/Pandoc/Writers/ODT.hs+5−7 src/Text/Pandoc/Writers/OpenDocument.hs+2−2 src/Text/Pandoc/Writers/Powerpoint/Output.hs+69−78 src/Text/Pandoc/Writers/Powerpoint/Presentation.hs+10−10 src/Text/Pandoc/Writers/RST.hs+9−7 src/Text/Pandoc/Writers/TEI.hs+2−4 src/Text/Pandoc/Writers/Texinfo.hs+2−3 src/Text/Pandoc/Writers/XWiki.hs+9−9 test/Tests/Command.hs−1 test/Tests/Readers/Docx.hs+1−1 test/Tests/Readers/HTML.hs+4−4 test/Tests/Readers/Man.hs+15−15 test/Tests/Readers/Org/Meta.hs+1−1 test/Tests/Readers/Txt2Tags.hs+3−3 test/Tests/Writers/HTML.hs+2−2 test/Tests/Writers/Markdown.hs+23−23 test/Tests/Writers/RST.hs+1−1
Makefile+10−4
@@ -1,6 +1,6 @@
11version?=$(shell grep '^[Vv]ersion:' pandoc.cabal | awk '{print $$2;}')
22pandoc=$(shell find dist -name pandoc -type f -exec ls -t {} \; | head -1)
3−SOURCEFILES?=$(shell find pandoc.hs src test -name '*.hs')
3+SOURCEFILES?=$(shell git ls-tree -r master --name-only | grep "\.hs$$")
44BRANCH?=master
55RESOLVER?=lts-13
66GHCOPTS=-fdiagnostics-color=always
@@ -45,8 +45,14 @@ weigh:
4545reformat:
4646 for f in $(SOURCEFILES); do echo $$f; stylish-haskell -i $$f ; done
4747
48−lint:
49− for f in $(SOURCEFILES); do echo $$f; hlint --verbose --refactor --refactor-options='-i -s' $$f; done
48+lint: hlint fix_spacing
49+
50+hlint:
51+ for f in $(SOURCEFILES); do echo $$f; hlint --verbose --refactor --refactor-options='-s -o -' $$f; done
52+
53+fix_spacing:
54+ # Fix trailing newlines and spaces at ends of lines
55+ for f in $(SOURCEFILES); do printf '%s\n' "`cat $$f`" | sed -e 's/ *$$//' > $$f.tmp; mv $$f.tmp $$f; done
5056
5157changes_github:
5258 pandoc --filter tools/extract-changes.hs changelog.md -t gfm --wrap=none | sed -e 's/\\#/#/g' | pbcopy
@@ -142,4 +148,4 @@ update-website:
142148clean:
143149 stack clean
144150
145−.PHONY: deps quick full haddock install clean test bench changes_github macospkg dist prof download_stats reformat lint weigh doc/lua-filters.md packages pandoc-templates trypandoc update-website debpkg macospkg winpkg checkdocs ghcid ghci
151+.PHONY: deps quick full haddock install clean test bench changes_github macospkg dist prof download_stats reformat lint weigh doc/lua-filters.md packages pandoc-templates trypandoc update-website debpkg macospkg winpkg checkdocs ghcid ghci fix_spacing hlint
benchmark/weigh-pandoc.hs−2
@@ -48,5 +48,3 @@ weighReader doc name reader = do
4848 let inp = either (error . show) id $ runPure $ writer def{ writerWrapText = WrapAuto} doc
4949 in func (unpack $ name <> " reader") reader inp
5050 _ -> return () -- no writer for reader
51−
52−
src/Text/Pandoc/App.hs+1−1
@@ -149,7 +149,7 @@ convertWithOpts opts = do
149149 let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"
150150
151151 when (pdfOutput && readerName == "latex") $
152− case (optInputFiles opts) of
152+ case optInputFiles opts of
153153 Just (inputFile:_) -> report $ UnusualConversion $ T.pack $
154154 "to convert a .tex file to PDF, you get better results by using pdflatex "
155155 <> "(or lualatex or xelatex) directly, try `pdflatex " <> inputFile
src/Text/Pandoc/App/Opt.hs+2−2
@@ -189,10 +189,10 @@ doOpt (k',v) = do
189189 parseYAML v >>= \x -> return (\o -> o{ optMetadata = optMetadata o <>
190190 contextToMeta x })
191191 "metadata-files" ->
192− (parseYAML v >>= \x ->
192+ parseYAML v >>= \x ->
193193 return (\o -> o{ optMetadataFiles =
194194 optMetadataFiles o <>
195− map unpack x }))
195+ map unpack x })
196196 "metadata-file" -> -- allow either a list or a single value
197197 (parseYAML v >>= \x -> return (\o -> o{ optMetadataFiles =
198198 optMetadataFiles o <>
src/Text/Pandoc/Lua.hs−1
@@ -23,4 +23,3 @@ import Text.Pandoc.Lua.Filter (runFilterFile)
2323import Text.Pandoc.Lua.Global (Global (..), setGlobals)
2424import Text.Pandoc.Lua.Init (LuaException (..), runLua)
2525import Text.Pandoc.Lua.Marshaling ()
26−
src/Text/Pandoc/Lua/Marshaling/Context.hs−1
@@ -29,4 +29,3 @@ instance (TemplateTarget a, Pushable a) => Pushable (Val a) where
2929 push (MapVal ctx) = Lua.push ctx
3030 push (ListVal xs) = Lua.push xs
3131 push (SimpleVal d) = Lua.push $ render Nothing d
32−
src/Text/Pandoc/Lua/Marshaling/Version.hs−1
@@ -154,4 +154,3 @@ must_be_at_least actual expected optMsg = do
154154 Lua.push (showVersion actual)
155155 Lua.call 3 1
156156 Lua.error
157−
src/Text/Pandoc/Parsing.hs+1−1
@@ -679,7 +679,7 @@ mathInlineWith op cl = try $ do
679679 where
680680 inBalancedBraces :: Stream s m Char => Int -> Text -> ParserT s st m Text
681681 inBalancedBraces n = fmap T.pack . inBalancedBraces' n . T.unpack
682−
682+
683683 inBalancedBraces' :: Stream s m Char => Int -> String -> ParserT s st m String
684684 inBalancedBraces' 0 "" = do
685685 c <- anyChar
src/Text/Pandoc/Readers/CSV.hs+1−2
@@ -1,6 +1,6 @@
11{-# LANGUAGE NoImplicitPrelude #-}
22{-# LANGUAGE FlexibleContexts #-}
3−{-# LANGUAGE OverloadedStrings #-}
3+
44{-# LANGUAGE ScopedTypeVariables #-}
55{- |
66 Module : Text.Pandoc.Readers.RST
@@ -42,4 +42,3 @@ readCSV _opts s =
4242 widths = replicate numcols 0
4343 Right [] -> return $ B.doc mempty
4444 Left e -> throwError $ PandocParsecError s e
45−
src/Text/Pandoc/Readers/DocBook.hs+1−2
@@ -1106,9 +1106,8 @@ equation e constructor =
11061106
11071107 readMath :: (Element -> Bool) -> (Element -> b) -> [b]
11081108 readMath childPredicate fromElement =
1109− ( map (fromElement . everywhere (mkT removePrefix))
1109+ map (fromElement . everywhere (mkT removePrefix))
11101110 $ filterChildren childPredicate e
1111− )
11121111
11131112-- | Get the actual text stored in a CData block. 'showContent'
11141113-- returns the text still surrounded by the [[CDATA]] tags.
src/Text/Pandoc/Readers/Docx/Fields.hs+2−2
@@ -42,7 +42,7 @@ escapedQuote = string "\\\"" $> "\\\""
4242
4343inQuotes :: Parser T.Text
4444inQuotes =
45− (try escapedQuote) <|> (anyChar >>= (\c -> return $ T.singleton c))
45+ try escapedQuote <|> (anyChar >>= (\c -> return $ T.singleton c))
4646
4747quotedString :: Parser T.Text
4848quotedString = do
@@ -50,7 +50,7 @@ quotedString = do
5050 T.concat <$> manyTill inQuotes (try (char '"'))
5151
5252unquotedString :: Parser T.Text
53−unquotedString = T.pack <$> manyTill anyChar (try $ lookAhead space *> return () <|> eof)
53+unquotedString = T.pack <$> manyTill anyChar (try $ lookAhead space Data.Functor.$> () <|> eof)
5454
5555fieldArgument :: Parser T.Text
5656fieldArgument = quotedString <|> unquotedString
src/Text/Pandoc/Readers/HTML.hs+3−3
@@ -403,8 +403,8 @@ pDiv = try $ do
403403
404404pRawHtmlBlock :: PandocMonad m => TagParser m Blocks
405405pRawHtmlBlock = do
406− raw <- (pHtmlBlock "script" <|> pHtmlBlock "style" <|> pHtmlBlock "textarea"
407− <|> pRawTag)
406+ raw <- pHtmlBlock "script" <|> pHtmlBlock "style" <|> pHtmlBlock "textarea"
407+ <|> pRawTag
408408 exts <- getOption readerExtensions
409409 if extensionEnabled Ext_raw_html exts && not (T.null raw)
410410 then return $ B.rawBlock "html" raw
@@ -976,7 +976,7 @@ isSpecial '\8221' = True
976976isSpecial _ = False
977977
978978pSymbol :: PandocMonad m => InlinesParser m Inlines
979−pSymbol = satisfy isSpecial >>= return . B.str . T.singleton
979+pSymbol = B.str . T.singleton <$> satisfy isSpecial
980980
981981isBad :: Char -> Bool
982982isBad c = c >= '\128' && c <= '\159' -- not allowed in HTML
src/Text/Pandoc/Readers/Markdown.hs+6−7
@@ -21,10 +21,9 @@ import Prelude
2121import Control.Monad
2222import Control.Monad.Except (throwError)
2323import Data.Char (isAlphaNum, isPunctuation, isSpace)
24−import Data.List (sortBy, transpose, elemIndex)
24+import Data.List (transpose, elemIndex, sortOn)
2525import qualified Data.Map as M
2626import Data.Maybe
27−import Data.Ord (comparing)
2827import qualified Data.Set as Set
2928import Data.Text (Text)
3029import qualified Data.Text as T
@@ -247,7 +246,7 @@ yamlMetaBlock = try $ do
247246 newMetaF <- yamlBsToMeta parseBlocks
248247 $ UTF8.fromTextLazy $ TL.fromStrict rawYaml
249248 -- Since `<>` is left-biased, existing values are not touched:
250− updateState $ \st -> st{ stateMeta' = (stateMeta' st) <> newMetaF }
249+ updateState $ \st -> st{ stateMeta' = stateMeta' st <> newMetaF }
251250 return mempty
252251
253252stopLine :: PandocMonad m => MarkdownParser m ()
@@ -1107,7 +1106,7 @@ rawHtmlBlocks = do
11071106 return (return (B.rawBlock "html" $ stripMarkdownAttribute raw) <>
11081107 contents <>
11091108 return (B.rawBlock "html" rawcloser)))
1110− <|> (return (return (B.rawBlock "html" raw) <> contents))
1109+ <|> return (return (B.rawBlock "html" raw) <> contents)
11111110 updateState $ \st -> st{ stateInHtmlBlock = oldInHtmlBlock }
11121111 return result
11131112
@@ -1170,7 +1169,7 @@ simpleTableHeader headless = try $ do
11701169 else rawHeads
11711170 heads <- fmap sequence
11721171 $
1173− mapM ((parseFromString' (mconcat <$> many plain)).trim) rawHeads'
1172+ mapM (parseFromString' (mconcat <$> many plain).trim) rawHeads'
11741173 return (heads, aligns, indices)
11751174
11761175-- Returns an alignment type for a table, based on a list of strings
@@ -1183,7 +1182,7 @@ alignType [] _ = AlignDefault
11831182alignType strLst len =
11841183 let nonempties = filter (not . T.null) $ map trimr strLst
11851184 (leftSpace, rightSpace) =
1186− case sortBy (comparing T.length) nonempties of
1185+ case sortOn T.length nonempties of
11871186 (x:_) -> (T.head x `elem` [' ', 't'], T.length x < len)
11881187 [] -> (False, False)
11891188 in case (leftSpace, rightSpace) of
@@ -1287,7 +1286,7 @@ multilineTableHeader headless = try $ do
12871286 then replicate (length dashes) ""
12881287 else map (T.unlines . map trim) rawHeadsList
12891288 heads <- fmap sequence $
1290− mapM ((parseFromString' (mconcat <$> many plain)).trim) rawHeads
1289+ mapM (parseFromString' (mconcat <$> many plain).trim) rawHeads
12911290 return (heads, aligns, indices')
12921291
12931292-- Parse a grid table: starts with row of '-' on top, then header
src/Text/Pandoc/Readers/Metadata.hs+6−9
@@ -40,8 +40,8 @@ yamlBsToMeta :: PandocMonad m
4040yamlBsToMeta pBlocks bstr = do
4141 pos <- getPosition
4242 case YAML.decodeNode' YAML.failsafeSchemaResolver False False bstr of
43− Right ((YAML.Doc (YAML.Mapping _ _ o)):_)
44− -> (fmap Meta) <$> yamlMap pBlocks o
43+ Right (YAML.Doc (YAML.Mapping _ _ o):_)
44+ -> fmap Meta <$> yamlMap pBlocks o
4545 Right [] -> return . return $ mempty
4646 Right [YAML.Doc (YAML.Scalar _ YAML.SNull)]
4747 -> return . return $ mempty
@@ -84,12 +84,10 @@ toMetaValue pBlocks x =
8484 asBlocks p = MetaBlocks . B.toList <$> p
8585
8686checkBoolean :: Text -> Maybe Bool
87−checkBoolean t =
88− if t == T.pack "true" || t == T.pack "True" || t == T.pack "TRUE"
89− then Just True
90− else if t == T.pack "false" || t == T.pack "False" || t == T.pack "FALSE"
91− then Just False
92− else Nothing
87+checkBoolean t
88+ | t == T.pack "true" || t == T.pack "True" || t == T.pack "TRUE" = Just True
89+ | t == T.pack "false" || t == T.pack "False" || t == T.pack "FALSE" = Just False
90+ | otherwise = Nothing
9391
9492yamlToMetaValue :: PandocMonad m
9593 => ParserT Text ParserState m (F Blocks)
@@ -133,4 +131,3 @@ yamlMap pBlocks o = do
133131 return $ do
134132 v' <- fv
135133 return (k, v')
136−
src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs+2−2
@@ -183,14 +183,14 @@ a >>?! f = a >>> right f
183183 => FallibleArrow a x f (b,b')
184184 -> (b -> b' -> c)
185185 -> FallibleArrow a x f c
186−a >>?% f = a >>?^ (uncurry f)
186+a >>?% f = a >>?^ uncurry f
187187
188188---
189189(^>>?%) :: (ArrowChoice a)
190190 => (x -> Either f (b,b'))
191191 -> (b -> b' -> c)
192192 -> FallibleArrow a x f c
193−a ^>>?% f = arr a >>?^ (uncurry f)
193+a ^>>?% f = arr a >>?^ uncurry f
194194
195195---
196196(>>?%?) :: (ArrowChoice a)
src/Text/Pandoc/Readers/Odt/ContentReader.hs+1−1
@@ -792,7 +792,7 @@ read_frame_title = matchingElement NsSVG "title" (matchChildContent [] read_plai
792792
793793image_attributes :: Maybe T.Text -> Maybe T.Text -> Attr
794794image_attributes x y =
795− ( "", [], (dim "width" x) ++ (dim "height" y))
795+ ( "", [], dim "width" x ++ dim "height" y)
796796 where
797797 dim _ (Just "") = []
798798 dim name (Just v) = [(name, v)]
src/Text/Pandoc/Readers/Odt/Generic/XMLConverter.hs+4−4
@@ -163,7 +163,7 @@ swapStack' state stack
163163pushElement :: XML.Element
164164 -> XMLConverterState nsID extraState
165165 -> XMLConverterState nsID extraState
166−pushElement e state = state { parentElements = e:(parentElements state) }
166+pushElement e state = state { parentElements = e:parentElements state }
167167
168168-- | Pop the top element from the call stack, unless it is the last one.
169169popElement :: XMLConverterState nsID extraState
@@ -605,8 +605,8 @@ executeInSub nsID name a = keepingTheValue
605605 (findChild nsID name)
606606 >>> ignoringState liftFailure
607607 >>? switchingTheStack a
608− where liftFailure (_, (Left f)) = Left f
609− liftFailure (x, (Right e)) = Right (x, e)
608+ where liftFailure (_, Left f) = Left f
609+ liftFailure (x, Right e) = Right (x, e)
610610
611611--------------------------------------------------------------------------------
612612-- Iterating over children
@@ -702,7 +702,7 @@ prepareMatchersC :: (NameSpaceID nsID)
702702 => [(nsID, ElementName, FallibleXMLConverter nsID extraState x x)]
703703 -> ContentMatchConverter nsID extraState x
704704--prepareMatchersC = foldSs . (map $ uncurry3 makeMatcherC)
705−prepareMatchersC = reverseComposition . (map $ uncurry3 makeMatcherC)
705+prepareMatchersC = reverseComposition . map (uncurry3 makeMatcherC)
706706
707707-- | Takes a list of element-data - converter groups and
708708-- * Finds all content of the current element
src/Text/Pandoc/Readers/Odt/StyleReader.hs+1−1
@@ -120,7 +120,7 @@ fontPitchReader = executeInSub NsOffice "font-face-decls" (
120120 lookupDefaultingAttr NsStyle "font-pitch"
121121 ))
122122 >>?^ ( M.fromList . foldl accumLegalPitches [] )
123− ) `ifFailedDo` (returnV (Right M.empty))
123+ ) `ifFailedDo` returnV (Right M.empty)
124124 where accumLegalPitches ls (Nothing,_) = ls
125125 accumLegalPitches ls (Just n,p) = (n,p):ls
126126
src/Text/Pandoc/Readers/RST.hs+6−8
@@ -166,10 +166,8 @@ parseRST = do
166166 blocks <- B.toList <$> parseBlocks
167167 citations <- (sort . M.toList . stateCitations) <$> getState
168168 citationItems <- mapM parseCitation citations
169− let refBlock = if null citationItems
170− then []
171− else [Div ("citations",[],[]) $
172− B.toList $ B.definitionList citationItems]
169+ let refBlock = [Div ("citations",[],[]) $
170+ B.toList $ B.definitionList citationItems | not (null citationItems)]
173171 standalone <- getOption readerStandalone
174172 state <- getState
175173 let meta = stateMeta state
@@ -225,7 +223,7 @@ rawFieldListItem minIndent = try $ do
225223 first <- anyLine
226224 rest <- option "" $ try $ do lookAhead (count indent (char ' ') >> spaceChar)
227225 indentedBlock
228− let raw = (if T.null first then "" else (first <> "\n")) <> rest <> "\n"
226+ let raw = (if T.null first then "" else first <> "\n") <> rest <> "\n"
229227 return (name, raw)
230228
231229fieldListItem :: PandocMonad m => Int -> RSTParser m (Inlines, [Blocks])
@@ -706,7 +704,7 @@ directive' = do
706704 tit <- B.para . B.strong <$> parseInlineFromText
707705 (trim top <> if T.null subtit
708706 then ""
709− else (": " <> subtit))
707+ else ": " <> subtit)
710708 bod <- parseFromString' parseBlocks body'
711709 return $ B.divWith (name,"sidebar":classes,keyvals) $ tit <> bod
712710 "topic" ->
@@ -1446,14 +1444,14 @@ roleAfter = try $ do
14461444unmarkedInterpretedText :: PandocMonad m => RSTParser m Text
14471445unmarkedInterpretedText = try $ do
14481446 atStart (char '`')
1449− contents <- mconcat <$> (many1
1447+ contents <- mconcat <$> many1
14501448 ( many1 (noneOf "`\\\n")
14511449 <|> (char '\\' >> ((\c -> ['\\',c]) <$> noneOf "\n"))
14521450 <|> (string "\n" <* notFollowedBy blankline)
14531451 <|> try (string "`" <*
14541452 notFollowedBy (() <$ roleMarker) <*
14551453 lookAhead (satisfy isAlphaNum))
1456− ))
1454+ )
14571455 char '`'
14581456 return $ T.pack contents
14591457
src/Text/Pandoc/Readers/TikiWiki.hs+1−1
@@ -55,7 +55,7 @@ type TikiWikiParser = ParserT Text ParserState
5555--
5656
5757tryMsg :: Text -> TikiWikiParser m a -> TikiWikiParser m a
58−tryMsg msg p = try p <?> (T.unpack msg)
58+tryMsg msg p = try p <?> T.unpack msg
5959
6060skip :: TikiWikiParser m a -> TikiWikiParser m ()
6161skip parser = Control.Monad.void parser
src/Text/Pandoc/Readers/Vimwiki.hs+1−1
@@ -147,7 +147,7 @@ header = try $ do
147147 contents <- trimInlines . mconcat <$> manyTill inline (try $ spaceChar
148148 >> string eqs >> many spaceChar >> newline)
149149 attr <- registerHeader (makeId contents,
150− if sp == "" then [] else ["justcenter"], []) contents
150+ ["justcenter" | not (null sp)], []) contents
151151 return $ B.headerWith attr lev contents
152152
153153para :: PandocMonad m => VwParser m Blocks
src/Text/Pandoc/SelfContained.hs+1−1
@@ -69,7 +69,7 @@ convertTags (t@(TagOpen tagname as):ts)
6969 enc <- getDataURI (fromAttrib "type" t) y
7070 return (x, enc)
7171 else return (x,y)
72−convertTags (t@(TagOpen "script" as):TagClose "script":ts) =
72+convertTags (t@(TagOpen "script" as):TagClose "script":ts) =
7373 case fromAttrib "src" t of
7474 "" -> (t:) <$> convertTags ts
7575 src -> do
src/Text/Pandoc/Shared.hs+9−9
@@ -466,7 +466,7 @@ compactify items =
466466 let (others, final) = (init items, last items)
467467 in case reverse (B.toList final) of
468468 (Para a:xs)
469− | null [Para x | Para x <- (xs ++ concatMap B.toList others)]
469+ | null [Para x | Para x <- xs ++ concatMap B.toList others]
470470 -> others ++ [B.fromList (reverse (Plain a : xs))]
471471 _ | null [Para x | Para x <- concatMap B.toList items]
472472 -> items
@@ -682,9 +682,9 @@ isTightList = all (\item -> firstIsPlain item || null item)
682682taskListItemFromAscii :: Extensions -> [Block] -> [Block]
683683taskListItemFromAscii = handleTaskListItem fromMd
684684 where
685− fromMd (Str "[" : Space : Str "]" : Space : is) = (Str "☐") : Space : is
686− fromMd (Str "[x]" : Space : is) = (Str "☒") : Space : is
687− fromMd (Str "[X]" : Space : is) = (Str "☒") : Space : is
685+ fromMd (Str "[" : Space : Str "]" : Space : is) = Str "☐" : Space : is
686+ fromMd (Str "[x]" : Space : is) = Str "☒" : Space : is
687+ fromMd (Str "[X]" : Space : is) = Str "☒" : Space : is
688688 fromMd is = is
689689
690690-- | Convert a list item containing text starting with @U+2610 BALLOT BOX@
@@ -787,19 +787,19 @@ splitSentences xs =
787787-- strip out ANSI escape sequences from CodeBlocks (see #5633).
788788filterIpynbOutput :: Maybe Format -> Pandoc -> Pandoc
789789filterIpynbOutput mode = walk go
790− where go (Div (ident, ("output":os), kvs) bs) =
790+ where go (Div (ident, "output":os, kvs) bs) =
791791 case mode of
792− Nothing -> Div (ident, ("output":os), kvs) []
792+ Nothing -> Div (ident, "output":os, kvs) []
793793 -- "best" for ipynb includes all formats:
794794 Just fmt
795795 | fmt == Format "ipynb"
796− -> Div (ident, ("output":os), kvs) bs
797− | otherwise -> Div (ident, ("output":os), kvs) $
796+ -> Div (ident, "output":os, kvs) bs
797+ | otherwise -> Div (ident, "output":os, kvs) $
798798 walk removeANSI $
799799 take 1 $ sortOn rank bs
800800 where
801801 rank (RawBlock (Format "html") _)
802− | fmt == Format "html" = (1 :: Int)
802+ | fmt == Format "html" = 1 :: Int
803803 | fmt == Format "markdown" = 2
804804 | otherwise = 3
805805 rank (RawBlock (Format "latex") _)
src/Text/Pandoc/Writers/AsciiDoc.hs+1−1
@@ -263,7 +263,7 @@ blockToAsciiDoc opts (OrderedList (start, sty, _delim) items) = do
263263 Decimal -> ["arabic"]
264264 Example -> []
265265 _ -> [T.toLower (tshow sty)]
266− let listStart = if start == 1 then [] else ["start=" <> tshow start]
266+ let listStart = ["start=" <> tshow start | not (start == 1)]
267267 let listoptions = case T.intercalate ", " (listStyle ++ listStart) of
268268 "" -> empty
269269 x -> brackets (literal x)
src/Text/Pandoc/Writers/CommonMark.hs+6−10
@@ -45,9 +45,7 @@ writeCommonMark opts (Pandoc meta blocks) = do
4545 else return mempty
4646
4747 let (blocks', notes) = runState (walkM processNotes blocks) []
48− notes' = if null notes
49− then []
50− else [OrderedList (1, Decimal, Period) $ reverse notes]
48+ notes' = [OrderedList (1, Decimal, Period) $ reverse notes | not (null notes)]
5149 main <- blocksToCommonMark opts (blocks' ++ notes')
5250 metadata <- metaToContext opts
5351 (fmap (literal . T.stripEnd) . blocksToCommonMark opts)
@@ -241,13 +239,11 @@ inlineToNodes opts SoftBreak
241239 | otherwise = (node SOFTBREAK [] :)
242240inlineToNodes opts (Emph xs) = (node EMPH (inlinesToNodes opts xs) :)
243241inlineToNodes opts (Strong xs) = (node STRONG (inlinesToNodes opts xs) :)
244−inlineToNodes opts (Strikeout xs) =
245− if isEnabled Ext_strikeout opts
246− then (node (CUSTOM_INLINE "~~" "~~") (inlinesToNodes opts xs) :)
247− else if isEnabled Ext_raw_html opts
248− then ((node (HTML_INLINE (T.pack "<s>")) [] : inlinesToNodes opts xs ++
249− [node (HTML_INLINE (T.pack "</s>")) []]) ++ )
250− else (inlinesToNodes opts xs ++)
242+inlineToNodes opts (Strikeout xs)
243+ | isEnabled Ext_strikeout opts = (node (CUSTOM_INLINE "~~" "~~") (inlinesToNodes opts xs) :)
244+ | isEnabled Ext_raw_html opts = ((node (HTML_INLINE (T.pack "<s>")) [] : inlinesToNodes opts xs ++
245+ [node (HTML_INLINE (T.pack "</s>")) []]) ++ )
246+ | otherwise = (inlinesToNodes opts xs ++)
251247inlineToNodes opts (Superscript xs) =
252248 if isEnabled Ext_raw_html opts
253249 then ((node (HTML_INLINE (T.pack "<sup>")) [] : inlinesToNodes opts xs ++
src/Text/Pandoc/Writers/Docbook.hs+2−6
@@ -409,9 +409,5 @@ isMathML _ = False
409409idAndRole :: Attr -> [(Text, Text)]
410410idAndRole (id',cls,_) = ident <> role
411411 where
412− ident = if T.null id'
413− then []
414− else [("id", id')]
415− role = if null cls
416− then []
417− else [("role", T.unwords cls)]
412+ ident = [("id", id') | not (T.null id')]
413+ role = [("role", T.unwords cls) | not (null cls)]
src/Text/Pandoc/Writers/FB2.hs+2−6
@@ -130,9 +130,7 @@ description meta' = do
130130booktitle :: PandocMonad m => Meta -> FBM m [Content]
131131booktitle meta' = do
132132 t <- cMapM toXml . docTitle $ meta'
133− return $ if null t
134− then []
135− else [ el "book-title" t ]
133+ return $ [el "book-title" t | not (null t)]
136134
137135authors :: Meta -> [Content]
138136authors meta' = cMap author (docAuthors meta')
@@ -156,9 +154,7 @@ docdate :: PandocMonad m => Meta -> FBM m [Content]
156154docdate meta' = do
157155 let ss = docDate meta'
158156 d <- cMapM toXml ss
159− return $ if null d
160− then []
161− else [el "date" d]
157+ return $ [el "date" d | not (null d)]
162158
163159-- | Divide the stream of blocks into sections and convert to XML
164160-- representation.
src/Text/Pandoc/Writers/HTML.hs+4−4
@@ -663,8 +663,8 @@ blockToHtml opts (Div (ident, "section":dclasses, dkvs)
663663 let fragmentClass = case slideVariant of
664664 RevealJsSlides -> "fragment"
665665 _ -> "incremental"
666− let inDiv zs = (RawBlock (Format "html") ("<div class=\""
667− <> fragmentClass <> "\">")) :
666+ let inDiv zs = RawBlock (Format "html") ("<div class=\""
667+ <> fragmentClass <> "\">") :
668668 (zs ++ [RawBlock (Format "html") "</div>"])
669669 let (titleBlocks, innerSecs) =
670670 if titleSlide
@@ -723,8 +723,8 @@ blockToHtml opts (Div attr@(ident, classes, kvs') bs) = do
723723 html5 <- gets stHtml5
724724 slideVariant <- gets stSlideVariant
725725 let kvs = [(k,v) | (k,v) <- kvs', k /= "width"] ++
726− [("style", "width:" <> w <> ";")
727− | ("width",w) <- kvs', "column" `elem` classes] ++
726+ [("style", "width:" <> w <> ";") | "column" `elem` classes,
727+ ("width", w) <- kvs'] ++
728728 [("role", "doc-bibliography") | ident == "refs" && html5] ++
729729 [("role", "doc-biblioentry")
730730 | "ref-item" `T.isPrefixOf` ident && html5]
src/Text/Pandoc/Writers/ICML.hs+1−1
@@ -156,7 +156,7 @@ writeICML opts (Pandoc meta blocks) = do
156156-- | Auxiliary functions for parStylesToDoc and charStylesToDoc.
157157contains :: Text -> (Text, (Text, Text)) -> [(Text, Text)]
158158contains s rule =
159− [snd rule | (fst rule) `Text.isInfixOf` s]
159+ [snd rule | fst rule `Text.isInfixOf` s]
160160
161161-- | The monospaced font to use as default.
162162monospacedFont :: Doc Text
src/Text/Pandoc/Writers/LaTeX.hs+2−4
@@ -644,9 +644,7 @@ blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do
644644 key `notElem` ["exports", "tangle", "results"]
645645 -- see #4889
646646 ] ++
647− (if identifier == ""
648− then []
649− else [ "label=" <> ref ])
647+ ["label=" <> ref | not (T.null identifier)]
650648
651649 else []
652650 printParams
@@ -1131,7 +1129,7 @@ inlineToLaTeX (Span (id',classes,kvs) ils) = do
11311129 ["LR" | ("dir", "ltr") `elem` kvs] ++
11321130 (case lang of
11331131 Just lng -> let (l, o) = toPolyglossia lng
1134− ops = if T.null o then "" else ("[" <> o <> "]")
1132+ ops = if T.null o then "" else "[" <> o <> "]"
11351133 in ["text" <> l <> ops]
11361134 Nothing -> [])
11371135 contents <- inlineListToLaTeX ils
src/Text/Pandoc/Writers/Man.hs+1−2
@@ -88,8 +88,7 @@ notesToMan :: PandocMonad m => WriterOptions -> [[Block]] -> StateT WriterState
8888notesToMan opts notes =
8989 if null notes
9090 then return empty
91− else zipWithM (noteToMan opts) [1..] notes >>=
92− return . (text ".SH NOTES" $$) . vcat
91+ else (text ".SH NOTES" $$) . vcat <$> zipWithM (noteToMan opts) [1..] notes
9392
9493-- | Return man representation of a note.
9594noteToMan :: PandocMonad m => WriterOptions -> Int -> [Block] -> StateT WriterState m (Doc Text)
src/Text/Pandoc/Writers/Math.hs−1
@@ -53,4 +53,3 @@ convertMath writer mt str =
5353 where dt = case mt of
5454 DisplayMath -> DisplayBlock
5555 InlineMath -> DisplayInline
56−
src/Text/Pandoc/Writers/MediaWiki.hs+10−6
@@ -16,6 +16,7 @@ MediaWiki: <http://www.mediawiki.org/wiki/MediaWiki>
1616-}
1717module Text.Pandoc.Writers.MediaWiki ( writeMediaWiki, highlightingLangs ) where
1818import Prelude
19+import Control.Applicative
1920import Control.Monad.Reader
2021import Control.Monad.State.Strict
2122import Data.Maybe (fromMaybe)
@@ -166,7 +167,8 @@ blockToMediaWiki (Table capt aligns widths headers rows') = do
166167 return $ "{|\n" <> caption <> tableBody <> "|}\n"
167168
168169blockToMediaWiki x@(BulletList items) = do
169− tags <- fmap (|| not (isSimpleList x)) $ asks useTags
170+ tags <-
171+ (|| not (isSimpleList x)) Control.Applicative.<$> asks useTags
170172 if tags
171173 then do
172174 contents <- local (\ s -> s { useTags = True }) $ mapM listItemToMediaWiki items
@@ -177,7 +179,8 @@ blockToMediaWiki x@(BulletList items) = do
177179 return $ vcat contents <> if null lev then "\n" else ""
178180
179181blockToMediaWiki x@(OrderedList attribs items) = do
180− tags <- fmap (|| not (isSimpleList x)) $ asks useTags
182+ tags <-
183+ (|| not (isSimpleList x)) Control.Applicative.<$> asks useTags
181184 if tags
182185 then do
183186 contents <- local (\s -> s { useTags = True }) $ mapM listItemToMediaWiki items
@@ -188,7 +191,8 @@ blockToMediaWiki x@(OrderedList attribs items) = do
188191 return $ vcat contents <> if null lev then "\n" else ""
189192
190193blockToMediaWiki x@(DefinitionList items) = do
191− tags <- fmap (|| not (isSimpleList x)) $ asks useTags
194+ tags <-
195+ (|| not (isSimpleList x)) Control.Applicative.<$> asks useTags
192196 if tags
193197 then do
194198 contents <- local (\s -> s { useTags = True }) $ mapM definitionListItemToMediaWiki items
@@ -342,7 +346,7 @@ blockListToMediaWiki :: PandocMonad m
342346 => [Block] -- ^ List of block elements
343347 -> MediaWikiWriter m Text
344348blockListToMediaWiki blocks =
345− fmap vcat $ mapM blockToMediaWiki blocks
349+ vcat Control.Applicative.<$> mapM blockToMediaWiki blocks
346350
347351-- | Convert list of Pandoc inline elements to MediaWiki.
348352inlineListToMediaWiki :: PandocMonad m => [Inline] -> MediaWikiWriter m Text
@@ -355,8 +359,8 @@ inlineListToMediaWiki lst =
355359 , isLinkOrImage x =
356360 Str t : RawInline (Format "mediawiki") "<nowiki/>" : x : fixup xs
357361 fixup (x:xs) = x : fixup xs
358− isLinkOrImage (Link{}) = True
359− isLinkOrImage (Image{}) = True
362+ isLinkOrImage Link{} = True
363+ isLinkOrImage Image{} = True
360364 isLinkOrImage _ = False
361365
362366-- | Convert Pandoc inline element to MediaWiki.
src/Text/Pandoc/Writers/Muse.hs+1−1
@@ -492,7 +492,7 @@ fixOrEscape b (Str s) = fixOrEscapeStr b s
492492 _ -> (sp && (startsWithMarker isDigit s ||
493493 startsWithMarker isAsciiLower s ||
494494 startsWithMarker isAsciiUpper s))
495− || stringStartsWithSpace s
495+ || stringStartsWithSpace s
496496fixOrEscape _ Space = True
497497fixOrEscape _ SoftBreak = True
498498fixOrEscape _ _ = False
src/Text/Pandoc/Writers/ODT.hs+5−7
@@ -101,7 +101,7 @@ pandocToODT opts doc@(Pandoc meta _) = do
101101 $ fromStringLazy $ render Nothing
102102 $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
103103 $$
104− (inTags True "manifest:manifest"
104+ inTags True "manifest:manifest"
105105 [("xmlns:manifest","urn:oasis:names:tc:opendocument:xmlns:manifest:1.0")
106106 ,("manifest:version","1.2")] ( selfClosingTag "manifest:file-entry"
107107 [("manifest:media-type","application/vnd.oasis.opendocument.text")
@@ -109,7 +109,6 @@ pandocToODT opts doc@(Pandoc meta _) = do
109109 $$ vcat ( map toFileEntry files )
110110 $$ vcat ( map toFileEntry formulas )
111111 )
112− )
113112 let archive' = addEntryToArchive manifestEntry archive
114113 -- create meta.xml
115114 let userDefinedMetaFields = [k | k <- Map.keys (unMeta meta)
@@ -129,7 +128,7 @@ pandocToODT opts doc@(Pandoc meta _) = do
129128 $ fromStringLazy $ render Nothing
130129 $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
131130 $$
132− (inTags True "office:document-meta"
131+ inTags True "office:document-meta"
133132 [("xmlns:office","urn:oasis:names:tc:opendocument:xmlns:office:1.0")
134133 ,("xmlns:xlink","http://www.w3.org/1999/xlink")
135134 ,("xmlns:dc","http://purl.org/dc/elements/1.1/")
@@ -163,7 +162,6 @@ pandocToODT opts doc@(Pandoc meta _) = do
163162 vcat userDefinedMeta
164163 )
165164 )
166− )
167165 -- make sure mimetype is first
168166 let mimetypeEntry = toEntry "mimetype" epochtime
169167 $ fromStringLazy "application/vnd.oasis.opendocument.text"
@@ -241,7 +239,7 @@ transformPicMath _ (Math t math) = do
241239 Right r -> do
242240 let conf = useShortEmptyTags (const False) defaultConfigPP
243241 let mathml = ppcTopElement conf r
244− epochtime <- floor `fmap` (lift P.getPOSIXTime)
242+ epochtime <- floor `fmap` lift P.getPOSIXTime
245243 let dirname = "Formula-" ++ show (length entries) ++ "/"
246244 let fname = dirname ++ "content.xml"
247245 let entry = toEntry fname epochtime (fromStringLazy mathml)
@@ -269,12 +267,12 @@ documentSettings :: Bool -> B.ByteString
269267documentSettings isTextMode = fromStringLazy $ render Nothing
270268 $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
271269 $$
272− (inTags True "office:document-settings"
270+ inTags True "office:document-settings"
273271 [("xmlns:office","urn:oasis:names:tc:opendocument:xmlns:office:1.0")
274272 ,("xmlns:xlink","http://www.w3.org/1999/xlink")
275273 ,("xmlns:config","urn:oasis:names:tc:opendocument:xmlns:config:1.0")
276274 ,("xmlns:ooo","http://openoffice.org/2004/office")
277− ,("office:version","1.2")] $
275+ ,("office:version","1.2")] (
278276 inTagsSimple "office:settings" $
279277 inTags False "config:config-item-set"
280278 [("config:name", "ooo:configuration-settings")] $
src/Text/Pandoc/Writers/OpenDocument.hs+2−2
@@ -19,7 +19,7 @@ import Prelude
1919import Control.Arrow ((***), (>>>))
2020import Control.Monad.State.Strict hiding (when)
2121import Data.Char (chr)
22−import Data.List (sortBy, foldl')
22+import Data.List (sortOn, sortBy, foldl')
2323import qualified Data.Map as Map
2424import Data.Maybe (fromMaybe)
2525import Data.Ord (comparing)
@@ -163,7 +163,7 @@ inTextStyle d = do
163163 [("style:name", styleName)
164164 ,("style:family", "text")]
165165 $ selfClosingTag "style:text-properties"
166− (sortBy (comparing fst) . Map.toList
166+ (sortOn fst . Map.toList
167167 $ foldl' textStyleAttr mempty (Set.toList at)))
168168 return $ inTags False
169169 "text:span" [("text:style-name",styleName)] d
src/Text/Pandoc/Writers/Powerpoint/Output.hs+69−78
@@ -41,7 +41,7 @@ import Text.Pandoc.MIME
4141import qualified Data.ByteString.Lazy as BL
4242import Text.Pandoc.Writers.OOXML
4343import qualified Data.Map as M
44−import Data.Maybe (mapMaybe, listToMaybe, fromMaybe, maybeToList, catMaybes, isNothing)
44+import Data.Maybe (mapMaybe, listToMaybe, fromMaybe, maybeToList, catMaybes, isJust)
4545import Text.Pandoc.ImageSize
4646import Control.Applicative ((<|>))
4747import System.FilePath.Glob
@@ -254,7 +254,7 @@ presentationToArchiveP p@(Presentation docProps slides) = do
254254 (throwError $
255255 PandocSomeError $
256256 "The following required files are missing:\n" <>
257− (T.unlines $ map (T.pack . (" " <>)) missingFiles)
257+ T.unlines (map (T.pack . (" " <>)) missingFiles)
258258 )
259259
260260 newArch' <- foldM copyFileToArchive emptyArchive filePaths
@@ -291,11 +291,12 @@ presentationToArchiveP p@(Presentation docProps slides) = do
291291
292292makeSlideIdMap :: Presentation -> M.Map SlideId Int
293293makeSlideIdMap (Presentation _ slides) =
294− M.fromList $ (map slideId slides) `zip` [1..]
294+ M.fromList $ map slideId slides `zip` [1..]
295295
296296makeSpeakerNotesMap :: Presentation -> M.Map Int Int
297297makeSpeakerNotesMap (Presentation _ slides) =
298− M.fromList $ (mapMaybe f $ slides `zip` [1..]) `zip` [1..]
298+ M.fromList $
299+ mapMaybe f (slides `zip` [1..]) `zip` [1..]
299300 where f (Slide _ _ notes, n) = if notes == mempty
300301 then Nothing
301302 else Just n
@@ -350,10 +351,10 @@ curSlideHasSpeakerNotes =
350351getLayout :: PandocMonad m => Layout -> P m Element
351352getLayout layout = do
352353 let layoutpath = case layout of
353− (MetadataSlide _ _ _ _) -> "ppt/slideLayouts/slideLayout1.xml"
354+ (MetadataSlide{}) -> "ppt/slideLayouts/slideLayout1.xml"
354355 (TitleSlide _) -> "ppt/slideLayouts/slideLayout3.xml"
355356 (ContentSlide _ _) -> "ppt/slideLayouts/slideLayout2.xml"
356− (TwoColumnSlide _ _ _) -> "ppt/slideLayouts/slideLayout4.xml"
357+ (TwoColumnSlide{}) -> "ppt/slideLayouts/slideLayout4.xml"
357358 refArchive <- asks envRefArchive
358359 distArchive <- asks envDistArchive
359360 parseXml refArchive distArchive layoutpath
@@ -409,7 +410,7 @@ getMasterShapeDimensionsById ident master = do
409410 let ns = elemToNameSpaces master
410411 cSld <- findChild (elemName ns "p" "cSld") master
411412 spTree <- findChild (elemName ns "p" "spTree") cSld
412− sp <- filterChild (\e -> (isElem ns "p" "sp" e) && (shapeHasId ns ident e)) spTree
413+ sp <- filterChild (\e -> isElem ns "p" "sp" e && shapeHasId ns ident e) spTree
413414 getShapeDimensions ns sp
414415
415416getContentShapeSize :: PandocMonad m
@@ -457,7 +458,7 @@ replaceNamedChildren ns prefix name newKids element =
457458 where
458459 fun :: Bool -> [Content] -> [[Content]]
459460 fun _ [] = []
460− fun switch ((Elem e) : conts) | isElem ns prefix name e =
461+ fun switch (Elem e : conts) | isElem ns prefix name e =
461462 if switch
462463 then map Elem newKids : fun False conts
463464 else fun False conts
@@ -522,9 +523,7 @@ registerMedia fp caption = do
522523 Just Emf -> Just ".emf"
523524 Nothing -> Nothing
524525
525− let newGlobalId = case M.lookup fp globalIds of
526− Just ident -> ident
527− Nothing -> maxGlobalId + 1
526+ let newGlobalId = fromMaybe (maxGlobalId + 1) (M.lookup fp globalIds)
528527
529528 let newGlobalIds = M.insert fp newGlobalId globalIds
530529
@@ -550,10 +549,9 @@ makeMediaEntry :: PandocMonad m => MediaInfo -> P m Entry
550549makeMediaEntry mInfo = do
551550 epochtime <- (floor . utcTimeToPOSIXSeconds) <$> asks envUTCTime
552551 (imgBytes, _) <- P.fetchItem (T.pack $ mInfoFilePath mInfo)
553− let ext = case mInfoExt mInfo of
554− Just e -> e
555− Nothing -> ""
556− let fp = "ppt/media/image" <> (show $ mInfoGlobalId mInfo) <> T.unpack ext
552+ let ext = fromMaybe "" (mInfoExt mInfo)
553+ let fp = "ppt/media/image" <>
554+ show (mInfoGlobalId mInfo) <> T.unpack ext
557555 return $ toEntry fp epochtime $ BL.fromStrict imgBytes
558556
559557makeMediaEntries :: PandocMonad m => P m [Entry]
@@ -717,7 +715,8 @@ makePicElements layout picProps mInfo alt = do
717715 , cNvPicPr
718716 , mknode "p:nvPr" [] ()]
719717 let blipFill = mknode "p:blipFill" []
720− [ mknode "a:blip" [("r:embed", "rId" <> (show $ mInfoLocalId mInfo))] ()
718+ [ mknode "a:blip" [("r:embed", "rId" <>
719+ show (mInfoLocalId mInfo))] ()
721720 , mknode "a:stretch" [] $
722721 mknode "a:fillRect" [] () ]
723722 let xfrm = mknode "a:xfrm" []
@@ -750,9 +749,12 @@ paraElemToElements Break = return [mknode "a:br" [] ()]
750749paraElemToElements (Run rpr s) = do
751750 sizeAttrs <- fontSizeAttributes rpr
752751 let attrs = sizeAttrs <>
753− (if rPropBold rpr then [("b", "1")] else []) <>
754− (if rPropItalics rpr then [("i", "1")] else []) <>
755− (if rPropUnderline rpr then [("u", "sng")] else []) <>
752+ (
753+ [("b", "1") | rPropBold rpr]) <>
754+ (
755+ [("i", "1") | rPropItalics rpr]) <>
756+ (
757+ [("u", "sng") | rPropUnderline rpr]) <>
756758 (case rStrikethrough rpr of
757759 Just NoStrike -> [("strike", "noStrike")]
758760 Just SingleStrike -> [("strike", "sngStrike")]
@@ -796,9 +798,8 @@ paraElemToElements (Run rpr s) = do
796798 _ -> []
797799 Nothing -> []
798800 codeFont <- monospaceFont
799− let codeContents = if rPropCode rpr
800− then [mknode "a:latin" [("typeface", T.unpack codeFont)] ()]
801− else []
801+ let codeContents =
802+ [mknode "a:latin" [("typeface", T.unpack codeFont)] () | rPropCode rpr]
802803 let propContents = linkProps <> colorContents <> codeContents
803804 return [mknode "a:r" [] [ mknode "a:rPr" attrs propContents
804805 , mknode "a:t" [] $ T.unpack s
@@ -817,7 +818,7 @@ paraElemToElements (RawOOXMLParaElem str) = return [ x | Elem x <- parseXML str
817818-- step at a time.
818819addMathInfo :: Element -> Element
819820addMathInfo element =
820− let mathspace = Attr { attrKey = (QName "m" Nothing (Just "xmlns"))
821+ let mathspace = Attr { attrKey = QName "m" Nothing (Just "xmlns")
821822 , attrVal = "http://schemas.openxmlformats.org/officeDocument/2006/math"
822823 }
823824 in add_attr mathspace element
@@ -920,7 +921,7 @@ graphicFrameToElements layout tbls caption = do
920921 `catchError`
921922 (\_ -> return ((0, 0), (pageWidth, pageHeight)))
922923
923− let cy = if (not $ null caption) then cytmp - captionHeight else cytmp
924+ let cy = if not $ null caption then cytmp - captionHeight else cytmp
924925
925926 elements <- mapM (graphicToElement cx) tbls
926927 let graphicFrameElts =
@@ -938,7 +939,7 @@ graphicFrameToElements layout tbls caption = do
938939 ]
939940 ] <> elements
940941
941− if (not $ null caption)
942+ if not $ null caption
942943 then do capElt <- createCaption ((x, y), (cx, cytmp)) caption
943944 return [graphicFrameElts, capElt]
944945 else return [graphicFrameElts]
@@ -1079,9 +1080,7 @@ contentToElement layout hdrShape shapes
10791080 , Just cSld <- findChild (elemName ns "p" "cSld") layout
10801081 , Just spTree <- findChild (elemName ns "p" "spTree") cSld = do
10811082 element <- nonBodyTextToElement layout [PHType "title"] hdrShape
1082− let hdrShapeElements = if null hdrShape
1083− then []
1084− else [element]
1083+ let hdrShapeElements = [element | not (null hdrShape)]
10851084 contentElements <- local
10861085 (\env -> env {envContentType = NormalContent})
10871086 (shapesToElements layout shapes)
@@ -1094,9 +1093,7 @@ twoColumnToElement layout hdrShape shapesL shapesR
10941093 , Just cSld <- findChild (elemName ns "p" "cSld") layout
10951094 , Just spTree <- findChild (elemName ns "p" "spTree") cSld = do
10961095 element <- nonBodyTextToElement layout [PHType "title"] hdrShape
1097− let hdrShapeElements = if null hdrShape
1098− then []
1099− else [element]
1096+ let hdrShapeElements = [element | not (null hdrShape)]
11001097 contentElementsL <- local
11011098 (\env -> env {envContentType =TwoColumnLeftContent})
11021099 (shapesToElements layout shapesL)
@@ -1115,9 +1112,7 @@ titleToElement layout titleElems
11151112 , Just cSld <- findChild (elemName ns "p" "cSld") layout
11161113 , Just spTree <- findChild (elemName ns "p" "spTree") cSld = do
11171114 element <- nonBodyTextToElement layout [PHType "title", PHType "ctrTitle"] titleElems
1118− let titleShapeElements = if null titleElems
1119− then []
1120− else [element]
1115+ let titleShapeElements = [element | not (null titleElems)]
11211116 return $ buildSpTree ns spTree titleShapeElements
11221117titleToElement _ _ = return $ mknode "p:sp" [] ()
11231118
@@ -1395,12 +1390,10 @@ presentationToRels :: PandocMonad m => Presentation -> P m [Relationship]
13951390presentationToRels pres@(Presentation _ slides) = do
13961391 mySlideRels <- mapM slideToPresRel slides
13971392 let notesMasterRels =
1398− if presHasSpeakerNotes pres
1399− then [Relationship { relId = length mySlideRels + 2
1400− , relType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster"
1401− , relTarget = "notesMasters/notesMaster1.xml"
1402− }]
1403− else []
1393+ [Relationship { relId = length mySlideRels + 2
1394+ , relType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster"
1395+ , relTarget = "notesMasters/notesMaster1.xml"
1396+ } | presHasSpeakerNotes pres]
14041397 insertedRels = mySlideRels <> notesMasterRels
14051398 rels <- getRels
14061399 -- we remove the slide rels and the notesmaster (if it's
@@ -1459,7 +1452,8 @@ topLevelRelsEntry :: PandocMonad m => P m Entry
14591452topLevelRelsEntry = elemToEntry "_rels/.rels" $ relsToElement topLevelRels
14601453
14611454relToElement :: Relationship -> Element
1462−relToElement rel = mknode "Relationship" [ ("Id", "rId" <> (show $ relId rel))
1455+relToElement rel = mknode "Relationship" [ ("Id", "rId" <>
1456+ show (relId rel))
14631457 , ("Type", T.unpack $ relType rel)
14641458 , ("Target", relTarget rel) ] ()
14651459
@@ -1502,7 +1496,8 @@ slideToSpeakerNotesEntry slide = do
15021496
15031497slideToSpeakerNotesRelElement :: PandocMonad m => Slide -> P m (Maybe Element)
15041498slideToSpeakerNotesRelElement (Slide _ _ (SpeakerNotes [])) = return Nothing
1505−slideToSpeakerNotesRelElement slide@(Slide _ _ _) = do
1499+slideToSpeakerNotesRelElement slide@(
1500+ Slide{}) = do
15061501 idNum <- slideNum slide
15071502 return $ Just $
15081503 mknode "Relationships"
@@ -1559,13 +1554,13 @@ linkRelElements mp = mapM linkRelElement (M.toList mp)
15591554
15601555mediaRelElement :: MediaInfo -> Element
15611556mediaRelElement mInfo =
1562− let ext = case mInfoExt mInfo of
1563− Just e -> e
1564− Nothing -> ""
1557+ let ext = fromMaybe "" (mInfoExt mInfo)
15651558 in
1566− mknode "Relationship" [ ("Id", "rId" <> (show $ mInfoLocalId mInfo))
1559+ mknode "Relationship" [ ("Id", "rId" <>
1560+ show (mInfoLocalId mInfo))
15671561 , ("Type", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image")
1568− , ("Target", "../media/image" <> (show $ mInfoGlobalId mInfo) <> T.unpack ext)
1562+ , ("Target", "../media/image" <>
1563+ show (mInfoGlobalId mInfo) <> T.unpack ext)
15691564 ] ()
15701565
15711566speakerNotesSlideRelElement :: PandocMonad m => Slide -> P m (Maybe Element)
@@ -1586,10 +1581,10 @@ slideToSlideRelElement :: PandocMonad m => Slide -> P m Element
15861581slideToSlideRelElement slide = do
15871582 idNum <- slideNum slide
15881583 let target = case slide of
1589− (Slide _ (MetadataSlide _ _ _ _) _) -> "../slideLayouts/slideLayout1.xml"
1584+ (Slide _ (MetadataSlide{}) _) -> "../slideLayouts/slideLayout1.xml"
15901585 (Slide _ (TitleSlide _) _) -> "../slideLayouts/slideLayout3.xml"
15911586 (Slide _ (ContentSlide _ _) _) -> "../slideLayouts/slideLayout2.xml"
1592− (Slide _ (TwoColumnSlide _ _ _) _) -> "../slideLayouts/slideLayout4.xml"
1587+ (Slide _ (TwoColumnSlide{}) _) -> "../slideLayouts/slideLayout4.xml"
15931588
15941589 speakerNotesRels <- maybeToList <$> speakerNotesSlideRelElement slide
15951590
@@ -1696,15 +1691,15 @@ docPropsElement docProps = do
16961691 ,("xmlns:dcterms","http://purl.org/dc/terms/")
16971692 ,("xmlns:dcmitype","http://purl.org/dc/dcmitype/")
16981693 ,("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance")]
1699− $ (mknode "dc:title" [] $ maybe "" T.unpack $ dcTitle docProps)
1700− : (mknode "dc:creator" [] $ maybe "" T.unpack $ dcCreator docProps)
1701− : (mknode "cp:keywords" [] $ T.unpack keywords)
1702− : (if isNothing (dcSubject docProps) then [] else
1703− [mknode "dc:subject" [] $ maybe "" T.unpack $ dcSubject docProps])
1704− <> (if isNothing (dcDescription docProps) then [] else
1705− [mknode "dc:description" [] $ maybe "" T.unpack $ dcDescription docProps])
1706− <> (if isNothing (cpCategory docProps) then [] else
1707− [mknode "cp:category" [] $ maybe "" T.unpack $ cpCategory docProps])
1694+ $
1695+ mknode "dc:title" [] (maybe "" T.unpack $ dcTitle docProps)
1696+ :
1697+ mknode "dc:creator" [] (maybe "" T.unpack $ dcCreator docProps)
1698+ :
1699+ mknode "cp:keywords" [] (T.unpack keywords)
1700+ : ( [mknode "dc:subject" [] $ maybe "" T.unpack $ dcSubject docProps | isJust (dcSubject docProps)])
1701+ <> ( [mknode "dc:description" [] $ maybe "" T.unpack $ dcDescription docProps | isJust (dcDescription docProps)])
1702+ <> ( [mknode "cp:category" [] $ maybe "" T.unpack $ cpCategory docProps | isJust (cpCategory docProps)])
17081703 <> (\x -> [ mknode "dcterms:created" [("xsi:type","dcterms:W3CDTF")] x
17091704 , mknode "dcterms:modified" [("xsi:type","dcterms:W3CDTF")] x
17101705 ]) (formatTime defaultTimeLocale "%FT%XZ" utctime)
@@ -1739,7 +1734,8 @@ viewPropsElement = do
17391734 viewPrElement <- parseXml refArchive distArchive "ppt/viewProps.xml"
17401735 -- remove "lastView" if it exists:
17411736 let notLastView :: Text.XML.Light.Attr -> Bool
1742− notLastView attr = (qName $ attrKey attr) /= "lastView"
1737+ notLastView attr =
1738+ qName (attrKey attr) /= "lastView"
17431739 return $
17441740 viewPrElement {elAttribs = filter notLastView (elAttribs viewPrElement)}
17451741
@@ -1765,8 +1761,9 @@ contentTypesToElement ct =
17651761 let ns = "http://schemas.openxmlformats.org/package/2006/content-types"
17661762 in
17671763 mknode "Types" [("xmlns", ns)] $
1768− (map defaultContentTypeToElem $ contentTypesDefaults ct) <>
1769− (map overrideContentTypeToElem $ contentTypesOverrides ct)
1764+
1765+ map defaultContentTypeToElem (contentTypesDefaults ct) <>
1766+ map overrideContentTypeToElem (contentTypesOverrides ct)
17701767
17711768data DefaultContentType = DefaultContentType
17721769 { defContentTypesExt :: T.Text
@@ -1789,16 +1786,14 @@ contentTypesToEntry :: PandocMonad m => ContentTypes -> P m Entry
17891786contentTypesToEntry ct = elemToEntry "[Content_Types].xml" $ contentTypesToElement ct
17901787
17911788pathToOverride :: FilePath -> Maybe OverrideContentType
1792−pathToOverride fp = OverrideContentType ("/" <> fp) <$> (getContentType fp)
1789+pathToOverride fp = OverrideContentType ("/" <> fp) <$> getContentType fp
17931790
17941791mediaFileContentType :: FilePath -> Maybe DefaultContentType
17951792mediaFileContentType fp = case takeExtension fp of
17961793 '.' : ext -> Just $
17971794 DefaultContentType { defContentTypesExt = T.pack ext
17981795 , defContentTypesType =
1799− case getMimeType fp of
1800− Just mt -> mt
1801− Nothing -> "application/octet-stream"
1796+ fromMaybe "application/octet-stream" (getMimeType fp)
18021797 }
18031798 _ -> Nothing
18041799
@@ -1808,9 +1803,7 @@ mediaContentType mInfo
18081803 , Just ('.', ext) <- T.uncons t =
18091804 Just $ DefaultContentType { defContentTypesExt = ext
18101805 , defContentTypesType =
1811− case mInfoMimeType mInfo of
1812− Just mt -> mt
1813− Nothing -> "application/octet-stream"
1806+ fromMaybe "application/octet-stream" (mInfoMimeType mInfo)
18141807 }
18151808 | otherwise = Nothing
18161809
@@ -1842,7 +1835,7 @@ presentationToContentTypes p@(Presentation _ slides) = do
18421835 let slideOverrides = mapMaybe
18431836 (\fp -> pathToOverride $ "ppt/slides/" <> fp)
18441837 relativePaths
1845− speakerNotesOverrides <- (mapMaybe pathToOverride) <$> getSpeakerNotesFilePaths
1838+ speakerNotesOverrides <- mapMaybe pathToOverride <$> getSpeakerNotesFilePaths
18461839 return $ ContentTypes
18471840 (defaults <> mediaDefaults)
18481841 (inheritedOverrides <> createdOverrides <> slideOverrides <> speakerNotesOverrides)
@@ -1862,22 +1855,22 @@ getContentType fp
18621855 | fp == "docProps/core.xml" = Just "application/vnd.openxmlformats-package.core-properties+xml"
18631856 | fp == "docProps/custom.xml" = Just "application/vnd.openxmlformats-officedocument.custom-properties+xml"
18641857 | fp == "docProps/app.xml" = Just $ noPresML <> ".extended-properties+xml"
1865− | "ppt" : "slideMasters" : f : [] <- splitDirectories fp
1858+ | ["ppt", "slideMasters", f] <- splitDirectories fp
18661859 , (_, ".xml") <- splitExtension f =
18671860 Just $ presML <> ".slideMaster+xml"
1868− | "ppt" : "slides" : f : [] <- splitDirectories fp
1861+ | ["ppt", "slides", f] <- splitDirectories fp
18691862 , (_, ".xml") <- splitExtension f =
18701863 Just $ presML <> ".slide+xml"
1871− | "ppt" : "notesMasters" : f : [] <- splitDirectories fp
1864+ | ["ppt", "notesMasters", f] <- splitDirectories fp
18721865 , (_, ".xml") <- splitExtension f =
18731866 Just $ presML <> ".notesMaster+xml"
1874− | "ppt" : "notesSlides" : f : [] <- splitDirectories fp
1867+ | ["ppt", "notesSlides", f] <- splitDirectories fp
18751868 , (_, ".xml") <- splitExtension f =
18761869 Just $ presML <> ".notesSlide+xml"
1877− | "ppt" : "theme" : f : [] <- splitDirectories fp
1870+ | ["ppt", "theme", f] <- splitDirectories fp
18781871 , (_, ".xml") <- splitExtension f =
18791872 Just $ noPresML <> ".theme+xml"
1880− | "ppt" : "slideLayouts" : _ : [] <- splitDirectories fp=
1873+ | ["ppt", "slideLayouts", _] <- splitDirectories fp=
18811874 Just $ presML <> ".slideLayout+xml"
18821875 | otherwise = Nothing
18831876
@@ -1886,9 +1879,7 @@ autoNumAttrs :: ListAttributes -> [(String, String)]
18861879autoNumAttrs (startNum, numStyle, numDelim) =
18871880 numAttr <> typeAttr
18881881 where
1889− numAttr = if startNum == 1
1890− then []
1891− else [("startAt", show startNum)]
1882+ numAttr = [("startAt", show startNum) | startNum /= 1]
18921883 typeAttr = [("type", typeString <> delimString)]
18931884 typeString = case numStyle of
18941885 Decimal -> "arabic"
src/Text/Pandoc/Writers/Powerpoint/Presentation.hs+10−10
@@ -580,15 +580,15 @@ isImage (Link _ (Image{} : _) _) = True
580580isImage _ = False
581581
582582splitBlocks' :: [Block] -> [[Block]] -> [Block] -> Pres [[Block]]
583−splitBlocks' cur acc [] = return $ acc ++ (if null cur then [] else [cur])
583+splitBlocks' cur acc [] = return $ acc ++ ([cur | not (null cur)])
584584splitBlocks' cur acc (HorizontalRule : blks) =
585− splitBlocks' [] (acc ++ (if null cur then [] else [cur])) blks
585+ splitBlocks' [] (acc ++ ([cur | not (null cur)])) blks
586586splitBlocks' cur acc (h@(Header n _ _) : blks) = do
587587 slideLevel <- asks envSlideLevel
588588 let (nts, blks') = span isNotesDiv blks
589589 case compare n slideLevel of
590− LT -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [h : nts]) blks'
591− EQ -> splitBlocks' (h:nts) (acc ++ (if null cur then [] else [cur])) blks'
590+ LT -> splitBlocks' [] (acc ++ ([cur | not (null cur)]) ++ [h : nts]) blks'
591+ EQ -> splitBlocks' (h:nts) (acc ++ ([cur | not (null cur)])) blks'
592592 GT -> splitBlocks' (cur ++ (h:nts)) acc blks'
593593-- `blockToParagraphs` treats Plain and Para the same, so we can save
594594-- some code duplication by treating them the same here.
@@ -604,7 +604,7 @@ splitBlocks' cur acc (Para (il:ils) : blks) | isImage il = do
604604 (acc ++ [cur ++ [Para [il]] ++ nts])
605605 (if null ils then blks' else Para ils : blks')
606606 _ -> splitBlocks' []
607− (acc ++ (if null cur then [] else [cur]) ++ [[Para [il]] ++ nts])
607+ (acc ++ ([cur | not (null cur)]) ++ [Para [il] : nts])
608608 (if null ils then blks' else Para ils : blks')
609609splitBlocks' cur acc (tbl@Table{} : blks) = do
610610 slideLevel <- asks envSlideLevel
@@ -612,14 +612,14 @@ splitBlocks' cur acc (tbl@Table{} : blks) = do
612612 case cur of
613613 [Header n _ _] | n == slideLevel ->
614614 splitBlocks' [] (acc ++ [cur ++ [tbl] ++ nts]) blks'
615− _ -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[tbl] ++ nts]) blks'
615+ _ -> splitBlocks' [] (acc ++ ([cur | not (null cur)]) ++ [tbl : nts]) blks'
616616splitBlocks' cur acc (d@(Div (_, classes, _) _): blks) | "columns" `elem` classes = do
617617 slideLevel <- asks envSlideLevel
618618 let (nts, blks') = span isNotesDiv blks
619619 case cur of
620620 [Header n _ _] | n == slideLevel ->
621621 splitBlocks' [] (acc ++ [cur ++ [d] ++ nts]) blks'
622− _ -> splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[d] ++ nts]) blks'
622+ _ -> splitBlocks' [] (acc ++ ([cur | not (null cur)]) ++ [d : nts]) blks'
623623splitBlocks' cur acc (blk : blks) = splitBlocks' (cur ++ [blk]) acc blks
624624
625625splitBlocks :: [Block] -> Pres [[Block]]
@@ -692,7 +692,7 @@ blockToSpeakerNotes _ = return mempty
692692handleSpeakerNotes :: Block -> Pres ()
693693handleSpeakerNotes blk = do
694694 spNotes <- blockToSpeakerNotes blk
695− modify $ \st -> st{stSpeakerNotes = (stSpeakerNotes st) <> spNotes}
695+ modify $ \st -> st{stSpeakerNotes = stSpeakerNotes st <> spNotes}
696696
697697handleAndFilterSpeakerNotes' :: [Block] -> Pres [Block]
698698handleAndFilterSpeakerNotes' blks = do
@@ -763,7 +763,7 @@ getMetaSlide = do
763763 mempty
764764
765765addSpeakerNotesToMetaSlide :: Slide -> [Block] -> Pres (Slide, [Block])
766−addSpeakerNotesToMetaSlide (Slide sldId layout@(MetadataSlide _ _ _ _) spkNotes) blks =
766+addSpeakerNotesToMetaSlide (Slide sldId layout@(MetadataSlide{}) spkNotes) blks =
767767 do let (ntsBlks, blks') = span isNotesDiv blks
768768 spkNotes' <- mconcat <$> mapM blockToSpeakerNotes ntsBlks
769769 return (Slide sldId layout (spkNotes <> spkNotes'), blks')
@@ -877,7 +877,7 @@ emptyLayout layout = case layout of
877877 all emptyShape shapes2
878878
879879emptySlide :: Slide -> Bool
880−emptySlide (Slide _ layout notes) = (notes == mempty) && (emptyLayout layout)
880+emptySlide (Slide _ layout notes) = (notes == mempty) && emptyLayout layout
881881
882882blocksToPresentationSlides :: [Block] -> Pres [Slide]
883883blocksToPresentationSlides blks = do
src/Text/Pandoc/Writers/RST.hs+9−7
@@ -103,7 +103,8 @@ pandocToRST (Pandoc meta blocks) = do
103103
104104-- | Return RST representation of reference key table.
105105refsToRST :: PandocMonad m => Refs -> RST m (Doc Text)
106−refsToRST refs = mapM keyToRST refs >>= return . vcat
106+refsToRST refs =
107+ vcat <$> mapM keyToRST refs
107108
108109-- | Return RST representation of a reference key.
109110keyToRST :: PandocMonad m => ([Inline], (Text, Text)) -> RST m (Doc Text)
@@ -117,8 +118,7 @@ keyToRST (label, (src, _)) = do
117118-- | Return RST representation of notes.
118119notesToRST :: PandocMonad m => [[Block]] -> RST m (Doc Text)
119120notesToRST notes =
120− zipWithM noteToRST [1..] notes >>=
121− return . vsep
121+ vsep <$> zipWithM noteToRST [1..] notes
122122
123123-- | Return RST representation of a note.
124124noteToRST :: PandocMonad m => Int -> [Block] -> RST m (Doc Text)
@@ -131,7 +131,8 @@ noteToRST num note = do
131131pictRefsToRST :: PandocMonad m
132132 => [([Inline], (Attr, Text, Text, Maybe Text))]
133133 -> RST m (Doc Text)
134−pictRefsToRST refs = mapM pictToRST refs >>= return . vcat
134+pictRefsToRST refs =
135+ vcat <$> mapM pictToRST refs
135136
136137-- | Return RST representation of a picture substitution reference.
137138pictToRST :: PandocMonad m
@@ -507,11 +508,11 @@ flatten outer
507508 (Span ("",[],[]) _, _) -> keep f i
508509 (_, Span ("",[],[]) _) -> keep f i
509510 -- inlineToRST handles this case properly so it's safe to keep
510− (Link _ _ _, Image _ _ _) -> keep f i
511+ ( Link{}, Image{}) -> keep f i
511512 -- parent inlines would prevent links from being correctly
512513 -- parsed, in this case we prioritise the content over the
513514 -- style
514− (_, Link _ _ _) -> emerge f i
515+ (_, Link{}) -> emerge f i
515516 -- always give priority to strong text over emphasis
516517 (Emph _, Strong _) -> emerge f i
517518 -- drop all other nested styles
@@ -567,7 +568,8 @@ inlineListToRST = writeInlines . walk transformInlines
567568
568569-- | Convert list of Pandoc inline elements to RST.
569570writeInlines :: PandocMonad m => [Inline] -> RST m (Doc Text)
570−writeInlines lst = mapM inlineToRST lst >>= return . hcat
571+writeInlines lst =
572+ hcat <$> mapM inlineToRST lst
571573
572574-- | Convert Pandoc inline element to RST.
573575inlineToRST :: PandocMonad m => Inline -> RST m (Doc Text)
src/Text/Pandoc/Writers/TEI.hs+2−4
@@ -282,7 +282,7 @@ inlineToTEI opts (Link attr txt (src, _))
282282 linktext <- inlinesToTEI opts txt
283283 return $ linktext <+> char '(' <> emailLink <> char ')'
284284 | otherwise =
285− (inTags False "ref" $ ("target", src) : idFromAttr opts attr)
285+ inTags False "ref" (("target", src) : idFromAttr opts attr)
286286 <$> inlinesToTEI opts txt
287287inlineToTEI opts (Image attr description (src, tit)) = do
288288 let titleDoc = if T.null tit
@@ -300,6 +300,4 @@ inlineToTEI opts (Note contents) =
300300
301301idFromAttr :: WriterOptions -> Attr -> [(Text, Text)]
302302idFromAttr opts (id',_,_) =
303− if T.null id'
304− then []
305− else [("xml:id", writerIdentifierPrefix opts <> id')]
303+ [("xml:id", writerIdentifierPrefix opts <> id') | not (T.null id')]
src/Text/Pandoc/Writers/Texinfo.hs+2−3
@@ -272,9 +272,8 @@ tableAnyRowToTexinfo :: PandocMonad m
272272 -> [[Block]]
273273 -> TI m (Doc Text)
274274tableAnyRowToTexinfo itemtype aligns cols =
275− zipWithM alignedBlock aligns cols >>=
276− return . (literal itemtype $$) . foldl (\row item -> row $$
277− (if isEmpty row then empty else text " @tab ") <> item) empty
275+ (literal itemtype $$) . foldl (\row item -> row $$
276+ (if isEmpty row then empty else text " @tab ") <> item) empty <$> zipWithM alignedBlock aligns cols
278277
279278alignedBlock :: PandocMonad m
280279 => Alignment
src/Text/Pandoc/Writers/XWiki.hs+9−9
@@ -71,7 +71,7 @@ genAnchor id' = if Text.null id'
7171
7272blockListToXWiki :: PandocMonad m => [Block] -> XWikiReader m Text
7373blockListToXWiki blocks =
74− fmap vcat $ mapM blockToXWiki blocks
74+ vcat <$> mapM blockToXWiki blocks
7575
7676blockToXWiki :: PandocMonad m => Block -> XWikiReader m Text
7777
@@ -79,7 +79,7 @@ blockToXWiki Null = return ""
7979
8080blockToXWiki (Div (id', _, _) blocks) = do
8181 content <- blockListToXWiki blocks
82− return $ (genAnchor id') <> content
82+ return $ genAnchor id' <> content
8383
8484blockToXWiki (Plain inlines) =
8585 inlineListToXWiki inlines
@@ -100,7 +100,7 @@ blockToXWiki HorizontalRule = return "\n----\n"
100100blockToXWiki (Header level (id', _, _) inlines) = do
101101 contents <- inlineListToXWiki inlines
102102 let eqs = Text.replicate level "="
103− return $ eqs <> " " <> contents <> " " <> (genAnchor id') <> eqs <> "\n"
103+ return $ eqs <> " " <> contents <> " " <> genAnchor id' <> eqs <> "\n"
104104
105105-- XWiki doesn't appear to differentiate between inline and block-form code, so we delegate
106106-- We do amend the text to ensure that the code markers are on their own lines, since this is a block
@@ -211,8 +211,8 @@ inlineToXWiki il@(RawInline frmt str)
211211inlineToXWiki (Link (id', _, _) txt (src, _)) = do
212212 label <- inlineListToXWiki txt
213213 case txt of
214− [Str s] | isURI src && escapeURI s == src -> return $ src <> (genAnchor id')
215− _ -> return $ "[[" <> label <> ">>" <> src <> "]]" <> (genAnchor id')
214+ [Str s] | isURI src && escapeURI s == src -> return $ src <> genAnchor id'
215+ _ -> return $ "[[" <> label <> ">>" <> src <> "]]" <> genAnchor id'
216216
217217inlineToXWiki (Image _ alt (source, tit)) = do
218218 alt' <- inlineListToXWiki alt
@@ -225,12 +225,12 @@ inlineToXWiki (Image _ alt (source, tit)) = do
225225
226226inlineToXWiki (Note contents) = do
227227 contents' <- blockListToXWiki contents
228− return $ "{{footnote}}" <> (Text.strip contents') <> "{{/footnote}}"
228+ return $ "{{footnote}}" <> Text.strip contents' <> "{{/footnote}}"
229229
230230-- TODO: support attrs other than id (anchor)
231231inlineToXWiki (Span (id', _, _) contents) = do
232232 contents' <- inlineListToXWiki contents
233− return $ (genAnchor id') <> contents'
233+ return $ genAnchor id' <> contents'
234234
235235-- Utility method since (for now) all lists are handled the same way
236236blockToXWikiList :: PandocMonad m => Text -> [[Block]] -> XWikiReader m Text
@@ -244,7 +244,7 @@ listItemToXWiki :: PandocMonad m => [Block] -> XWikiReader m Text
244244listItemToXWiki contents = do
245245 marker <- asks listLevel
246246 contents' <- blockListToXWiki contents
247− return $ marker <> ". " <> (Text.strip contents')
247+ return $ marker <> ". " <> Text.strip contents'
248248
249249
250250-- | Convert definition list item (label, list of blocks) to MediaWiki.
@@ -256,7 +256,7 @@ definitionListItemToMediaWiki (label, items) = do
256256 contents <- mapM blockListToXWiki items
257257 marker <- asks listLevel
258258 return $ marker <> " " <> labelText <> "\n" <>
259− intercalate "\n" (map (\d -> (Text.init marker) <> ": " <> d) contents)
259+ intercalate "\n" (map (\d -> Text.init marker <> ": " <> d) contents)
260260
261261-- Escape the escape character, as well as formatting pairs
262262escapeXWikiString :: Text -> Text
test/Tests/Command.hs−1
@@ -18,7 +18,6 @@ import Data.Algorithm.Diff
1818import qualified Data.ByteString as BS
1919import qualified Data.Text as T
2020import Data.List (isSuffixOf)
21−import Prelude hiding (readFile)
2221import System.Directory
2322import System.Exit
2423import System.FilePath (joinPath, splitDirectories, takeDirectory, (</>))
test/Tests/Readers/Docx.hs+1−1
@@ -91,7 +91,7 @@ testForWarningsWithOpts opts name docxFile expected =
9191
9292getMedia :: FilePath -> FilePath -> IO (Maybe B.ByteString)
9393getMedia archivePath mediaPath = do
94− zf <- B.readFile archivePath >>= return . toArchive
94+ zf <- toArchive <$> B.readFile archivePath
9595 return $ findEntryByPath ("word/" ++ mediaPath) zf >>= (Just . fromEntry)
9696
9797compareMediaPathIO :: FilePath -> MediaBag -> FilePath -> IO Bool
test/Tests/Readers/HTML.hs+4−4
@@ -95,14 +95,14 @@ tests = [ testGroup "base tag"
9595 ]
9696 , testGroup "samp"
9797 [
98− test html "inline samp block" $
99− "<samp>Answer is 42</samp>" =?>
98+ test html "inline samp block" $
99+ "<samp>Answer is 42</samp>" =?>
100100 plain (codeWith ("",["sample"],[]) "Answer is 42")
101101 ]
102102 , testGroup "var"
103103 [
104− test html "inline var block" $
105− "<var>result</var>" =?>
104+ test html "inline var block" $
105+ "<var>result</var>" =?>
106106 plain (codeWith ("",["variable"],[]) "result")
107107 ]
108108 , askOption $ \(QuickCheckTests numtests) ->
test/Tests/Readers/Man.hs+15−15
@@ -51,13 +51,13 @@ tests = [
5151 =?> header 2 (text "The header 2")
5252 , "Macro args" =:
5353 ".B \"single arg with \"\"Q\"\"\""
54− =?> (para $ strong $ text "single arg with \"Q\"")
54+ =?>para (strong $ text "single arg with \"Q\"")
5555 , "Argument from next line" =:
5656 ".B\nsingle arg with \"Q\""
57− =?> (para $ strong $ text "single arg with \"Q\"")
57+ =?>para (strong $ text "single arg with \"Q\"")
5858 , "comment" =:
5959 ".\\\"bla\naaa"
60− =?> (para $ str "aaa")
60+ =?>para (str "aaa")
6161 , "link" =:
6262 ".BR aa (1)"
6363 =?> para (strong (str "aa") <> str "(1)")
@@ -65,7 +65,7 @@ tests = [
6565 testGroup "Escapes" [
6666 "fonts" =:
6767 "aa\\fIbb\\fRcc"
68− =?> (para $ str "aa" <> (emph $ str "bb") <> str "cc")
68+ =?>para (str "aa" <> (emph $ str "bb") <> str "cc")
6969 , "nested fonts" =:
7070 "\\f[BI]hi\\f[I] there\\f[R]"
7171 =?> para (emph (strong (text "hi") <> text " there"))
@@ -75,26 +75,26 @@ tests = [
7575 text " ok")
7676 , "skip" =:
7777 "a\\%\\\n\\:b\\0"
78− =?> (para $ str "ab\8199")
78+ =?>para (str "ab\8199")
7979 , "replace" =:
8080 "\\-\\ \\\\\\[lq]\\[rq]\\[em]\\[en]\\*(lq\\*(rq"
81− =?> (para $ text "- \\“”—–“”")
81+ =?>para (text "- \\“”—–“”")
8282 , "replace2" =:
83− "\\t\\e\\`\\^\\|\\'" =?> (para $ text "\\`\8202\8198`")
83+ "\\t\\e\\`\\^\\|\\'" =?>para (text "\\`\8202\8198`")
8484 , "comment with \\\"" =:
85− "Foo \\\" bar\n" =?> (para $ text "Foo")
85+ "Foo \\\" bar\n" =?>para (text "Foo")
8686 , "comment with \\#" =:
87− "Foo\\#\nbar\n" =?> (para $ text "Foobar")
87+ "Foo\\#\nbar\n" =?>para (text "Foobar")
8888 , "two letter escapes" =:
89− "\\(oA\\(~O" =?> (para $ text "ÅÕ")
89+ "\\(oA\\(~O" =?>para (text "ÅÕ")
9090 , "bracketed escapes" =:
91− "\\[oA]\\[~O]\\[Do]\\[Ye]\\[product]\\[ul]" =?> (para $ text "ÅÕ$¥∏_")
91+ "\\[oA]\\[~O]\\[Do]\\[Ye]\\[product]\\[ul]" =?>para (text "ÅÕ$¥∏_")
9292 , "unicode escapes" =:
93− "\\[u2020]" =?> (para $ text "†")
93+ "\\[u2020]" =?>para (text "†")
9494 , "unicode escapes (combined)" =:
95− "\\[u0075_u0301]" =?> (para $ text "\250")
95+ "\\[u0075_u0301]" =?>para (text "\250")
9696 , "unknown escape (#5034)" =:
97− "\\9" =?> (para $ text "9")
97+ "\\9" =?>para (text "9")
9898 ],
9999 testGroup "Lists" [
100100 "bullet" =:
@@ -108,7 +108,7 @@ tests = [
108108 =?> orderedListWith (1,UpperAlpha,OneParen) [para $ str "first", para $ str "second"]
109109 , "nested" =:
110110 ".IP \"\\[bu]\"\nfirst\n.RS\n.IP \"\\[bu]\"\n1a\n.IP \"\\[bu]\"\n1b\n.RE"
111− =?> bulletList [(para $ str "first") <> (bulletList [para $ str "1a", para $ str "1b"])]
111+ =?> bulletList [para (str "first") <> bulletList [para $ str "1a", para $ str "1b"]]
112112 , "change in list style" =:
113113 ".IP \\[bu]\nfirst\n.IP 1\nsecond"
114114 =?> bulletList [para (str "first")] <>
test/Tests/Readers/Org/Meta.hs+1−1
@@ -199,6 +199,6 @@ tests =
199199 , "#+pandoc-emphasis-post:"
200200 , "[/noemph/]"
201201 ] =?>
202− para ("[/noemph/]")
202+ para "[/noemph/]"
203203 ]
204204 ]
test/Tests/Readers/Txt2Tags.hs+3−3
@@ -311,14 +311,14 @@ tests =
311311 , "Ordered List in Bullet List" =:
312312 ("- Emacs\n" <>
313313 " + Org\n") =?>
314− bulletList [ (plain "Emacs") <>
315− (orderedList [ plain "Org"])
314+ bulletList [ plain "Emacs" <>
315+ orderedList [ plain "Org"]
316316 ]
317317
318318 , "Bullet List in Ordered List" =:
319319 ("+ GNU\n" <>
320320 " - Freedom\n") =?>
321− orderedList [ (plain "GNU") <> bulletList [ (plain "Freedom") ] ]
321+ orderedList [ plain "GNU" <> bulletList [ plain "Freedom" ] ]
322322
323323 , "Definition List" =:
324324 T.unlines [ ": PLL"
test/Tests/Writers/HTML.hs+2−2
@@ -74,13 +74,13 @@ tests = [ testGroup "inline code"
7474 , testGroup "sample with style"
7575 [ "samp should wrap highlighted code" =:
7676 codeWith ("",["sample","haskell"],[]) ">>="
77− =?> ("<samp><code class=\"sourceCode haskell\">" ++
77+ =?> ("<samp><code class=\"sourceCode haskell\">" ++
7878 "<span class=\"op\">&gt;&gt;=</span></code></samp>")
7979 ]
8080 , testGroup "variable with style"
8181 [ "var should wrap highlighted code" =:
8282 codeWith ("",["haskell","variable"],[]) ">>="
83− =?> ("<var><code class=\"sourceCode haskell\">" ++
83+ =?> ("<var><code class=\"sourceCode haskell\">" ++
8484 "<span class=\"op\">&gt;&gt;=</span></code></var>")
8585 ]
8686 ]
test/Tests/Writers/Markdown.hs+23−23
@@ -93,7 +93,7 @@ noteTests = testGroup "note and reference location"
9393 [ test (markdownWithOpts defopts)
9494 "footnotes at the end of a document" $
9595 noteTestDoc =?>
96− (unlines [ "First Header"
96+ unlines [ "First Header"
9797 , "============"
9898 , ""
9999 , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
@@ -110,11 +110,11 @@ noteTests = testGroup "note and reference location"
110110 , "[^1]: Down here."
111111 , ""
112112 , "[^2]: The second note."
113− ])
113+ ]
114114 , test (markdownWithOpts defopts{writerReferenceLocation=EndOfBlock})
115115 "footnotes at the end of blocks" $
116116 noteTestDoc =?>
117− (unlines [ "First Header"
117+ unlines [ "First Header"
118118 , "============"
119119 , ""
120120 , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
@@ -131,11 +131,11 @@ noteTests = testGroup "note and reference location"
131131 , "============="
132132 , ""
133133 , "Some more text."
134− ])
134+ ]
135135 , test (markdownWithOpts defopts{writerReferenceLocation=EndOfBlock, writerReferenceLinks=True})
136136 "footnotes and reference links at the end of blocks" $
137137 noteTestDoc =?>
138− (unlines [ "First Header"
138+ unlines [ "First Header"
139139 , "============"
140140 , ""
141141 , "This is a footnote.[^1] And this is a [link]."
@@ -154,11 +154,11 @@ noteTests = testGroup "note and reference location"
154154 , "============="
155155 , ""
156156 , "Some more text."
157− ])
157+ ]
158158 , test (markdownWithOpts defopts{writerReferenceLocation=EndOfSection})
159159 "footnotes at the end of section" $
160160 noteTestDoc =?>
161− (unlines [ "First Header"
161+ unlines [ "First Header"
162162 , "============"
163163 , ""
164164 , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
@@ -175,7 +175,7 @@ noteTests = testGroup "note and reference location"
175175 , "============="
176176 , ""
177177 , "Some more text."
178− ])
178+ ]
179179
180180 ]
181181
@@ -191,24 +191,24 @@ shortcutLinkRefsTests =
191191 =: para (link "/url" "title" "foo")
192192 =?> "[foo]\n\n [foo]: /url \"title\""
193193 , "Followed by another link (unshortcutable)"
194− =: para ((link "/url1" "title1" "first")
195− <> (link "/url2" "title2" "second"))
194+ =: para (link "/url1" "title1" "first"
195+ <> link "/url2" "title2" "second")
196196 =?> unlines [ "[first][][second]"
197197 , ""
198198 , " [first]: /url1 \"title1\""
199199 , " [second]: /url2 \"title2\""
200200 ]
201201 , "Followed by space and another link (unshortcutable)"
202− =: para ((link "/url1" "title1" "first") <> " "
203− <> (link "/url2" "title2" "second"))
202+ =: para (link "/url1" "title1" "first" <> " "
203+ <> link "/url2" "title2" "second")
204204 =?> unlines [ "[first][] [second]"
205205 , ""
206206 , " [first]: /url1 \"title1\""
207207 , " [second]: /url2 \"title2\""
208208 ]
209209 , "Reference link is used multiple times (unshortcutable)"
210− =: para ((link "/url1" "" "foo") <> (link "/url2" "" "foo")
211− <> (link "/url3" "" "foo"))
210+ =: para (link "/url1" "" "foo" <> link "/url2" "" "foo"
211+ <> link "/url3" "" "foo")
212212 =?> unlines [ "[foo][][foo][1][foo][2]"
213213 , ""
214214 , " [foo]: /url1"
@@ -216,8 +216,8 @@ shortcutLinkRefsTests =
216216 , " [2]: /url3"
217217 ]
218218 , "Reference link is used multiple times (unshortcutable)"
219− =: para ((link "/url1" "" "foo") <> " " <> (link "/url2" "" "foo")
220− <> " " <> (link "/url3" "" "foo"))
219+ =: para (link "/url1" "" "foo" <> " " <> link "/url2" "" "foo"
220+ <> " " <> link "/url3" "" "foo")
221221 =?> unlines [ "[foo][] [foo][1] [foo][2]"
222222 , ""
223223 , " [foo]: /url1"
@@ -225,43 +225,43 @@ shortcutLinkRefsTests =
225225 , " [2]: /url3"
226226 ]
227227 , "Reference link is followed by text in brackets"
228− =: para ((link "/url" "" "link") <> "[text in brackets]")
228+ =: para (link "/url" "" "link" <> "[text in brackets]")
229229 =?> unlines [ "[link][]\\[text in brackets\\]"
230230 , ""
231231 , " [link]: /url"
232232 ]
233233 , "Reference link is followed by space and text in brackets"
234− =: para ((link "/url" "" "link") <> " [text in brackets]")
234+ =: para (link "/url" "" "link" <> " [text in brackets]")
235235 =?> unlines [ "[link][] \\[text in brackets\\]"
236236 , ""
237237 , " [link]: /url"
238238 ]
239239 , "Reference link is followed by RawInline"
240− =: para ((link "/url" "" "link") <> rawInline "markdown" "[rawText]")
240+ =: para (link "/url" "" "link" <> rawInline "markdown" "[rawText]")
241241 =?> unlines [ "[link][][rawText]"
242242 , ""
243243 , " [link]: /url"
244244 ]
245245 , "Reference link is followed by space and RawInline"
246− =: para ((link "/url" "" "link") <> space <> rawInline "markdown" "[rawText]")
246+ =: para (link "/url" "" "link" <> space <> rawInline "markdown" "[rawText]")
247247 =?> unlines [ "[link][] [rawText]"
248248 , ""
249249 , " [link]: /url"
250250 ]
251251 , "Reference link is followed by RawInline with space"
252− =: para ((link "/url" "" "link") <> rawInline "markdown" " [rawText]")
252+ =: para (link "/url" "" "link" <> rawInline "markdown" " [rawText]")
253253 =?> unlines [ "[link][] [rawText]"
254254 , ""
255255 , " [link]: /url"
256256 ]
257257 , "Reference link is followed by citation"
258− =: para ((link "/url" "" "link") <> cite [Citation "author" [] [] NormalCitation 0 0] (str "[@author]"))
258+ =: para (link "/url" "" "link" <> cite [Citation "author" [] [] NormalCitation 0 0] (str "[@author]"))
259259 =?> unlines [ "[link][][@author]"
260260 , ""
261261 , " [link]: /url"
262262 ]
263263 , "Reference link is followed by space and citation"
264− =: para ((link "/url" "" "link") <> space <> cite [Citation "author" [] [] NormalCitation 0 0] (str "[@author]"))
264+ =: para (link "/url" "" "link" <> space <> cite [Citation "author" [] [] NormalCitation 0 0] (str "[@author]"))
265265 =?> unlines [ "[link][] [@author]"
266266 , ""
267267 , " [link]: /url"
test/Tests/Writers/RST.hs+1−1
@@ -175,6 +175,6 @@ tests = [ testGroup "rubrics"
175175 , "--------"]
176176 ]
177177 , testTemplate "$subtitle$\n" "subtitle" $
178− (setMeta "subtitle" ("subtitle" :: Inlines) $ doc $ plain "") =?>
178+ setMeta "subtitle" ("subtitle" :: Inlines) (doc $ plain "") =?>
179179 ("subtitle" :: String)
180180 ]