git.iko.soy/typeable/pandoc
on master help sign in
Highlighting: Use reads instead of read.

Fixes crash on startNum="abc".

commitf0e0e1e5d4f80140b7e965f1db1af3528d0833da authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 18 Dec 2011, 11:42 (15 years ago) parentbfa5ca0
1 file changed+5−3
src/Text/Pandoc/Highlighting.hs+5−3
src/Text/Pandoc/Highlighting.hs+5−3
@@ -40,9 +40,11 @@ import Data.Char (toLower)
4040highlightHtml :: Bool -- ^ True if inline HTML
4141 -> Attr -- ^ Attributes of the Code or CodeBlock
4242 -> String -- ^ Raw contents of the Code or CodeBlock
43− -> Either String Html -- ^ An error or the formatted Html
44−highlightHtml inline (_, classes, keyvals) rawCode =
45− let firstNum = read $ fromMaybe "1" $ lookup "startFrom" keyvals
43+ -> Either String Html -- ^ An error or the formatted Html
44+highlightHtml inline (id', classes, keyvals) rawCode =
45+ let firstNum = case reads (fromMaybe "1" $ lookup "startFrom" keyvals) of
46+ ((n,_):_) -> n
47+ [] -> 1
4648 fmtOpts = [OptNumberFrom firstNum] ++
4749 [OptInline | inline] ++
4850 case find (`elem` ["number","numberLines","number-lines"]) classes of