From f0e0e1e5d4f80140b7e965f1db1af3528d0833da Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 18 Dec 2011 11:42:24 -0800 Subject: Highlighting: Use reads instead of read. Fixes crash on startNum="abc". --- src/Text/Pandoc/Highlighting.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Highlighting.hs b/src/Text/Pandoc/Highlighting.hs index f80ebeac7..efa4fa20e 100644 --- a/src/Text/Pandoc/Highlighting.hs +++ b/src/Text/Pandoc/Highlighting.hs @@ -40,9 +40,11 @@ import Data.Char (toLower) highlightHtml :: Bool -- ^ True if inline HTML -> Attr -- ^ Attributes of the Code or CodeBlock -> String -- ^ Raw contents of the Code or CodeBlock - -> Either String Html -- ^ An error or the formatted Html -highlightHtml inline (_, classes, keyvals) rawCode = - let firstNum = read $ fromMaybe "1" $ lookup "startFrom" keyvals + -> Either String Html -- ^ An error or the formatted Html +highlightHtml inline (id', classes, keyvals) rawCode = + let firstNum = case reads (fromMaybe "1" $ lookup "startFrom" keyvals) of + ((n,_):_) -> n + [] -> 1 fmtOpts = [OptNumberFrom firstNum] ++ [OptInline | inline] ++ case find (`elem` ["number","numberLines","number-lines"]) classes of -- cgit v1.2.3