packages feed

microformats2-parser 1.0.2.2 → 1.0.2.3

raw patch · 3 files changed

+16/−8 lines, 3 files

Files

library/Data/Microformats2/Jf2.hs view
@@ -22,7 +22,7 @@         flattenType x = x         flattenProps p@(Object o) = Object $ KM.delete "value" $ KM.delete "properties" $           foldl (\acc (k, v) → KM.insert k (flattenArr $ processProp k v) acc) o $-#if MIN_VERSION_aeson(2,0,0)+#if MIN_VERSION_aeson(2,0,0) && !MIN_VERSION_lens_aeson(1,2,0)           map (\(k, v) -> (K.fromText k, v)) $ #endif           p ^@.. key "properties" . members
library/Data/Microformats2/Parser.hs view
@@ -30,6 +30,14 @@ import           Safe (headMay)  #if MIN_VERSION_aeson(2,0,0)+toK' :: T.Text -> K.Key+toK' = K.fromText+#else+toK' :: a -> a+toK' = id+#endif++#if MIN_VERSION_aeson(2,0,0) && !MIN_VERSION_lens_aeson(1,2,0) toK :: T.Text -> K.Key toK = K.fromText #else@@ -92,8 +100,8 @@   let propNames = groupBy' snd $ map readPropertyName $ filter isPropertyClass $ classes e       extractPropertyValue (t, _) = extractProperty settings t e in   if any isMf2Class $ classes e-     then map (\(n, ts) → (toK n) .= [ addValue (fst $ head ts) (parseH settings e) (extractPropertyValue $ head ts) ]) propNames-     else map (\(n, ts) → (toK n) .= map extractPropertyValue ts) propNames+     then map (\(n, ts) → (toK' n) .= [ addValue (fst $ head ts) (parseH settings e) (extractPropertyValue $ head ts) ]) propNames+     else map (\(n, ts) → (toK' n) .= map extractPropertyValue ts) propNames  parseH ∷ Mf2ParserSettings → Element → Value parseH settings e =@@ -114,9 +122,9 @@ parseMf2 ∷ Mf2ParserSettings → Element → Value parseMf2 settings rootEl = object [ "items" .= items, "rels" .= rels, "rel-urls" .= relUrls ]   where items = map (parseH settings') $ deduplicateElements $ rootEl' ^.. cosmos . mf2Elements-        rels = object $ map (\(r, es) → (toK r) .= map snd es) $ groupBy' fst $ expandSnd $ map (\e → (T.split isSpace (e ^. attr "rel"), resolveURI (baseUri settings') $ e ^. attr "href")) linkEls+        rels = object $ map (\(r, es) → (toK' r) .= map snd es) $ groupBy' fst $ expandSnd $ map (\e → (T.split isSpace (e ^. attr "rel"), resolveURI (baseUri settings') $ e ^. attr "href")) linkEls         relUrls = object $ map relUrlObject linkEls-        relUrlObject e = toK (resolveURI (baseUri settings') (e ^. attr "href")) .= object (filter (not . emptyVal . snd) [+        relUrlObject e = toK' (resolveURI (baseUri settings') (e ^. attr "href")) .= object (filter (not . emptyVal . snd) [             "rels" .= T.split isSpace (e ^. attr "rel")           , "text" .= fromMaybe Null (String <$> getInnerTextWithImgs e)           , linkAttr "type" "type" e
microformats2-parser.cabal view
@@ -1,12 +1,12 @@ name:            microformats2-parser-version:         1.0.2.2+version:         1.0.2.3 synopsis:        A Microformats 2 parser. description:     A parser for Microformats 2 (http://microformats.org/wiki/microformats2), a simple way to describe structured information in HTML. category:        Web homepage:        https://codeberg.org/valpackett/microformats2-parser bug-reports:     https://codeberg.org/valpackett/microformats2-parser/issues author:          Val Packett-copyright:       2015-2022 Val Packett <val@packett.cool>+copyright:       2015-2025 Val Packett <val@packett.cool> maintainer:      val@packett.cool license:         PublicDomain license-file:    UNLICENSE@@ -15,7 +15,7 @@ extra-source-files:     README.md tested-with:-    GHC == 9.0.2+    GHC == 9.10.2  source-repository head     type: git