xhtml-combinators 0.2.1 → 0.2.2
raw patch · 3 files changed
+23/−3 lines, 3 files
Files
- src/Text/XHtmlCombinators/Escape.hs +1/−1
- src/Text/XHtmlCombinators/Render.hs +21/−1
- xhtml-combinators.cabal +1/−1
src/Text/XHtmlCombinators/Escape.hs view
@@ -46,7 +46,7 @@ encode c | Just ent <- I.lookup (fromEnum c) entityMap = T.concat ["&", ent, ";"]- | otherwise = T.pack $ concat ["&#", hex c , ";"]+ | otherwise = T.pack $ concat ["&#x", hex c , ";"] -- | Escaping text intended for places where scripts can be used escapeJavaScript :: Text -> Text
src/Text/XHtmlCombinators/Render.hs view
@@ -12,7 +12,7 @@ ) where import Control.Applicative hiding (empty)-import Data.Foldable+import Data.Foldable hiding (elem) import Data.Functor.Identity import qualified Data.Sequence as Seq @@ -37,12 +37,29 @@ renderNode (TextNode t) = t renderNode (Node name rattrs attrs c)+ | name `elem` validEmptyElements && Seq.null c = T.concat [lt, name, a, b, " />"] | Seq.null c = T.concat [lt, name, a, b, gt, lts, name, gt] | otherwise = T.concat [lt, name, a, b, gt, fold (fmap renderNode c), lts, name, gt] where a = renderAttrs rattrs b = renderAttrs attrs +validEmptyElements :: [Text]+validEmptyElements = [ "area"+ , "base"+ , "basefont"+ , "br"+ , "col"+ , "frame"+ , "hr"+ , "img"+ , "input"+ , "isindex"+ , "link"+ , "meta"+ , "param"+ ]+ -- | Quickly render a xhtml page to text. -- -- This function will render the entire page on a single line, which@@ -61,6 +78,9 @@ -- -- Also, 'Text.XML.Light' will render the document as proper XML, which is -- fine only if you're not trying to pass of your page as text/html.+--+-- It also has a tendency to turn escaped characters back into their unescaped+-- counterparts, so it's probably best to only use this for debugging. renderPrettyT :: (Functor t, Monad t, Content c) => XHtmlT t c -> t Text renderPrettyT page = do content <- renderT page
xhtml-combinators.cabal view
@@ -1,5 +1,5 @@ name: xhtml-combinators-version: 0.2.1+version: 0.2.2 cabal-version: >= 1.2.3 synopsis: Fast and easy to use XHTML combinators. description: