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.
This commit is contained in:
n3fariox 2018-01-15 23:46:12 -05:00 committed by John MacFarlane
parent 6910267abf
commit f5f0b76636

View file

@ -531,15 +531,18 @@ pCol = try $ do
skipMany pBlank
optional $ pSatisfy (matchTagClose "col")
skipMany pBlank
return $ case lookup "width" attribs of
let width = case lookup "width" attribs of
Nothing -> case lookup "style" attribs of
Just ('w':'i':'d':'t':'h':':':xs) | '%' `elem` xs ->
fromMaybe 0.0 $ safeRead ('0':'.':filter
fromMaybe 0.0 $ safeRead (filter
(`notElem` (" \t\r\n%'\";" :: [Char])) xs)
_ -> 0.0
Just x | not (null x) && last x == '%' ->
fromMaybe 0.0 $ safeRead ('0':'.':init x)
fromMaybe 0.0 $ safeRead (init x)
_ -> 0.0
if width > 0.0
then return $ width / 100.0
else return 0.0
pColgroup :: PandocMonad m => TagParser m [Double]
pColgroup = try $ do