git.iko.soy/typeable/pandoc
on master help sign in
HTML reader: Fix col width parsing for percentages < 10% (#4262)

Rather than take user input, and place a "0." in front, actually calculate the percentage to catch cases where small column sizes (e.g. `2%`) are needed.

commitf5f0b76636dcf568d6afa53783fb8dc2d36c74b3 authorn3fariox <n3fariox@gmail.com> dateMon 15 Jan 2018, 23:46 (9 years ago) parent6910267
1 file changed+6−3
src/Text/Pandoc/Readers/HTML.hs+6−3
src/Text/Pandoc/Readers/HTML.hs+6−3
@@ -531,15 +531,18 @@ pCol = try $ do
531531 skipMany pBlank
532532 optional $ pSatisfy (matchTagClose "col")
533533 skipMany pBlank
534− return $ case lookup "width" attribs of
534+ let width = case lookup "width" attribs of
535535 Nothing -> case lookup "style" attribs of
536536 Just ('w':'i':'d':'t':'h':':':xs) | '%' `elem` xs ->
537− fromMaybe 0.0 $ safeRead ('0':'.':filter
537+ fromMaybe 0.0 $ safeRead (filter
538538 (`notElem` (" \t\r\n%'\";" :: [Char])) xs)
539539 _ -> 0.0
540540 Just x | not (null x) && last x == '%' ->
541− fromMaybe 0.0 $ safeRead ('0':'.':init x)
541+ fromMaybe 0.0 $ safeRead (init x)
542542 _ -> 0.0
543+ if width > 0.0
544+ then return $ width / 100.0
545+ else return 0.0
543546
544547pColgroup :: PandocMonad m => TagParser m [Double]
545548pColgroup = try $ do