Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Exposed two versions of renderFragment. One for XML and one for HTML.

  • Loading branch information...
commit 2d8415fe6e4a46e60b821cb22608720fb34f92bc 1 parent 1c2862f
@mightybyte mightybyte authored
View
3  src/Text/XmlHtml.hs
@@ -57,7 +57,8 @@ module Text.XmlHtml (
-- * Rendering
render,
- XML.renderFragment
+ XML.renderXmlFragment,
+ HTML.renderHtmlFragment
) where
------------------------------------------------------------------------------
View
9 src/Text/XmlHtml/HTML/Render.hs
@@ -33,6 +33,15 @@ render e dt ns = byteOrder
------------------------------------------------------------------------------
+-- | Function for rendering HTML nodes without the overhead of creating a
+-- Document structure.
+renderHtmlFragment :: Encoding -> [Node] -> Builder
+renderHtmlFragment _ [] = mempty
+renderHtmlFragment e (n:ns) =
+ firstNode e n `mappend` (mconcat $ map (node e) ns)
+
+
+------------------------------------------------------------------------------
-- | HTML allows & so long as it is not "ambiguous" (i.e., looks like an
-- entity). So we have a special case for that.
escaped :: [Char] -> Encoding -> Text -> Builder
View
10 src/Text/XmlHtml/XML/Render.hs
@@ -24,10 +24,14 @@ render e dt ns = byteOrder
| otherwise = firstNode e (head ns)
`mappend` (mconcat $ map (node e) (tail ns))
+
------------------------------------------------------------------------------
-renderFragment :: Encoding -> [Node] -> Builder
-renderFragment _ [] = mempty
-renderFragment e (n:ns) = firstNode e n `mappend` (mconcat $ map (node e) ns)
+-- | Function for rendering XML nodes without the overhead of creating a
+-- Document structure.
+renderXmlFragment :: Encoding -> [Node] -> Builder
+renderXmlFragment _ [] = mempty
+renderXmlFragment e (n:ns) =
+ firstNode e n `mappend` (mconcat $ map (node e) ns)
------------------------------------------------------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.