git.iko.soy/typeable/pandoc
on master help sign in
Use minimumDef instead of minimum (partial function).
commit3428248debb14066e7fb1ef216927d3d62e3a43a authorJohn MacFarlane <jgm@berkeley.edu> dateThu 18 Mar 2021, 23:01 (6 years ago) parentf0e4b9c
4 files changed+8−9
src/Text/Pandoc/Readers/LaTeX.hs+1−1 src/Text/Pandoc/Readers/Org/Blocks.hs+2−2 src/Text/Pandoc/Readers/Textile.hs+3−1 src/Text/Pandoc/Writers/Powerpoint/Output.hs+2−5
src/Text/Pandoc/Readers/LaTeX.hs+1−1
@@ -96,7 +96,7 @@ parseLaTeX = do
9696 let doc' = doc bs
9797 let headerLevel (Header n _ _) = [n]
9898 headerLevel _ = []
99− let bottomLevel = minimumBound 1 $ query headerLevel doc'
99+ let bottomLevel = minimumDef 1 $ query headerLevel doc'
100100 let adjustHeaders m (Header n attr ils) = Header (n+m) attr ils
101101 adjustHeaders _ x = x
102102 let (Pandoc _ bs') =
src/Text/Pandoc/Readers/Org/Blocks.hs+2−2
@@ -39,6 +39,7 @@ import Data.Functor (($>))
3939import Data.List (foldl', intersperse)
4040import Data.Maybe (fromMaybe, isJust, isNothing)
4141import Data.Text (Text)
42+import Safe (minimumDef)
4243
4344import qualified Data.Text as T
4445import qualified Text.Pandoc.Builder as B
@@ -542,8 +543,7 @@ include = try $ do
542543 in case (minlvl >>= safeRead :: Maybe Int) of
543544 Nothing -> blks
544545 Just lvl -> let levels = Walk.query headerLevel blks
545− -- CAVE: partial function in else
546− curMin = if null levels then 0 else minimum levels
546+ curMin = minimumDef 0 levels
547547 in Walk.walk (shiftHeader (curMin - lvl)) blks
548548
549549 headerLevel :: Block -> [Int]
src/Text/Pandoc/Readers/Textile.hs+3−1
@@ -53,6 +53,7 @@ import Text.Pandoc.Parsing
5353import Text.Pandoc.Readers.HTML (htmlTag, isBlockTag, isInlineTag)
5454import Text.Pandoc.Readers.LaTeX (rawLaTeXBlock, rawLaTeXInline)
5555import Text.Pandoc.Shared (crFilter, trim, tshow)
56+import Safe (minimumDef)
5657
5758-- | Parse a Textile text and return a Pandoc document.
5859readTextile :: PandocMonad m
@@ -376,7 +377,8 @@ table = try $ do
376377 (toprow, rest)
377378 _ -> (mempty, rawrows)
378379 let nbOfCols = maximum $ map length (headers:rows)
379− let aligns = map minimum $ transpose $ map (map (snd . fst)) (headers:rows)
380+ let aligns = map (minimumDef AlignDefault) $
381+ transpose $ map (map (snd . fst)) (headers:rows)
380382 let toRow = Row nullAttr . map B.simpleCell
381383 toHeaderRow l = [toRow l | not (null l)]
382384 return $ B.table (B.simpleCaption $ B.plain caption)
src/Text/Pandoc/Writers/Powerpoint/Output.hs+2−5
@@ -50,6 +50,7 @@ import Text.Pandoc.Writers.Math (convertMath)
5050import Text.Pandoc.Writers.Powerpoint.Presentation
5151import Text.Pandoc.Shared (tshow)
5252import Skylighting (fromColor)
53+import Safe (minimumDef)
5354
5455-- |The 'EMU' type is used to specify sizes in English Metric Units.
5556type EMU = Integer
@@ -1427,11 +1428,7 @@ presentationToRels pres@(Presentation _ slides) = do
14271428 -- all relWithoutSlide rels (unless they're 1)
14281429 -- 3. If we have a notesmaster slide, we make space for that as well.
14291430
1430− let minRelNotOne = case filter (1<) $ map relId relsWeKeep of
1431− [] -> 0 -- doesn't matter in this case, since
1432− -- there will be nothing to map the
1433− -- function over
1434− l -> minimum l
1431+ let minRelNotOne = minimumDef 0 $ filter (1 <) $ map relId relsWeKeep
14351432
14361433 modifyRelNum :: Int -> Int
14371434 modifyRelNum 1 = 1