@@ -50,10 +50,28 @@ namespace HtmlLib {
5050 void initHtml (std::ostream &str, std::string title) {
5151 escapeText (title);
5252
53- str << " <!DOCTYPE html>\n \
54- <html>\n \
55- <head><title>" << title << " </title></head>\n \
56- <body style='background: white;'>\n <h1>" << title << " </h1>\n " ;
53+ str << R"( <!DOCTYPE html>
54+ <html>
55+ <head>
56+ <title>)" << title << R"( </title>
57+ <style>
58+ body { background-color: white; }
59+ pre { white-space: pre-wrap; }
60+ .checker { background:#C0FF00; }
61+ .ctxLine { color:#000000; }
62+ .infoEvent { color:#808080; }
63+ .infoEventComment { color:#00C0C0; }
64+ .traceEvent { color: #C0C0C0; }
65+ .newDefect { color: #00FF00; }
66+ .parseWarning { color: #FF0000; }
67+ .impFlag { color: #FF0000; font-weight: bold; }
68+ #scanProps { font-family: monospace; }
69+ .oddRow { background-color: #EEE; }
70+ .scanPropName { padding-right: 8px; white-space: nowrap; }
71+ </style>
72+ </head>
73+ <body>
74+ <h1>)" << title << " </h1>\n " ;
5775 }
5876
5977 void writeLink (
@@ -74,7 +92,7 @@ namespace HtmlLib {
7492 }
7593
7694 void initPre (std::ostream &str) {
77- str << " <pre style='white-space: pre-wrap;' >\n " ;
95+ str << " <pre>\n " ;
7896 }
7997
8098 void finalizePre (std::ostream &str) {
@@ -133,7 +151,7 @@ void writeParseWarnings(std::ostream &str, const TScanProps &props) {
133151 const int count = boost::lexical_cast<int >(itCount->second );
134152 const int ratio = boost::lexical_cast<float >(itRatio->second );
135153 if (ratio < parsingRatioThr)
136- str << " <p><b style='color: #FF0000; '>warning:</b> "
154+ str << " <p><b class='parseWarning '>warning:</b> "
137155 " low parsing ratio: " << ratio << " %</p>\n " ;
138156
139157 itCount = props.find (" diffbase-cov-compilation-unit-count" );
@@ -149,12 +167,12 @@ void writeParseWarnings(std::ostream &str, const TScanProps &props) {
149167 const int baseCount = boost::lexical_cast<int >(itCount->second );
150168 const int baseRatio = boost::lexical_cast<float >(itRatio->second );
151169 if (baseRatio < parsingRatioThr && baseRatio < ratio)
152- str << " <p><b style='color: #FF0000; '>warning:</b> "
170+ str << " <p><b class='parseWarning '>warning:</b> "
153171 " low parsing ratio in diff base: "
154172 << baseRatio << " %</p>\n " ;
155173
156174 if (!count || 100 * baseCount / count < parsingOldToNewRatioThr)
157- str << " <p><b style='color: #FF0000; '>warning:</b> "
175+ str << " <p><b class='parseWarning '>warning:</b> "
158176 " low count of parsed units in diff base: "
159177 << baseCount << " </p>\n " ;
160178 }
@@ -169,16 +187,15 @@ void writeScanProps(std::ostream &str, const TScanProps &props) {
169187
170188 HtmlLib::initSection (str, " Scan Properties" );
171189
172- str << " <table style='font-family: monospace; '>\n " ;
190+ str << " <table id='scanProps '>\n " ;
173191 int i = 0 ;
174192
175193 for (TScanProps::const_reference item : props) {
176- const char *trStyle = " " ;
194+ const char *trClass = " " ;
177195 if (++i & 1 )
178- trStyle = " style='background-color: #EEE; '" ;
196+ trClass = " class='oddRow '" ;
179197
180- const char *tdStyle0 = " padding-right: 8px; white-space: nowrap;" ;
181- str << " <tr" << trStyle << " ><td style='" << tdStyle0 << " '>"
198+ str << " <tr" << trClass << " ><td class='scanPropName'>"
182199 << item.first << " </td><td>" << item.second << " </td></tr>\n " ;
183200 }
184201
@@ -445,7 +462,7 @@ void HtmlWriter::Private::writeNewDefWarning(const Defect &def)
445462 return ;
446463
447464 // a newly introduced defect
448- this ->str << " <span style='color: #00FF00; '>[<b>warning:</b> "
465+ this ->str << " <span class='newDefect '>[<b>warning:</b> "
449466 << this ->newDefMsg << " ]</span>" ;
450467}
451468
@@ -456,7 +473,7 @@ void HtmlWriter::handleDef(const Defect &def)
456473 // HTML anchor
457474 d->str << " <a id='def" << ++(d->defCnt ) << " '></a>" ;
458475
459- d->str << " <b>Error: <span style='background: #C0FF00; '>"
476+ d->str << " <b>Error: <span class='checker '>"
460477 << HtmlLib::escapeTextInline (def.checker ) << " </span>" ;
461478
462479 const int cwe = def.cwe ;
@@ -482,7 +499,7 @@ void HtmlWriter::handleDef(const Defect &def)
482499
483500 if (0 < def.imp ) {
484501 // highlight the "imp" flag
485- d->str << " <span style='color: #FF0000; font-weight: bold; '>"
502+ d->str << " <span class='impFlag '>"
486503 " [important]</span>" ;
487504 }
488505
@@ -498,13 +515,13 @@ void HtmlWriter::handleDef(const Defect &def)
498515 switch (evt.verbosityLevel ) {
499516 case 1 :
500517 if (isComment)
501- d->str << " <span style='color: #00C0C0; '>" ;
518+ d->str << " <span class='infoEventComment '>" ;
502519 else
503- d->str << " <span style='color: #808080; '>" ;
520+ d->str << " <span class='infoEvent '>" ;
504521 break ;
505522
506523 case 2 :
507- d->str << " <span style='color: #C0C0C0; '>" ;
524+ d->str << " <span class='traceEvent '>" ;
508525 break ;
509526 }
510527
@@ -543,10 +560,10 @@ void HtmlWriter::handleDef(const Defect &def)
543560 static CtxEventDetector detector;
544561 const bool isCtxLine = detector.isAnyCtxLine (evt);
545562 if (isCtxLine) {
546- const char *color = (detector.isKeyCtxLine (evt))
547- ? " 000000 "
548- : " C0C0C0 " ;
549- d->str << " <span style='color: # " << color << " ; '>" ;
563+ const char *styleClass = (detector.isKeyCtxLine (evt))
564+ ? " ctxLine "
565+ : " traceEvent " ;
566+ d->str << " <span class=' " << styleClass << " '>" ;
550567 }
551568
552569 // translate message text
0 commit comments