{-
Functions to parse and render the HTML/CSS code.
Copyright (C) 2007, 2008 Luis Francisco Araujo
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-}
module Render (render, htmltemp)
where
import Util
import Data.Char
(isSpace)
csstemplate, htmltemp :: FilePath
csstemplate = "/usr/share/doc/himerge-" ++ hversion ++ "/himerge.css"
htmltemp = "hweb.html"
render :: String -> String
render = html . concatMap body . splitPackages
. lines . cleanOutput
html :: String -> String
html contents = "\n\n"
++ ""
++ "\n"
++ contents ++ "\n
himerge\n\n"
body :: [String] -> String
body [] = []
body (('*':' ':xs):xss) = "
"
++ xs ++ "
\n
"
++ makeMenu xss
body ((y@('[':_)):xss) = "overlay: " ++ y ++ " " ++ makeMenu xss
body (_:xss) = body xss
makeMenu :: [String] -> String
makeMenu xs@(('[':_):_) = body xs -- check for overlays.
makeMenu ys = concatMap menu ys ++ "
"
where
menu xs = let (label, value) = (break (== ':') xs)
in
if null value
then label
else "