-> case block of
Heading level text
-> formatHeading -< (level, text)
+
+ HorizontalLine
+ -> eelem "hr" -< ()
+
+ List list
+ -> formatListElement -< (baseURI, list)
+
+ DefinitionList list
+ -> formatDefinitionList -< (baseURI, list)
+
+ Preformatted inlines
+ -> formatPreformatted -< (baseURI, inlines)
Paragraph inlines
-> formatParagraph -< (baseURI, inlines)
-> selem ("h" ++ show level) [txt text] -<< ()
+formatListElement :: (ArrowXml a, ArrowChoice a) => a (URI, ListElement) XmlTree
+formatListElement
+ = proc (baseURI, list)
+ -> let tag = case listType list of
+ Bullet -> "ul"
+ Numbered -> "ol"
+ in
+ ( eelem tag
+ += ( (constA baseURI &&& constL (listItems list))
+ >>>
+ formatListItem
+ )
+ ) -<< ()
+ where
+ formatListItem :: (ArrowXml a, ArrowChoice a) => a (URI, ListItem) XmlTree
+ formatListItem
+ = proc (baseURI, item)
+ -> eelem "li"
+ += ( (arr fst &&& arrL snd)
+ >>>
+ formatListItem'
+ ) -< (baseURI, item)
+
+ formatListItem' :: (ArrowXml a, ArrowChoice a) => a (URI, Either ListElement InlineElement) XmlTree
+ formatListItem'
+ = proc (baseURI, x)
+ -> case x of
+ Left nestedList -> formatListElement -< (baseURI, nestedList)
+ Right inline -> formatInline -< (baseURI, inline )
+
+
+formatDefinitionList :: (ArrowXml a, ArrowChoice a) => a (URI, [Definition]) XmlTree
+formatDefinitionList
+ = proc (baseURI, list)
+ -> ( eelem "dl"
+ += ( (arr fst &&& arrL snd)
+ >>>
+ formatDefinition
+ )
+ ) -< (baseURI, list)
+ where
+ formatDefinition :: (ArrowXml a, ArrowChoice a) => a (URI, Definition) XmlTree
+ formatDefinition
+ = proc (baseURI, def)
+ -> ( eelem "dt"
+ += ( (arr fst &&& arrL (defTerm . snd))
+ >>>
+ formatInline
+ )
+ <+>
+ eelem "dd"
+ += ( (arr fst &&& arrL (defDesc . snd))
+ >>>
+ formatInline
+ )
+ ) -< (baseURI, def)
+
+
+formatPreformatted :: (ArrowXml a, ArrowChoice a) => a (URI, [InlineElement]) XmlTree
+formatPreformatted
+ = eelem "pre"
+ += ( (arr fst &&& arrL snd)
+ >>>
+ formatInline
+ )
+
+
formatParagraph :: (ArrowXml a, ArrowChoice a) => a (URI, [InlineElement]) XmlTree
formatParagraph
= eelem "p"
Text text
-> mkText -< text
+ Italic inlines
+ -> ( eelem "i"
+ += ( (arr fst &&& arrL snd)
+ >>>
+ formatInline
+ )
+ ) -< (baseURI, inlines)
+
+ Bold inlines
+ -> ( eelem "b"
+ += ( (arr fst &&& arrL snd)
+ >>>
+ formatInline
+ )
+ ) -< (baseURI, inlines)
+
link@(PageLink _ _ _)
-> formatPageLink -< (baseURI, link)
+ LineBreak attrs
+ -> ( eelem "br"
+ += (arrL id >>> attrFromPair)
+ ) -< attrs
+
+
+attrFromPair :: (ArrowXml a) => a (String, String) XmlTree
+attrFromPair = proc (name, value)
+ -> attr name (txt value) -<< ()
+
formatPageLink :: (ArrowXml a) => a (URI, InlineElement) XmlTree
formatPageLink