--- 複數の Inline を一つに纏める
-packParagraph :: [WikiElement] -> [Either BlockElement [InlineElement]]
-packParagraph elems = map pack grp
- where
- grp :: [[WikiElement]]
- grp = groupBy criteria elems
-
- criteria :: WikiElement -> WikiElement -> Bool
- criteria (Inline _) (Inline _) = True
- criteria _ _ = False
-
- pack :: [WikiElement] -> Either BlockElement [InlineElement]
- pack (Block b : []) = Left b
- pack xs = Right [ case x of
- Inline i -> i | x <- xs ]
-
-
-formatWikiElements :: (ArrowXml a, ArrowChoice a) => a (URI, [WikiElement]) XmlTree
-formatWikiElements
- = proc (baseURI, elems)
- -> do chunk <- arrL id -< packParagraph elems
- case chunk of
- Left x -> formatBlock -< x
- Right xs -> formatParagraph -< (baseURI, xs)
+formatWikiBlocks :: (ArrowXml a, ArrowChoice a) => a (URI, [BlockElement]) XmlTree
+formatWikiBlocks
+ = proc (baseURI, blocks)
+ -> do block <- arrL id -< blocks
+ formatBlock -< (baseURI, block)