More cleanup (#6209)

* Simplify by collapsing a do block into a single <$>
* Remove an unnecessary variable: `all` takes any Foldable, so only blocksToInlines needs toList.
This commit is contained in:
Joseph C. Sible
2020-03-28 22:48:47 -07:00
committed by GitHub
parent c812ff7e89
commit 7233a7a932
2 changed files with 5 additions and 7 deletions
+3 -4
View File
@@ -334,15 +334,14 @@ extentToAttr _ = nullAttr
blocksToInlinesWarn :: PandocMonad m => T.Text -> Blocks -> DocxContext m Inlines
blocksToInlinesWarn cmtId blks = do
let blkList = toList blks
paraOrPlain :: Block -> Bool
let paraOrPlain :: Block -> Bool
paraOrPlain (Para _) = True
paraOrPlain (Plain _) = True
paraOrPlain _ = False
unless (all paraOrPlain blkList) $
unless (all paraOrPlain blks) $
lift $ P.report $ DocxParserWarning $
"Docx comment " <> cmtId <> " will not retain formatting"
return $ blocksToInlines' blkList
return $ blocksToInlines' (toList blks)
-- The majority of work in this function is done in the primed
-- subfunction `partPartToInlines'`. We make this wrapper so that we
+2 -3
View File
@@ -90,9 +90,8 @@ testForWarningsWithOpts opts name docxFile expected =
-- testForWarnings = testForWarningsWithOpts defopts
getMedia :: FilePath -> FilePath -> IO (Maybe B.ByteString)
getMedia archivePath mediaPath = do
zf <- toArchive <$> B.readFile archivePath
return $ fromEntry <$> findEntryByPath ("word/" ++ mediaPath) zf
getMedia archivePath mediaPath = fmap fromEntry . findEntryByPath
("word/" ++ mediaPath) . toArchive <$> B.readFile archivePath
compareMediaPathIO :: FilePath -> MediaBag -> FilePath -> IO Bool
compareMediaPathIO mediaPath mediaBag docxPath = do