@@ -1,6 +1,5 @@
11{-# LANGUAGE LambdaCase #-}
22{-# LANGUAGE OverloadedStrings #-}
3−{-# LANGUAGE ViewPatterns #-}
43{- |
54 Module : Text.Pandoc.Readers.HTML.Table
65 Copyright : © 2006-2021 John MacFarlane,
@@ -42,18 +41,15 @@ pCol = try $ do
4241 skipMany pBlank
4342 optional $ pSatisfy (matchTagClose "col")
4443 skipMany pBlank
45− let width = case lookup "width" attribs of
46− Nothing -> case lookup "style" attribs of
47− Just (T.stripPrefix "width:" -> Just xs) | T.any (== '%') xs ->
48− fromMaybe 0.0 $ safeRead (T.filter
49− (`notElem` (" \t\r\n%'\";" :: [Char])) xs)
50− _ -> 0.0
51− Just (T.unsnoc -> Just (xs, '%')) ->
52− fromMaybe 0.0 $ safeRead xs
53− _ -> 0.0
54− if width > 0.0
55− then return $ ColWidth $ width / 100.0
56− else return ColWidthDefault
44+ let toColWidth = maybe ColWidthDefault (ColWidth . (/100.0)) . safeRead
45+ return $ fromMaybe ColWidthDefault $
46+ (case lookup "width" attribs >>= T.unsnoc of
47+ Just (xs, '%') -> Just (toColWidth xs)
48+ _ -> Nothing) <|>
49+ (case lookup "style" attribs >>= T.stripPrefix "width" of
50+ Just xs | T.any (== '%') xs -> Just . toColWidth $
51+ T.filter (`notElem` (" \t\r\n%'\";" :: [Char])) xs
52+ _ -> Nothing)
5753
5854pColgroup :: PandocMonad m => TagParser m [ColWidth]
5955pColgroup = try $ do