Avoid deprecation warning for minimumDef using CPP.

This commit is contained in:
John MacFarlane 2019-12-05 10:35:16 -08:00
parent ee44d44f20
commit d96f1fdc40

View file

@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
@ -38,7 +39,6 @@ import Data.Maybe (fromMaybe, maybeToList)
import qualified Data.Set as Set import qualified Data.Set as Set
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as T import qualified Data.Text as T
import Safe (minimumDef)
import System.FilePath (addExtension, replaceExtension, takeExtension) import System.FilePath (addExtension, replaceExtension, takeExtension)
import Text.Pandoc.BCP47 (Lang (..), renderLang) import Text.Pandoc.BCP47 (Lang (..), renderLang)
import Text.Pandoc.Builder import Text.Pandoc.Builder
@ -62,6 +62,7 @@ import qualified Text.Pandoc.Translations as Translations
import Text.Pandoc.Walk import Text.Pandoc.Walk
import qualified Text.Pandoc.Builder as B import qualified Text.Pandoc.Builder as B
import qualified Data.Text.Normalize as Normalize import qualified Data.Text.Normalize as Normalize
import Safe
-- for debugging: -- for debugging:
-- import Text.Pandoc.Extensions (getDefaultExtensions) -- import Text.Pandoc.Extensions (getDefaultExtensions)
@ -89,7 +90,11 @@ parseLaTeX = do
let doc' = doc bs let doc' = doc bs
let headerLevel (Header n _ _) = [n] let headerLevel (Header n _ _) = [n]
headerLevel _ = [] headerLevel _ = []
#if MIN_VERSION_safe(0,3,18)
let bottomLevel = minimumBound 1 $ query headerLevel doc'
#else
let bottomLevel = minimumDef 1 $ query headerLevel doc' let bottomLevel = minimumDef 1 $ query headerLevel doc'
#endif
let adjustHeaders m (Header n attr ils) = Header (n+m) attr ils let adjustHeaders m (Header n attr ils) = Header (n+m) attr ils
adjustHeaders _ x = x adjustHeaders _ x = x
let (Pandoc _ bs') = let (Pandoc _ bs') =