xml-types-content 0.0.1 → 0.0.1.1
raw patch · 3 files changed
+13/−5 lines, 3 filesdep −text-builder-dev
Dependencies removed: text-builder-dev
Files
- src/hspec/XmlTypesContentSpec.hs +11/−1
- src/library/XmlTypesContent.hs +1/−2
- xml-types-content.cabal +1/−2
src/hspec/XmlTypesContentSpec.hs view
@@ -17,9 +17,19 @@ spec :: Spec spec = do describe "textNodes" do+ it "Properly encodes a control character" do+ let text = "a&b"+ XmlTypesContent.textContents text+ `shouldBe` [ContentText "a", ContentEntity "amp", ContentText "b"]++ it "Properly encodes an undefined character" do+ let text = "a\64976b"+ XmlTypesContent.textContents text+ `shouldBe` [ContentText "a", ContentEntity "#64976", ContentText "b"]+ prop "Produces nodes that decode to the source" do -- For some reason xml-conduit remaps '\r' to '\n', so we simply work around that.- text <- suchThat arbitrary (not . elem '\r' . Text.unpack)+ text <- Text.pack <$> suchThat arbitrary (not . elem '\r') pure case extractTextContentFromXml (textXml text) of Right decodedText -> if decodedText == text
src/library/XmlTypesContent.hs view
@@ -8,7 +8,6 @@ import Data.Text (Text) import qualified Data.Text as Text import Data.XML.Types-import qualified TextBuilderDev import Prelude -- |@@ -41,7 +40,7 @@ codepointDecimalEntityText :: Int -> Text codepointDecimalEntityText codepoint =- TextBuilderDev.fromTextBuilder ("#" <> TextBuilderDev.unsignedDecimal codepoint)+ Text.pack ('#' : show codepoint) charNeedsNoEscaping :: Char -> Bool charNeedsNoEscaping = codepointNeedsNoEscaping . ord
xml-types-content.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: xml-types-content-version: 0.0.1+version: 0.0.1.1 synopsis: Utilities for dealing with Content-values of "xml-types" description: The `Content` type in "xml-types" is tricky and naive usage of it can lead to bugs.@@ -46,7 +46,6 @@ build-depends: base >=4.13 && <5, text >=1.2 && <3,- text-builder-dev ^>=0.3.9, xml-types ^>=0.3.8, test-suite hspec