git.iko.soy/typeable/pandoc
on master help sign in
Use traverse instead of reimplementing it (#6124)
commit013a1647a7c78e92b12c2ae520699ef7a567029a authorJoseph C. Sible <josephcsible@users.noreply.github.com> dateFri 7 Feb 2020, 02:10 (7 years ago) parent30c8980
2 files changed+3−8
src/Text/Pandoc/App/OutputSettings.hs+2−5 src/Text/Pandoc/Readers/Org/Blocks.hs+1−3
src/Text/Pandoc/App/OutputSettings.hs+2−5
@@ -65,9 +65,7 @@ optToOutputSettings opts = do
6565 mapM_ (UTF8.hPutStrLn stdout) (fromMaybe [] $ optInputFiles opts)
6666 exitSuccess
6767
68− epubMetadata <- case optEpubMetadata opts of
69− Nothing -> return Nothing
70− Just fp -> Just <$> readUtf8File fp
68+ epubMetadata <- traverse readUtf8File $ optEpubMetadata opts
7169
7270 let pdfOutput = map toLower (takeExtension outputFile) == ".pdf" ||
7371 optTo opts == Just "pdf"
@@ -112,8 +110,7 @@ optToOutputSettings opts = do
112110 syntaxMap <- foldM addSyntaxMap defaultSyntaxMap
113111 (optSyntaxDefinitions opts)
114112
115− hlStyle <- maybe (return Nothing) (fmap Just . lookupHighlightStyle . T.unpack)
116− (optHighlightStyle opts)
113+ hlStyle <- traverse (lookupHighlightStyle . T.unpack) $ optHighlightStyle opts
117114
118115 let setVariableM k v = return . setVariable k v
119116
src/Text/Pandoc/Readers/Org/Blocks.hs+1−3
@@ -130,9 +130,7 @@ blockAttributes = try $ do
130130 let kvAttrs = foldl' (appendValues "ATTR_HTML") Nothing kv
131131 let name = lookup "NAME" kv
132132 let label = lookup "LABEL" kv
133− caption' <- case caption of
134− Nothing -> return Nothing
135− Just s -> Just <$> parseFromString inlines (s <> "\n")
133+ caption' <- traverse (parseFromString inlines . (<> "\n")) caption
136134 kvAttrs' <- parseFromString keyValues . (<> "\n") $ fromMaybe mempty kvAttrs
137135 return BlockAttributes
138136 { blockAttrName = name