blaze-markup-0.8.0.0/0000755000000000000000000000000013043667100012435 5ustar0000000000000000blaze-markup-0.8.0.0/Setup.hs0000644000000000000000000000005613043667100014072 0ustar0000000000000000import Distribution.Simple main = defaultMain blaze-markup-0.8.0.0/CHANGELOG0000644000000000000000000000207013043667100013646 0ustar0000000000000000# Changelog - 0.8.0.0 (2017-01-30) * Make `MarkupM` finally adhere to the Monad laws * Stricten the `IsString` instance to only work with `MarkupM ()` and not `MarkupM a` * Change the type of `contents` to `MarkupM a -> MarkupM a` * Add a `Semigroup` instance for `MarkupM` - 0.7.1.1 * Bump `HUnit` dependency to allow 1.5 - 0.7.1.0 * Relax `QuickCheck` dependency to allow 2.9 * Add text builder instances - 0.7.0.3 * Relax `HUnit` dependency to allow 1.3 - 0.7.0.2 * Relax `blaze-builder` dependency to allow 0.3 - 0.7.0.1 * Bump `QuickCheck` dependency to allow 2.8 - 0.7.0.0 * Depend on blaze-builder 0.4 - 0.6.3.0 * Add combinators to insert HTML comments - 0.6.2.0 * Add `Applicative` instance for `MarkupM` - 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 blaze-markup-0.8.0.0/blaze-markup.cabal0000644000000000000000000000361013043667100016013 0ustar0000000000000000Name: blaze-markup Version: 0.8.0.0 Homepage: http://jaspervdj.be/blaze Bug-Reports: http://github.com/jaspervdj/blaze-markup/issues License: BSD3 License-file: LICENSE Author: Jasper Van der Jeugt, Simon Meier, Deepak Jois Maintainer: Jasper Van der Jeugt Stability: Experimental Category: Text Synopsis: A blazingly fast markup combinator library for Haskell Description: Core modules of a blazingly fast markup combinator library for the Haskell programming language. The Text.Blaze module is a good starting point, as well as this tutorial: . Build-type: Simple Cabal-version: >= 1.8 Extra-source-files: CHANGELOG Library Hs-source-dirs: src Ghc-Options: -Wall Exposed-modules: Text.Blaze Text.Blaze.Internal Text.Blaze.Renderer.Pretty Text.Blaze.Renderer.String Text.Blaze.Renderer.Text Text.Blaze.Renderer.Utf8 Build-depends: base >= 4 && < 5, blaze-builder >= 0.3 && < 0.5, text >= 0.10 && < 1.3, bytestring >= 0.9 && < 0.11 Test-suite blaze-markup-tests Type: exitcode-stdio-1.0 Hs-source-dirs: src tests Main-is: TestSuite.hs Ghc-options: -Wall Other-modules: Text.Blaze.Tests Text.Blaze.Tests.Util Build-depends: HUnit >= 1.2 && < 1.6, QuickCheck >= 2.4 && < 2.10, containers >= 0.3 && < 0.6, test-framework >= 0.4 && < 0.9, test-framework-hunit >= 0.3 && < 0.4, test-framework-quickcheck2 >= 0.3 && < 0.4, -- Copied from regular dependencies... base >= 4 && < 5, blaze-builder >= 0.3 && < 0.5, text >= 0.10 && < 1.3, bytestring >= 0.9 && < 0.11 Source-repository head Type: git Location: http://github.com/jaspervdj/blaze-markup blaze-markup-0.8.0.0/LICENSE0000644000000000000000000000277513043667100013455 0ustar0000000000000000Copyright Jasper Van der Jeugt 2010 All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Jasper Van der Jeugt nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. blaze-markup-0.8.0.0/tests/0000755000000000000000000000000013043667100013577 5ustar0000000000000000blaze-markup-0.8.0.0/tests/TestSuite.hs0000644000000000000000000000035513043667100016067 0ustar0000000000000000-- | Main module to run all tests. -- module Main where import Test.Framework (defaultMain, testGroup) import qualified Text.Blaze.Tests main :: IO () main = defaultMain [ testGroup "Text.Blaze.Tests" Text.Blaze.Tests.tests ] blaze-markup-0.8.0.0/tests/Text/0000755000000000000000000000000013043667100014523 5ustar0000000000000000blaze-markup-0.8.0.0/tests/Text/Blaze/0000755000000000000000000000000013043667100015560 5ustar0000000000000000blaze-markup-0.8.0.0/tests/Text/Blaze/Tests.hs0000644000000000000000000001715313043667100017225 0ustar0000000000000000{-# LANGUAGE OverloadedStrings, FlexibleInstances, TypeSynonymInstances #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-unused-do-bind #-} module Text.Blaze.Tests ( tests ) where import Prelude hiding (div, id, null) import Data.Monoid (mempty, mappend) import Control.Monad (replicateM) import Control.Applicative (Applicative (..), (<$>)) import Data.Word (Word8) import Data.Char (ord, isControl) import qualified Data.List as List import qualified Prelude as Prelude import Test.Framework (Test) import Test.HUnit (Assertion, (@=?)) import Test.Framework.Providers.HUnit (testCase) import Test.Framework.Providers.QuickCheck2 (testProperty) import Test.QuickCheck import qualified Data.ByteString as SB import qualified Data.ByteString.Lazy as LB import qualified Data.ByteString.Lazy.Char8 as LBC import Text.Blaze import Text.Blaze.Internal import Text.Blaze.Tests.Util tests :: [Test] tests = [ testProperty "left identity Monoid law" monoidLeftIdentity , testProperty "right identity Monoid law" monoidRightIdentity , testProperty "associativity Monoid law" monoidAssociativity , testProperty "mconcat Monoid law" monoidConcat , testProperty "identity Applicative law" applicativeIdentity , testProperty "post escaping characters" postEscapingCharacters , testProperty "valid UTF-8" isValidUtf8 , testProperty "external " wellNestedBrackets , testProperty "unsafeByteString id" unsafeByteStringId , testCase "conditional attributes" conditionalAttributes , testCase "contents 1" contents1 , testCase "empty 1" empty1 , testCase "empty 2" empty2 , testCase "comment 1" comment1 ] -- | The left identity Monoid law. -- monoidLeftIdentity :: Markup -> Bool monoidLeftIdentity h = (return () >> h) == h -- | The right identity Monoid law. -- monoidRightIdentity :: Markup -> Bool monoidRightIdentity h = (h >> return ()) == h -- | The associativity Monoid law. -- monoidAssociativity :: Markup -> Markup -> Markup -> Bool monoidAssociativity x y z = (x >> (y >> z)) == ((x >> y) >> z) -- | Concatenation Monoid law. -- monoidConcat :: [Markup] -> Bool monoidConcat xs = sequence_ xs == foldr (>>) (return ()) xs -- | Applicative identity law. -- applicativeIdentity :: Markup -> Bool applicativeIdentity x = (pure Prelude.id <*> x) == x -- | Escaped content cannot contain certain characters. -- postEscapingCharacters :: String -> Bool postEscapingCharacters str = LB.all (`notElem` forbidden) $ renderUsingUtf8 (string str) where forbidden = map (fromIntegral . ord) "\"'<>" -- | Check if the produced bytes are valid UTF-8 -- isValidUtf8 :: Markup -> Bool isValidUtf8 = isValidUtf8' . LB.unpack . renderUsingUtf8 where isIn x y z = (x <= z) && (z <= y) isValidUtf8' :: [Word8] -> Bool isValidUtf8' [] = True isValidUtf8' (x:t) -- One byte | isIn 0x00 0x7f x = isValidUtf8' t -- Two bytes | isIn 0xc0 0xdf x = case t of (y:t') -> isIn 0x80 0xbf y && isValidUtf8' t' _ -> False -- Three bytes | isIn 0xe0 0xef x = case t of (y:z:t') -> all (isIn 0x80 0xbf) [y, z] && isValidUtf8' t' _ -> False -- Four bytes | isIn 0xf0 0xf7 x = case t of (y:z:u:t') -> all (isIn 0x80 0xbf) [y, z, u] && isValidUtf8' t' _ -> False | otherwise = False -- | Rendering an unsafe bytestring should not do anything -- unsafeByteStringId :: [Word8] -> Bool unsafeByteStringId ws = LB.pack ws == renderUsingUtf8 (unsafeByteString $ SB.pack ws) -- | Check if the "@ or @