commit ghc-blaze-markup for openSUSE:Factory
Hello community, here is the log from the commit of package ghc-blaze-markup for openSUSE:Factory checked in at 2014-11-26 20:55:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-blaze-markup (Old) and /work/SRC/openSUSE:Factory/.ghc-blaze-markup.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "ghc-blaze-markup" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-blaze-markup/ghc-blaze-markup.changes 2014-04-02 17:18:45.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-blaze-markup.new/ghc-blaze-markup.changes 2014-11-26 20:55:29.000000000 +0100 @@ -1,0 +2,8 @@ +Sun Nov 9 15:45:37 UTC 2014 - peter.trommler@ohm-hochschule.de + +- update to 0.6.1.1 +* Bump `text` dependency to allow 1.2 (Haskell Platform 2014.2.0.0) +* Add the `null` query to Text.Blaze.Internal. +* Add the operator (!?) for nicely setting conditional attributes + +------------------------------------------------------------------- Old: ---- blaze-markup-0.5.1.5.tar.gz New: ---- blaze-markup-0.6.1.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-blaze-markup.spec ++++++ --- /var/tmp/diff_new_pack.DuBxR0/_old 2014-11-26 20:55:30.000000000 +0100 +++ /var/tmp/diff_new_pack.DuBxR0/_new 2014-11-26 20:55:30.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package ghc-blaze-markup # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %global pkg_name blaze-markup Name: ghc-blaze-markup -Version: 0.5.1.5 +Version: 0.6.1.1 Release: 0 Summary: A blazingly fast markup combinator library for Haskell License: BSD-3-Clause ++++++ blaze-markup-0.5.1.5.tar.gz -> blaze-markup-0.6.1.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blaze-markup-0.5.1.5/CHANGELOG new/blaze-markup-0.6.1.1/CHANGELOG --- old/blaze-markup-0.5.1.5/CHANGELOG 1970-01-01 01:00:00.000000000 +0100 +++ new/blaze-markup-0.6.1.1/CHANGELOG 2014-09-11 11:09:18.000000000 +0200 @@ -0,0 +1,12 @@ +- 0.6.1.1 + * Bump `text` dependency to allow 1.2 + +- 0.6.1.0 + * Add the `null` query to Text.Blaze.Internal. + +- 0.6.0.0 + * Add the operator (!?) for nicely setting conditional attributes + +- 0.5.2.0 + * Provide ToHtml and ToValue instances for Int32, Int64, Word, Word32, + and Word64 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blaze-markup-0.5.1.5/blaze-markup.cabal new/blaze-markup-0.6.1.1/blaze-markup.cabal --- old/blaze-markup-0.5.1.5/blaze-markup.cabal 2013-03-08 17:18:29.000000000 +0100 +++ new/blaze-markup-0.6.1.1/blaze-markup.cabal 2014-09-11 11:09:18.000000000 +0200 @@ -1,5 +1,5 @@ Name: blaze-markup -Version: 0.5.1.5 +Version: 0.6.1.1 Homepage: http://jaspervdj.be/blaze Bug-Reports: http://github.com/jaspervdj/blaze-markup/issues License: BSD3 @@ -18,6 +18,9 @@ Build-type: Simple Cabal-version: >= 1.8 +Extra-source-files: + CHANGELOG + Library Hs-source-dirs: src Ghc-Options: -Wall @@ -33,7 +36,7 @@ Build-depends: base >= 4 && < 5, blaze-builder >= 0.2 && < 0.4, - text >= 0.10 && < 0.12, + text >= 0.10 && < 1.3, bytestring >= 0.9 && < 0.11 Test-suite blaze-markup-tests @@ -48,7 +51,7 @@ Build-depends: HUnit >= 1.2 && < 1.3, - QuickCheck >= 2.4 && < 2.7, + QuickCheck >= 2.4 && < 2.8, containers >= 0.3 && < 0.6, test-framework >= 0.4 && < 0.9, test-framework-hunit >= 0.3 && < 0.4, @@ -56,7 +59,7 @@ -- Copied from regular dependencies... base >= 4 && < 5, blaze-builder >= 0.2 && < 0.4, - text >= 0.10 && < 0.12, + text >= 0.10 && < 1.3, bytestring >= 0.9 && < 0.11 Source-repository head diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blaze-markup-0.5.1.5/src/Text/Blaze/Internal.hs new/blaze-markup-0.6.1.1/src/Text/Blaze/Internal.hs --- old/blaze-markup-0.5.1.5/src/Text/Blaze/Internal.hs 2013-03-08 17:18:29.000000000 +0100 +++ new/blaze-markup-0.6.1.1/src/Text/Blaze/Internal.hs 2014-09-11 11:09:18.000000000 +0200 @@ -53,14 +53,20 @@ -- * Setting attributes , Attributable , (!) + , (!?) -- * Modifying Markup elements , contents , external + + -- * Querying Markup elements + , null ) where +import Prelude hiding (null) import Data.Monoid (Monoid, mappend, mempty, mconcat) import Unsafe.Coerce (unsafeCoerce) +import qualified Data.List as List import Data.ByteString.Char8 (ByteString) import Data.Text (Text) @@ -412,6 +418,19 @@ h ! f = (! f) . h {-# INLINE (!) #-} +-- | Shorthand for setting an attribute depending on a conditional. +-- +-- Example: +-- +-- > p !? (isBig, A.class "big") $ "Hello" +-- +-- Gives the same result as: +-- +-- > (if isBig then p ! A.class "big" else p) "Hello" +-- +(!?) :: Attributable h => h -> (Bool, Attribute) -> h +(!?) h (c, a) = if c then h ! a else h + -- | Mark HTML as external data. External data can be: -- -- * CSS data in a @<style>@ tag; @@ -449,3 +468,29 @@ contents (AddAttribute _ _ _ c) = contents c contents (AddCustomAttribute _ _ c) = contents c contents _ = Empty + +-- | Check if a 'Markup' value is completely empty (renders to the empty +-- string). +null :: MarkupM a -> Bool +null markup = case markup of + Parent _ _ _ _ -> False + CustomParent _ _ -> False + Leaf _ _ _ -> False + CustomLeaf _ _ -> False + Content c -> emptyChoiceString c + Append c1 c2 -> null c1 && null c2 + AddAttribute _ _ _ c -> null c + AddCustomAttribute _ _ c -> null c + Empty -> True + where + emptyChoiceString cs = case cs of + Static ss -> emptyStaticString ss + String s -> List.null s + Text t -> T.null t + ByteString bs -> B.null bs + PreEscaped c -> emptyChoiceString c + External c -> emptyChoiceString c + AppendChoiceString c1 c2 -> emptyChoiceString c1 && emptyChoiceString c2 + EmptyChoiceString -> True + + emptyStaticString = B.null . getUtf8ByteString diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blaze-markup-0.5.1.5/src/Text/Blaze.hs new/blaze-markup-0.6.1.1/src/Text/Blaze.hs --- old/blaze-markup-0.5.1.5/src/Text/Blaze.hs 2013-03-08 17:18:29.000000000 +0100 +++ new/blaze-markup-0.6.1.1/src/Text/Blaze.hs 2014-09-11 11:09:18.000000000 +0200 @@ -60,12 +60,15 @@ -- * Setting attributes , (!) + , (!?) -- * Modifiying Markup trees , contents ) where import Data.Monoid (mconcat) +import Data.Int (Int32, Int64) +import Data.Word (Word, Word32, Word64) import Data.Text (Text) import qualified Data.Text.Lazy as LT @@ -115,6 +118,14 @@ toMarkup = string . show {-# INLINE toMarkup #-} +instance ToMarkup Int32 where + toMarkup = string . show + {-# INLINE toMarkup #-} + +instance ToMarkup Int64 where + toMarkup = string . show + {-# INLINE toMarkup #-} + instance ToMarkup Char where toMarkup = string . return {-# INLINE toMarkup #-} @@ -135,6 +146,18 @@ toMarkup = string . show {-# INLINE toMarkup #-} +instance ToMarkup Word where + toMarkup = string . show + {-# INLINE toMarkup #-} + +instance ToMarkup Word32 where + toMarkup = string . show + {-# INLINE toMarkup #-} + +instance ToMarkup Word64 where + toMarkup = string . show + {-# INLINE toMarkup #-} + -- | Class allowing us to use a single function for attribute values -- class ToValue a where @@ -174,6 +197,14 @@ toValue = stringValue . show {-# INLINE toValue #-} +instance ToValue Int32 where + toValue = stringValue . show + {-# INLINE toValue #-} + +instance ToValue Int64 where + toValue = stringValue . show + {-# INLINE toValue #-} + instance ToValue Char where toValue = stringValue . return {-# INLINE toValue #-} @@ -193,3 +224,15 @@ instance ToValue Double where toValue = stringValue . show {-# INLINE toValue #-} + +instance ToValue Word where + toValue = stringValue . show + {-# INLINE toValue #-} + +instance ToValue Word32 where + toValue = stringValue . show + {-# INLINE toValue #-} + +instance ToValue Word64 where + toValue = stringValue . show + {-# INLINE toValue #-} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/blaze-markup-0.5.1.5/tests/Text/Blaze/Tests.hs new/blaze-markup-0.6.1.1/tests/Text/Blaze/Tests.hs --- old/blaze-markup-0.5.1.5/tests/Text/Blaze/Tests.hs 2013-03-08 17:18:29.000000000 +0100 +++ new/blaze-markup-0.6.1.1/tests/Text/Blaze/Tests.hs 2014-09-11 11:09:18.000000000 +0200 @@ -1,16 +1,17 @@ {-# LANGUAGE OverloadedStrings, FlexibleInstances, TypeSynonymInstances #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} +{-# OPTIONS_GHC -fno-warn-orphans #-} +{-# OPTIONS_GHC -fno-warn-unused-do-bind #-} module Text.Blaze.Tests ( tests ) where -import Prelude hiding (div, id) -import Data.Monoid (mempty) +import Prelude hiding (div, id, null) +import Data.Monoid (mempty, mappend) import Control.Monad (replicateM) import Control.Applicative ((<$>)) import Data.Word (Word8) import Data.Char (ord) -import Data.List (isInfixOf) +import qualified Data.List as List import Test.Framework (Test) import Test.HUnit (Assertion, (@=?)) @@ -35,7 +36,10 @@ , testProperty "well nested <>" wellNestedBrackets , testProperty "unsafeByteString id" unsafeByteStringId + , testCase "conditional attributes" conditionalAttributes , testCase "contents 1" contents1 + , testCase "empty 1" empty1 + , testCase "empty 2" empty2 ] -- | The left identity Monoid law. @@ -100,7 +104,7 @@ -- | Check if the "</" sequence does not appear in @<script>@ or @<style>@ tags. -- externalEndSequence :: String -> Bool -externalEndSequence = not . isInfixOf "</" . LBC.unpack +externalEndSequence = not . List.isInfixOf "</" . LBC.unpack . renderUsingUtf8 . external . string -- | Check that the "<>" characters are well-nested. @@ -114,6 +118,14 @@ '>' -> if isOpen then wellNested False xs else False _ -> wellNested isOpen xs +conditionalAttributes :: Assertion +conditionalAttributes = + "<p class=\"foo\">Hello</p><p id=\"2nd\">World</p>" @=? renderUsingUtf8 html + where + html = do + p !? (4 > length [()], class_ "foo") $ "Hello" + p !? (List.null [()], class_ "bar") !? (True, id "2nd") $ "World" + contents1 :: Assertion contents1 = "Hello World!" @=? renderUsingUtf8 (contents html) where @@ -123,6 +135,21 @@ img ! name "An image" p "World!" +empty1 :: Assertion +empty1 = True @=? null html + where + html :: Markup + html = do + "" + "" + mempty + +empty2 :: Assertion +empty2 = False @=? null html + where + html :: Markup + html = "" `mappend` "" `mappend` p "a" + -- Show instance for the HTML type, so we can debug. -- instance Show Markup where @@ -148,7 +175,7 @@ -- arbitraryMarkup :: Int -- ^ Maximum depth. -> Gen Markup -- ^ Resulting arbitrary HTML snippet. -arbitraryMarkup depth = do +arbitraryMarkup depth = do -- Choose the size (width) of this element. size <- choose (0, 3) -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org
participants (1)
-
root@hilbert.suse.de