git.iko.soy/typeable/pandoc
on master help sign in
Use NonEmpty instead of minimumDef.
commit8d5116381b20442bb3fa58dac1ef7d44db618823 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 19 Mar 2021, 10:30 (6 years ago) parenta31731b
4 files changed+9−8
src/Text/Pandoc/Readers/LaTeX.hs+2−2 src/Text/Pandoc/Readers/Org/Blocks.hs+2−2 src/Text/Pandoc/Readers/Textile.hs+2−2 src/Text/Pandoc/Writers/Powerpoint/Output.hs+3−2
src/Text/Pandoc/Readers/LaTeX.hs+2−2
@@ -68,7 +68,7 @@ import Text.Pandoc.Readers.LaTeX.Inline (acronymCommands, refCommands,
6868 listingsLanguage)
6969import Text.Pandoc.Shared
7070import Text.Pandoc.Walk
71−import Safe
71+import Data.List.NonEmpty (nonEmpty)
7272
7373-- for debugging:
7474-- import Text.Pandoc.Extensions (getDefaultExtensions)
@@ -96,7 +96,7 @@ parseLaTeX = do
9696 let doc' = doc bs
9797 let headerLevel (Header n _ _) = [n]
9898 headerLevel _ = []
99− let bottomLevel = minimumDef 1 $ query headerLevel doc'
99+ let bottomLevel = maybe 1 minimum $ nonEmpty $ 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,7 +39,7 @@ import Data.Functor (($>))
3939import Data.List (foldl', intersperse)
4040import Data.Maybe (fromMaybe, isJust, isNothing)
4141import Data.Text (Text)
42−import Safe (minimumDef)
42+import Data.List.NonEmpty (nonEmpty)
4343
4444import qualified Data.Text as T
4545import qualified Text.Pandoc.Builder as B
@@ -543,7 +543,7 @@ include = try $ do
543543 in case (minlvl >>= safeRead :: Maybe Int) of
544544 Nothing -> blks
545545 Just lvl -> let levels = Walk.query headerLevel blks
546− curMin = minimumDef 0 levels
546+ curMin = maybe 0 minimum $ nonEmpty levels
547547 in Walk.walk (shiftHeader (curMin - lvl)) blks
548548
549549 headerLevel :: Block -> [Int]
src/Text/Pandoc/Readers/Textile.hs+2−2
@@ -53,7 +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)
56+import Data.List.NonEmpty (nonEmpty)
5757
5858-- | Parse a Textile text and return a Pandoc document.
5959readTextile :: PandocMonad m
@@ -377,7 +377,7 @@ table = try $ do
377377 (toprow, rest)
378378 _ -> (mempty, rawrows)
379379 let nbOfCols = maximum $ map length (headers:rows)
380− let aligns = map (minimumDef AlignDefault) $
380+ let aligns = map (maybe AlignDefault minimum . nonEmpty) $
381381 transpose $ map (map (snd . fst)) (headers:rows)
382382 let toRow = Row nullAttr . map B.simpleCell
383383 toHeaderRow l = [toRow l | not (null l)]
src/Text/Pandoc/Writers/Powerpoint/Output.hs+3−2
@@ -50,7 +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)
53+import Data.List.NonEmpty (nonEmpty)
5454
5555-- |The 'EMU' type is used to specify sizes in English Metric Units.
5656type EMU = Integer
@@ -1428,7 +1428,8 @@ presentationToRels pres@(Presentation _ slides) = do
14281428 -- all relWithoutSlide rels (unless they're 1)
14291429 -- 3. If we have a notesmaster slide, we make space for that as well.
14301430
1431− let minRelNotOne = minimumDef 0 $ filter (1 <) $ map relId relsWeKeep
1431+ let minRelNotOne = maybe 0 minimum $ nonEmpty
1432+ $ filter (1 <) $ map relId relsWeKeep
14321433
14331434 modifyRelNum :: Int -> Int
14341435 modifyRelNum 1 = 1