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:
parent
6910267abf
commit
f5f0b76636
1 changed files with 6 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue