git.iko.soy/typeable/pandoc
on master help sign in
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.

commit7233a7a9329c6c4e75f84b9dca01cb05bf2a55b7 authorJoseph C. Sible <josephcsible@users.noreply.github.com> dateSun 29 Mar 2020, 01:48 (7 years ago) parentc812ff7
2 files changed+5−7
src/Text/Pandoc/Readers/Docx.hs+3−4 test/Tests/Readers/Docx.hs+2−3
src/Text/Pandoc/Readers/Docx.hs+3−4
@@ -334,15 +334,14 @@ extentToAttr _ = nullAttr
334334
335335blocksToInlinesWarn :: PandocMonad m => T.Text -> Blocks -> DocxContext m Inlines
336336blocksToInlinesWarn cmtId blks = do
337− let blkList = toList blks
338− paraOrPlain :: Block -> Bool
337+ let paraOrPlain :: Block -> Bool
339338 paraOrPlain (Para _) = True
340339 paraOrPlain (Plain _) = True
341340 paraOrPlain _ = False
342− unless (all paraOrPlain blkList) $
341+ unless (all paraOrPlain blks) $
343342 lift $ P.report $ DocxParserWarning $
344343 "Docx comment " <> cmtId <> " will not retain formatting"
345− return $ blocksToInlines' blkList
344+ return $ blocksToInlines' (toList blks)
346345
347346-- The majority of work in this function is done in the primed
348347-- subfunction `partPartToInlines'`. We make this wrapper so that we
test/Tests/Readers/Docx.hs+2−3
@@ -90,9 +90,8 @@ testForWarningsWithOpts opts name docxFile expected =
9090-- testForWarnings = testForWarningsWithOpts defopts
9191
9292getMedia :: FilePath -> FilePath -> IO (Maybe B.ByteString)
93−getMedia archivePath mediaPath = do
94− zf <- toArchive <$> B.readFile archivePath
95− return $ fromEntry <$> findEntryByPath ("word/" ++ mediaPath) zf
93+getMedia archivePath mediaPath = fmap fromEntry . findEntryByPath
94+ ("word/" ++ mediaPath) . toArchive <$> B.readFile archivePath
9695
9796compareMediaPathIO :: FilePath -> MediaBag -> FilePath -> IO Bool
9897compareMediaPathIO mediaPath mediaBag docxPath = do