import Control.Arrow
import Control.Arrow.ArrowList
+import Control.Arrow.ArrowTree
import Data.Char
import Data.List
import Data.Maybe
formatWikiBlocks :: (ArrowXml a, ArrowChoice a) => a (URI, [BlockElement]) XmlTree
formatWikiBlocks
= proc (baseURI, blocks)
- -> do block <- arrL id -< blocks
- formatBlock -< (baseURI, block)
+ -> do block <- arrL id -< blocks
+ tree <- formatBlock -< (baseURI, block)
+ attachXHtmlNs -< tree
formatBlock :: (ArrowXml a, ArrowChoice a) => a (URI, BlockElement) XmlTree
Div attrs contents
-> formatElem "div" -< (baseURI, attrs, contents)
+
+ EmptyBlock
+ -> none -< ()
where
formatElem :: (ArrowXml a, ArrowChoice a) =>
String
Anchor attrs contents
-> formatElem "a" -< (baseURI, attrs, contents)
+
+ EmptyInline
+ -> none -< ()
where
formatElem :: (ArrowXml a, ArrowChoice a) =>
String
+= attr "href" (arr fst >>> mkText)
+= (arr snd >>> mkText)
) -< (href, label)
+
+
+attachXHtmlNs :: ArrowXml a => a XmlTree XmlTree
+attachXHtmlNs = processBottomUp (changeQName attach')
+ where
+ attach' :: QName -> QName
+ attach' qn = qn {
+ namePrefix = "xhtml"
+ , namespaceUri = "http://www.w3.org/1999/xhtml"
+ }