module Data.Number.ER.ShowHTML where
import qualified Text.Html as H
import Text.Regex
showHTML ::
(H.HTML t) =>
t -> String
showHTML v =
escapeNewLines $
renderHtmlNoHeader $
H.toHtml v
where
escapeNewLines s =
(subRegex (mkRegex "([^\\])$") s "\\1\\\\")
abovesTable attrs cells =
H.table H.! attrs H.<< (H.aboves $ map (H.td H.<<) cells)
besidesTable attrs cells =
H.table H.! attrs H.<< (H.aboves [H.besides $ map (H.td H.<<) cells])
renderHtmlNoHeader :: H.Html -> String
renderHtmlNoHeader theHtml =
foldr (.) id (map (H.renderHtml' 0)
(H.getHtmlElements theHtml)) "\n"
toHtmlDefault :: (Show a) => a -> H.Html
toHtmlDefault = H.toHtml . show
instance (H.HTML a) => H.HTML (Maybe a) where
toHtml Nothing = H.toHtml $ "[Nothing]"
toHtml (Just a) = H.toHtml a