module Text.HTML.TreeList ( treeList )
where
import Data.Tree
import Data.List

mkHTMLBox :: String -> String -> String
mkHTMLBox cs co = "<table style=\"border: 2px solid orange;\" cellpadding=1 cellspacing=1 border=0 bgcolor=\""++co++"\">"
                  ++"<tr><td>"++(mkHTMLLines cs)++"</td></tr></table>\n"

mkHTMLLines :: String -> String
mkHTMLLines x = intercalate "<br/>" $ lines x

treeList :: Tree String -> String
treeList (Node s xs) = (mkHTMLBox s "lightyellow") ++ (mkList $ map treeList xs)

mkList :: [String] -> String
mkList [] = ""
mkList xs = let lnStart = "<ul>"
                lnIn    = map (\x -> "<li style=\"list-style-type: none;\">"++x++"</li>") xs
                lnEnd   = "</u>"
            in unlines ([lnStart] ++ lnIn ++ [lnEnd])