diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2011-12-18 11:42:24 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2011-12-18 11:42:24 -0800 |
commit | f0e0e1e5d4f80140b7e965f1db1af3528d0833da (patch) | |
tree | f833a069856691f31b0416089f8fee9a761467ab /src/Text | |
parent | bfa5ca01bc2ea97f041441ef7f4667decd76c5c8 (diff) | |
download | pandoc-f0e0e1e5d4f80140b7e965f1db1af3528d0833da.tar.gz |
Highlighting: Use reads instead of read.
Fixes crash on startNum="abc".
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Highlighting.hs | 8 |
1 files changed, 5 insertions, 3 deletions
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 |