From 404e96761a9301e750a332524137639e204e44d0 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 17 Dec 2018 10:24:09 -0800 Subject: Replace read with safeRead. Closes #5162. --- src/Text/Pandoc/Readers/Docx/Lists.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc/Readers/Docx') diff --git a/src/Text/Pandoc/Readers/Docx/Lists.hs b/src/Text/Pandoc/Readers/Docx/Lists.hs index 0be363f3d..72d49c6fa 100644 --- a/src/Text/Pandoc/Readers/Docx/Lists.hs +++ b/src/Text/Pandoc/Readers/Docx/Lists.hs @@ -39,21 +39,21 @@ import Data.List import Data.Maybe import Text.Pandoc.Generic (bottomUp) import Text.Pandoc.JSON -import Text.Pandoc.Shared (trim) +import Text.Pandoc.Shared (trim, safeRead) isListItem :: Block -> Bool isListItem (Div (_, classes, _) _) | "list-item" `elem` classes = True isListItem _ = False getLevel :: Block -> Maybe Integer -getLevel (Div (_, _, kvs) _) = read <$> lookup "level" kvs +getLevel (Div (_, _, kvs) _) = lookup "level" kvs >>= safeRead getLevel _ = Nothing getLevelN :: Block -> Integer getLevelN b = fromMaybe (-1) (getLevel b) getNumId :: Block -> Maybe Integer -getNumId (Div (_, _, kvs) _) = read <$> lookup "num-id" kvs +getNumId (Div (_, _, kvs) _) = lookup "num-id" kvs >>= safeRead getNumId _ = Nothing getNumIdN :: Block -> Integer @@ -89,7 +89,7 @@ getListType b@(Div (_, _, kvs) _) | isListItem b = Just f -> case txt of Just t -> Just $ Enumerated ( - read (fromMaybe "1" start) :: Int, + fromMaybe 1 (start >>= safeRead) :: Int, fromMaybe DefaultStyle (lookup f listStyleMap), fromMaybe DefaultDelim (lookup t listDelimMap)) Nothing -> Nothing -- cgit v1.2.3