diff options
author | Bas van Dijk <v.dijk.bas@gmail.com> | 2012-07-16 11:20:23 +0100 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2012-07-16 11:20:23 +0100 |
commit | c84481238ceb7ed49bcfd044c5bf1d9d7136d1e1 (patch) | |
tree | 8a94fde4b32ee7f9118d4f8219faabea1cb3cb35 /utils/hpc | |
parent | cc456b0be3f20a1c1cef4154ae40ac18f4f6711e (diff) | |
download | haskell-c84481238ceb7ed49bcfd044c5bf1d9d7136d1e1.tar.gz |
Write locale character encoding to hpc html report (#5006)
This allows the correct interpretation of Unicode characters by the browser.
Diffstat (limited to 'utils/hpc')
-rw-r--r-- | utils/hpc/HpcMarkup.hs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/utils/hpc/HpcMarkup.hs b/utils/hpc/HpcMarkup.hs index dff6012cb0..bd297828e5 100644 --- a/utils/hpc/HpcMarkup.hs +++ b/utils/hpc/HpcMarkup.hs @@ -13,6 +13,7 @@ import HpcFlags import HpcUtils import System.Directory +import System.IO (localeEncoding) import Data.List import Data.Maybe(fromJust) import Data.Array @@ -79,6 +80,8 @@ markup_main flags (prog:modNames) = do writeFileUsing (dest_dir ++ "/" ++ filename ++ ".html") $ "<html>" ++ + "<head>" ++ + charEncodingTag ++ "<style type=\"text/css\">" ++ "table.bar { background-color: #f25913; }\n" ++ "td.bar { background-color: #60de51; }\n" ++ @@ -87,6 +90,8 @@ markup_main flags (prog:modNames) = do ".dashboard td { border: solid 1px black }\n" ++ ".dashboard th { border: solid 1px black }\n" ++ "</style>\n" ++ + "</head>" ++ + "<body>" ++ "<table class=\"dashboard\" width=\"100%\" border=1>\n" ++ "<tr>" ++ "<th rowspan=2><a href=\"" ++ index_name ++ ".html\">module</a></th>" ++ @@ -110,7 +115,7 @@ markup_main flags (prog:modNames) = do [ modSummary | (_,_,modSummary) <- mods' ]) - ++ "</table></html>\n" + ++ "</table></body></html>\n" writeSummary index_name $ \ (n1,_,_) (n2,_,_) -> compare n1 n2 @@ -130,6 +135,11 @@ markup_main flags (prog:modNames) = do markup_main _ [] = hpcError markup_plugin $ "no .tix file or executable name specified" +charEncodingTag :: String +charEncodingTag = + "<meta http-equiv=\"Content-Type\" " ++ + "content=\"text/html; " ++ "charset=" ++ show localeEncoding ++ "\">" + genHtmlFromMod :: String -> Flags @@ -206,7 +216,10 @@ genHtmlFromMod dest_dir flags tix theFunTotals invertOutput = do let fileName = modName0 ++ ".hs.html" putStrLn $ "Writing: " ++ fileName writeFileUsing (dest_dir ++ "/" ++ fileName) $ - unlines [ "<html><style type=\"text/css\">", + unlines ["<html>", + "<head>", + charEncodingTag, + "<style type=\"text/css\">", "span.lineno { color: white; background: #aaaaaa; border-right: solid white 12px }", if invertOutput then "span.nottickedoff { color: #404040; background: white; font-style: oblique }" @@ -222,7 +235,10 @@ genHtmlFromMod dest_dir flags tix theFunTotals invertOutput = do else "span.decl { font-weight: bold }", "span.spaces { background: white }", "</style>", - "<pre>"] ++ addLines content' ++ "\n</pre>\n</html>\n"; + "</head>", + "<body>", + "<pre>"] ++ addLines content' ++ "\n</pre>\n</body>\n</html>\n"; + modSummary `seq` return (modName0,fileName,modSummary) |