hurl-xml 0.2.0.0 → 0.2.0.1
raw patch · 2 files changed
+11/−11 lines, 2 files
Files
- hurl-xml.cabal +2/−2
- src/Network/URI/Fetch/XML/Table.hs +9/−9
hurl-xml.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.2.0.0+version: 0.2.0.1 -- A short (one-line) description of the package. synopsis: Fetch parsed XML & possibly CSS for a URL based on MIMEtype.@@ -60,7 +60,7 @@ -- other-extensions: -- Other library packages from which modules are imported.- build-depends: base >=4.12 && <4.13, text, bytestring, containers,+ build-depends: base >=4.12 && <4.16, text, bytestring, containers, data-default-class, time, directory, filepath, temporary, xml-conduit >= 1.8 && <2, html-conduit >= 1.3 && <2,
src/Network/URI/Fetch/XML/Table.hs view
@@ -19,7 +19,7 @@ applySort :: String -> Element -> Element applySort ('#':'-':'a':'r':'g':'o':'-':'%':anchor) el- | (id', ord:col) <- L.break (`elem` ['<', '>']) anchor, Just col' <- readMaybe col =+ | (id', ord:col) <- L.break (`L.elem` ['<', '>']) anchor, Just col' <- readMaybe col = applySort' id' (ord == '<') col' el applySort _ el = el @@ -94,14 +94,14 @@ tableHeadComparators' :: [Node] -> [Maybe Text] tableHeadComparators' (NodeElement el@Element { elementName = Name name _ _, elementNodes = childs}:els) | name == "thead" = tableHeadComparators' childs `mergeRight` tableHeadComparators' els- | name `elem` ["colgroup", "tr"] = tableRowComparators childs `mergeRight` tableHeadComparators' els+ | name `L.elem` ["colgroup", "tr"] = tableRowComparators childs `mergeRight` tableHeadComparators' els | otherwise = tableHeadComparators' els tableHeadComparators' [] = [] tableRowComparators :: [Node] -> [Maybe Text] tableRowComparators (NodeElement el@(Element (Name "col" _ _) attrs _):els) = let colspan = fromMaybe 1 (M.lookup "span" attrs >>= readMaybe . unpack) in Prelude.replicate colspan (M.lookup "-argo-sortas" attrs) ++ tableRowComparators els-tableRowComparators (NodeElement el@(Element (Name n _ _) attrs _):els) | n `elem` ["td", "th"] =+tableRowComparators (NodeElement el@(Element (Name n _ _) attrs _):els) | n `L.elem` ["td", "th"] = let colspan = fromMaybe 1 (M.lookup "colspan" attrs >>= readMaybe . unpack) in Prelude.replicate colspan (M.lookup "-argo-sortas" attrs) ++ tableRowComparators els tableRowComparators (_:els) = tableRowComparators els@@ -120,9 +120,9 @@ annotateTHead [] _ _ = [] annotateTR (NodeElement el@Element { elementName = Name n _ _, elementAttributes = attrs }:nodes) asc col count- | n `elem` ["th", "td"], count >= col =+ | n `L.elem` ["th", "td"], count >= col = NodeElement el { elementAttributes = M.insert "aria-sort" asc' attrs }:nodes- | n `elem` ["th", "td"] = NodeElement el:annotateTR nodes asc col (count + colspan)+ | n `L.elem` ["th", "td"] = NodeElement el:annotateTR nodes asc col (count + colspan) where colspan = fromMaybe 1 (readMaybe =<< unpack <$> M.lookup "colspan" attrs') attrs' = M.mapKeys nameLocalName attrs@@ -140,9 +140,9 @@ tds2keys :: [Element] -> Maybe [Text] tds2keys (el@Element {elementName = Name n _ _, elementAttributes = attrs, elementNodes = childs }:els)- | n `elem` ["td", "th"], Just key <- "-argo-sortkey" `M.lookup` attrs, Just rest <- tds2keys els =+ | n `L.elem` ["td", "th"], Just key <- "-argo-sortkey" `M.lookup` attrs, Just rest <- tds2keys els = Just (Prelude.replicate colspan key ++ rest)- | n `elem` ["td", "th"], Just rest <- tds2keys els =+ | n `L.elem` ["td", "th"], Just rest <- tds2keys els = Just (Prelude.replicate colspan (nodesText childs) ++ rest) where colspan | Just n <- "colspan" `M.lookup` M.mapKeys nameLocalName attrs,@@ -160,7 +160,7 @@ rowRowspan n Element {elementName = Name "tr" _ _, elementNodes = childs } = Prelude.maximum (n : [n | NodeElement (Element (Name name _ _) attrs _) <- childs,- name `elem` ["td", "th"],+ name `L.elem` ["td", "th"], rowspan <- maybeToList ("rowspan" `M.lookup` M.mapKeys nameLocalName attrs), n <- maybeToList $ readMaybe $ unpack rowspan]) @@ -204,7 +204,7 @@ compareAs as bs "number" = readInt as `compare` readInt bs where readInt :: Text -> Maybe Float- readInt = readMaybe . Prelude.filter (`elem` '-':'.':['0'..'9']) . unpack+ readInt = readMaybe . Prelude.filter (`L.elem` '-':'.':['0'..'9']) . unpack compareAs as bs fmt = readTime as `compare` readTime bs where readTime :: Text -> Maybe UTCTime