diff options
author | n3fariox <n3fariox@gmail.com> | 2018-01-15 23:46:12 -0500 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-01-15 21:46:12 -0700 |
commit | f5f0b76636dcf568d6afa53783fb8dc2d36c74b3 (patch) | |
tree | 0f9b4d112cd34b2ed1b58489909cca1875f29282 | |
parent | 6910267abfa7d5a1743589d301e7b9ecf2a54e4f (diff) | |
download | pandoc-f5f0b76636dcf568d6afa53783fb8dc2d36c74b3.tar.gz |
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.
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index e8dd9ec11..f15bf1c96 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -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 |