packages feed

html-entities 1.1.2 → 1.1.3

raw patch · 3 files changed

+32/−4 lines, 3 files

Files

html-entities.cabal view
@@ -1,7 +1,7 @@ name:   html-entities version:-  1.1.2+  1.1.3 synopsis:   A codec library for HTML-escaped text and HTML-entities description:
library/HTMLEntities/Decoder.hs view
@@ -19,6 +19,16 @@   P.htmlEntity <* P.endOfInput  -- |+-- A decoder of a single entity.+-- +-- >>> mapM_ Data.Text.IO.putStrLn $ htmlEntityBody "#169"+-- ©+htmlEntityBody :: Text -> Either String Text+htmlEntityBody =+  P.parseOnly $+  P.htmlEntityBody <* P.endOfInput++-- | -- A decoder of a text with entities. --  -- Produces a text builder, 
library/HTMLEntities/Parser.hs view
@@ -16,15 +16,33 @@ -- >>> mapM_ Data.Text.IO.putStrLn $ Data.Attoparsec.Text.parseOnly htmlEntity "&#169;" -- © -- --- as well as named entities:+-- as well as the named entities: --  -- >>> mapM_ Data.Text.IO.putStrLn $ Data.Attoparsec.Text.parseOnly htmlEntity "&copy;" -- © -- -{-# INLINABLE htmlEntity #-}+{-# INLINE htmlEntity #-} htmlEntity :: Parser Text htmlEntity =-  char '&' *> (numeric <|> named) <* char ';'+  char '&' *> htmlEntityBody <* char ';'++-- |+-- A parser of the body of a single entity.+-- +-- Parses numeric encoding:+-- +-- >>> mapM_ Data.Text.IO.putStrLn $ Data.Attoparsec.Text.parseOnly htmlEntityBody "#169"+-- ©+-- +-- as well as the named entities:+-- +-- >>> mapM_ Data.Text.IO.putStrLn $ Data.Attoparsec.Text.parseOnly htmlEntityBody "copy"+-- ©+-- +{-# INLINABLE htmlEntityBody #-}+htmlEntityBody :: Parser Text+htmlEntityBody =+  numeric <|> named   where     numeric =       Text.singleton . chr <$> (char '#' *> (decimal <|> (char 'x' *> hexadecimal)))