aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Odt
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-12-17 10:24:09 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2018-12-17 10:31:09 -0800
commit404e96761a9301e750a332524137639e204e44d0 (patch)
tree82942f3852f12fb4ac01f6e81dbfcef525fc9b8c /src/Text/Pandoc/Readers/Odt
parent90c820dc4e3d7e1db3813b953777d65ee74b2779 (diff)
downloadpandoc-404e96761a9301e750a332524137639e204e44d0.tar.gz
Replace read with safeRead. Closes #5162.
Diffstat (limited to 'src/Text/Pandoc/Readers/Odt')
-rw-r--r--src/Text/Pandoc/Readers/Odt/StyleReader.hs9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/Odt/StyleReader.hs b/src/Text/Pandoc/Readers/Odt/StyleReader.hs
index 6a1682829..bddc014f9 100644
--- a/src/Text/Pandoc/Readers/Odt/StyleReader.hs
+++ b/src/Text/Pandoc/Readers/Odt/StyleReader.hs
@@ -62,7 +62,6 @@ import Prelude
import Control.Applicative hiding (liftA, liftA2, liftA3)
import Control.Arrow
-import Data.Char (isDigit)
import Data.Default
import qualified Data.Foldable as F
import Data.List (unfoldr)
@@ -72,6 +71,8 @@ import qualified Data.Set as S
import qualified Text.XML.Light as XML
+import Text.Pandoc.Shared (safeRead)
+
import Text.Pandoc.Readers.Odt.Arrows.Utils
import Text.Pandoc.Readers.Odt.Generic.Fallible
@@ -576,11 +577,7 @@ readListLevelStyle levelType = readAttr NsText "level"
toListLevelStyle _ p s LinfNone b = ListLevelStyle LltBullet p s LinfNone (startValue b)
toListLevelStyle _ p s f@(LinfString _) b = ListLevelStyle LltBullet p s f (startValue b)
toListLevelStyle t p s f b = ListLevelStyle t p s f (startValue b)
- startValue (Just "") = 1
- startValue (Just v) = if all isDigit v
- then read v
- else 1
- startValue Nothing = 1
+ startValue mbx = fromMaybe 1 (mbx >>= safeRead)
--
chooseMostSpecificListLevelStyle :: S.Set ListLevelStyle -> Maybe ListLevelStyle