\begin{code}
+-- Copyright 2008 the Contributors, as shown in the revision logs.
+-- Licensed under the Apache Public Source License 2.0 ("the License").
+-- You may not use this file except in compliance with the License.
+
module Html
where
import Edu_Berkeley_Sbp_Haskell_SBP
" LI { margin-top: 5px; }\n"++
" body { color: #333333; }\n"++
" blockquote { font-style: italic; width: 100% }\n"++
- " div.warn { border: 1px solid red; background-color: #fbb; color: white; }\n"++
+ " div.warn { border: 1px solid #f44; border-top: 5px solid #f44; background-color: #fbb; color: white; }\n"++
" td.warn { color: black; }\n"++
" div.announce { border: 1px solid green; background-color: #bfb; color: white; }\n"++
" td.announce { color: black; }\n"++
" a:hover { text-decoration: none; border-bottom:1px solid; }\n"++
" table.footer { border-top: silver solid 1px; }\n"++
" span.signature { color: #bbb; }\n"++
- " .signature a:link { color: #bbb; }\n"++
- " .signature a:visited { color: #bbb; }\n"++
+ " .signature a:link { color: #aaf; }\n"++
+ " .signature a:visited { color: #faa; }\n"++
" .signature a:hover { color: blue; border-bottom: 1px solid blue; }\n"++
" span.highlight { background: yellow; color: black; padding: 3px }\n"++
" div.pre {\n"++
" text-align: left;\n"++
" font-family: monospace;\n"++
- " border-style: solid;\n"++
+ " border-style: none;\n"++
" border-width: 2px 2px 2px 2px;\n"++
" border-color: #6666aa;\n"++
" color: #FFFFFF;\n"++
- " background-color: #000000;\n"++
+ " background-color: #333333;\n"++
" margin-right: 25px;\n"++
" margin-left: 25px;\n"++
" padding: 10px;\n"++
toHtml (P t) = stag "p" $ toHtml t
-link ref body = "<a href='"++ref++"'>"++icon++body++"</a>"
+link ref body = "<a href='"++(urlify ref)++"'>"++icon++body++"</a>"
where
+ urlify = toHtml
icon = if ".pdf" `isSuffixOf` ref then "<img "++img++" src='"++pdfIconBase64++"'> "
else if "mailto:" `isPrefixOf` ref then "<img "++img++" src='"++emailIconBase64++"'> "
else ""
toHtml (Quotes x) = "“"++(toHtml x)++"”"
toHtml (Verbatim x) = pre x
toHtml (Link t ref) = link (show ref) (toHtml t)
+ toHtml (Command "comment" y) = ""
toHtml (Command "url" y) = "<tt>"++(link (toHtml y) (toHtml y))++"</tt>"
toHtml (Command "WiX" y) = "W<span style='vertical-align:-20%'>I</span>X"
toHtml (Command "TeX" y) = "T<span style='vertical-align:-20%'>E</span>X"
toHtml (Command "green" y) = "<font color=green>"++(toHtml y)++"</font>"
toHtml (Command "sc" y) = "<sc>"++(toHtml y)++"</sc>"
toHtml (Command "image" y) = "<img src='"++(toHtml y)++"'/>"
+ toHtml (Command "imagec" y) = "<center><img src='"++(toHtml y)++"'/></center>"
+ toHtml (Command "image2" y) = "<img width=180px src='"++(toHtml y)++"'/>"
toHtml (Command "image3" y) = "<img width=200px src='"++(toHtml y)++"'/>"
toHtml (Command "image4" y) = "<center><img width=550px src='"++(toHtml y)++"'/></center>"
toHtml (Command "warn" y) = "\n<div class=warn>\n<table border=0 cellpadding=5px>\n"
toHtml (Command "br" _) = "\n<br/>\n"
toHtml (Command "cent" _) = "½"
toHtml (Command "euro" _) = "€"
- toHtml (Command "ordinal" x) = (toHtml x)++"<sup>"++"th"++"</sup>"
+
+ -- gross hack
+ toHtml (Command "ordinal" x) | (last (toHtml x) == '1') = (toHtml x)++"<sup>"++"st"++"</sup>"
+ | (last (toHtml x) == '2') = (toHtml x)++"<sup>"++"nd"++"</sup>"
+ | (last (toHtml x) == '3') = (toHtml x)++"<sup>"++"rd"++"</sup>"
+ | otherwise = (toHtml x)++"<sup>"++"th"++"</sup>"
+
-- FIXME: use "unicode vulgar fractions" here
toHtml (Command "fraction" [n,d]) = "<sup>"++(toHtml n)++"</sup>"++"/"++"<sub>"++(toHtml d)++"</sub>"
toHtml (Command "rfc" x) = "<tt><a href=http://tools.ietf.org/html/rfc"++(toHtml x)++">RFC"++(toHtml x)++"</a></tt>"
toHtml (GlyphText TradeMark) = "™"
toHtml (GlyphText ServiceMark) = "™"
toHtml (GlyphText Emdash) = "—"
- toHtml (GlyphText Ellipsis) = "…"
+ toHtml (GlyphText Ellipsis) = "…" -- &cdots;?
toHtml (GlyphText Cent) = "½"
toHtml (GlyphText Daggar) = "†"
toHtml (GlyphText DoubleDaggar) = "‡"
toHtml (GlyphText Sharp) = "⋘"
toHtml (GlyphText CheckMark) = "✓"
toHtml (GlyphText XMark) = "✗"
- toHtml (GlyphText LeftArrow) = "&#;" -- FIXME
+ toHtml (GlyphText LeftArrow) = "←"
+ toHtml (GlyphText RightArrow) = "→"
toHtml (GlyphText DoubleLeftArrow) = "&#;" -- FIXME
toHtml (GlyphText DoubleRightArrow) = "&#;" -- FIXME
toHtml (GlyphText DoubleLeftRightArrow) = "&#;" -- FIXME
htmlEscapeChar '\"' = """
htmlEscapeChar c = [c]
-pre x = "\n<div class=pre>"++ (pre' x) ++ "\n</div>\n"
+pre x = "\n<div class=pre style='white-space:nowrap'>"++ (pre' x) ++ "\n</div>\n"
where
pre' (' ':b) = " "++(pre' b)
pre' ('\n':b) = "<br/>\n"++(pre' b)