- -> let uri = case (page, fragment) of
- (Just x, Just y) -> mkPageFragmentURI baseURI (fix x) y
- (Just x, Nothing) -> mkPageURI baseURI (fix x)
- (Nothing, Just y) -> nullURI { uriFragment = ('#':y) }
- fix = (\ (x:xs) -> toUpper x : xs) . map (\ c -> if c == ' ' then '_' else c)
- href = uriToString id uri ""
- dLabel = fromMaybe "" page ++ fromMaybe "" (fmap ('#':) fragment)
- label = fromMaybe dLabel text
- in
- ( eelem "a"
- += attr "href" (arr fst >>> mkText)
- += (arr snd >>> mkText)
- ) -< (href, label)
-
-
-formatExternalLink :: (ArrowXml a) => a InlineElement XmlTree
+ → let uri = case (page, fragment) of
+ (Just x, Just y) → mkPageFragmentURI baseURI x y
+ (Just x, Nothing) → mkPageURI baseURI x
+ (Nothing, Just y) → mkFragmentURI y
+ _ → (⊥)
+ dLabel = fromMaybe (∅) page ⊕ maybe (∅) (T.cons '#') fragment
+ label = fromMaybe dLabel text
+ in
+ mkAnchor ⤙ (uri, label)
+
+formatImage ∷ ArrowXml (⇝) ⇒ (URI, InlineElement) ⇝ XmlTree
+formatImage = proc (baseURI, Image src alt)
+ → let uri = case src of
+ Left u → u
+ Right name → mkObjectURI baseURI name
+ href = uriToString id uri ""
+ in
+ ( eelem "img"
+ += sattr "src" href
+ += ( case alt of
+ Just x → sattr "alt" (T.unpack x)
+ Nothing → none
+ )
+ ) ⤛ ()
+
+
+formatExternalLink ∷ ArrowXml (⇝) ⇒ InlineElement ⇝ XmlTree