aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/Powerpoint/Output.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2021-03-11 15:49:27 -0800
committerJohn MacFarlane <[email protected]>2021-03-13 15:05:37 -0800
commit8be95ad8e5150d5cab66c4abdf59baaf4670c6c8 (patch)
tree9655036efbaabda6a2a7802dc971c7fba5a987ca /src/Text/Pandoc/Writers/Powerpoint/Output.hs
parent35b66a76718205c303f416bf0afc01c098e8a171 (diff)
Use custom Prelude based on relude.relude
The Prelude now longer exports partial functions, so a large number of uses of these functions in the code base have been rewritten. A .ghci file has been added; this is necessary for ghci to work properly with the custom Prelude. Currently there are lots of compiler warnings. We should either fix these or go to using a custom Prelude that changes less than relude.
Diffstat (limited to 'src/Text/Pandoc/Writers/Powerpoint/Output.hs')
-rw-r--r--src/Text/Pandoc/Writers/Powerpoint/Output.hs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Writers/Powerpoint/Output.hs b/src/Text/Pandoc/Writers/Powerpoint/Output.hs
index 5caeb0753..a9fb4e46a 100644
--- a/src/Text/Pandoc/Writers/Powerpoint/Output.hs
+++ b/src/Text/Pandoc/Writers/Powerpoint/Output.hs
@@ -17,9 +17,8 @@ module Text.Pandoc.Writers.Powerpoint.Output ( presentationToArchive
) where
import Control.Monad.Except (throwError, catchError)
-import Control.Monad.Reader
-import Control.Monad.State
import Codec.Archive.Zip
+import Control.Monad (foldM)
import Data.List (intercalate, stripPrefix, nub, union, isPrefixOf, intersperse)
import Data.Default
import Data.Text (Text)
@@ -477,11 +476,12 @@ registerLink link = do
let maxLinkId = case M.lookup curSlideId linkReg of
Just mp -> case M.keys mp of
[] -> if hasSpeakerNotes then 2 else 1
- ks -> maximum ks
+ ks -> fromMaybe 0 $ viaNonEmpty maximum1 ks
Nothing -> if hasSpeakerNotes then 2 else 1
maxMediaId = case M.lookup curSlideId mediaReg of
Just [] -> if hasSpeakerNotes then 2 else 1
- Just mInfos -> maximum $ map mInfoLocalId mInfos
+ Just mInfos -> fromMaybe 0 $ viaNonEmpty maximum1
+ $ map mInfoLocalId mInfos
Nothing -> if hasSpeakerNotes then 2 else 1
maxId = max maxLinkId maxMediaId
slideLinks = case M.lookup curSlideId linkReg of
@@ -500,17 +500,18 @@ registerMedia fp caption = do
let maxLinkId = case M.lookup curSlideId linkReg of
Just mp -> case M.keys mp of
[] -> if hasSpeakerNotes then 2 else 1
- ks -> maximum ks
+ ks -> fromMaybe 0 $ viaNonEmpty maximum1 ks
Nothing -> if hasSpeakerNotes then 2 else 1
maxMediaId = case M.lookup curSlideId mediaReg of
Just [] -> if hasSpeakerNotes then 2 else 1
- Just mInfos -> maximum $ map mInfoLocalId mInfos
+ Just mInfos -> fromMaybe 0 $ viaNonEmpty maximum1
+ $ map mInfoLocalId mInfos
Nothing -> if hasSpeakerNotes then 2 else 1
maxLocalId = max maxLinkId maxMediaId
maxGlobalId = case M.elems globalIds of
[] -> 0
- ids -> maximum ids
+ ids -> fromMaybe 0 $ viaNonEmpty maximum1 ids
(imgBytes, mbMt) <- P.fetchItem $ T.pack fp
let imgExt = (mbMt >>= extensionFromMimeType >>= (\x -> return $ "." <> x))
@@ -1431,7 +1432,7 @@ presentationToRels pres@(Presentation _ slides) = do
[] -> 0 -- doesn't matter in this case, since
-- there will be nothing to map the
-- function over
- l -> minimum l
+ l -> fromMaybe 0 $ viaNonEmpty minimum1 l
modifyRelNum :: Int -> Int
modifyRelNum 1 = 1