@@ -1013,29 +1013,30 @@ private static string generateCSS(CsvDefinition csvdef, int style_idx)
10131013 if ( style_idx == 0 ) return "" ;
10141014
10151015 // generate CSS
1016- var style_str = @" <style type=""text/css"">
1016+ var style_str = @" <style type=""text/css"">
10171017body {
1018- font-family: Arial, Helvetica, sans-serif;
1019- background: #fff;
1020- color: #000;
1018+ font-family: Arial, Helvetica, sans-serif;
1019+ background: #fff;
1020+ color: #000;
10211021}
10221022
10231023/* Table structure */
10241024.csvlint-table {
1025- border-collapse: collapse;
1025+ border-collapse: collapse;
10261026}
10271027
10281028/* Column headers */
10291029.csvlint-table thead th {
1030- background: #dbeafe;
1031- padding: 8px 12px;
1032- border-bottom: 2px solid #9bbce3;
1030+ background: #dbeafe;
1031+ padding: 8px 12px;
1032+ border-bottom: 2px solid #9bbce3;
10331033}
10341034
10351035/* Table cells */
10361036.csvlint-table td {
1037- padding: 8px 12px;
1038- border-bottom: 1px solid #ddd;
1037+ padding: 8px 12px;
1038+ border-bottom: 1px solid #ddd;
1039+ white-space: nowrap;
10391040}
10401041
10411042/* rows columns */
@@ -1113,7 +1114,7 @@ private static string generateCSS(CsvDefinition csvdef, int style_idx)
11131114 style_str = style_str . Replace ( "solid #9bbce3;\r \n " , "solid #ddd;\r \n " ) ;
11141115
11151116 // update style
1116- style_str = style_str . Replace ( "background : #dbeafe;\r \n " , "" ) ;
1117+ style_str = style_str . Replace ( "\t background : #dbeafe;\r \n " , "" ) ;
11171118 if ( fg_def > 0x808080 ) hl_clr = "#110a00" ;
11181119 style_str = style_str . Replace ( "/* rows columns */" , csscolors ) ;
11191120 break ;
@@ -1142,11 +1143,11 @@ private static string generateCSS(CsvDefinition csvdef, int style_idx)
11421143 // hover highlight, except not for Minimal UI
11431144 if ( style_idx != 1 ) // not Minimal UI
11441145 {
1145- style_str += "\r \n /* Optional hover highlight */\r \n .csvlint-table tbody tr:hover td {\r \n background : " + hl_clr + ";\r \n }" ;
1146+ style_str += "\r \n /* Optional hover highlight */\r \n .csvlint-table tbody tr:hover td {\r \n \t background : " + hl_clr + ";\r \n }\r \n " ;
11461147 }
11471148
11481149 // close tag
1149- style_str += "\r \n </style>\r \n " ;
1150+ style_str += "\t </style>\r \n " ;
11501151
11511152 // return css
11521153 return style_str ;
@@ -1177,7 +1178,7 @@ public static void ConvertToHTML(CsvDefinition csvdef)
11771178 // build HTML table document
11781179 sb . Append ( "<!DOCTYPE html>\r \n <html>\r \n <head>\r \n " ) ;
11791180 sb . Append ( "\t <meta http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >\r \n " ) ;
1180- sb . Append ( string . Format ( "\t <meta name=\" generator\" content=\" CSV Lint {0}\" >\r \n " , Main . GetVersion ( ) ) ) ;
1181+ sb . Append ( string . Format ( "\t <meta name=\" generator\" content=\" {0}\" >\r \n " , comment [ 0 ] ) ) ;
11811182 sb . Append ( string . Format ( "\t <title>{0}</title>\r \n " , TABLE_NAME ) ) ;
11821183
11831184 // css style and colors
@@ -1264,7 +1265,7 @@ public static void ConvertToHTML(CsvDefinition csvdef)
12641265
12651266 for ( var col = 0 ; col < csvdef . Fields . Count ; col ++ )
12661267 {
1267- // format next value, quotes for varchar and datetime
1268+ // next column value
12681269 var colvalue = "" ;
12691270 if ( col < list . Count ) colvalue = list [ col ] ;
12701271
@@ -1283,17 +1284,20 @@ public static void ConvertToHTML(CsvDefinition csvdef)
12831284 if ( Main . Settings . TrimValues ) colvalue = colvalue . Trim ( ) ;
12841285
12851286 // HTML table, display csv values as-is, don't convert date or decimals
1287+ if ( colvalue == "" ) {
1288+ sb . Append ( "\t \t \t <td/>\r \n " ) ; // use <td/> instead of <td></td>
1289+ } else {
1290+ // HTML escape characters
1291+ colvalue = colvalue . Replace ( "&" , "&" ) ; // ampersnd
1292+ colvalue = colvalue . Replace ( "<" , "<" ) ; // less than
1293+ colvalue = colvalue . Replace ( ">" , ">" ) ; // greater than
12861294
1287- // HTML escape characters
1288- colvalue = colvalue . Replace ( "&" , "&" ) ; // ampersnd
1289- colvalue = colvalue . Replace ( "<" , "<" ) ; // less than
1290- colvalue = colvalue . Replace ( ">" , ">" ) ; // greater than
1291-
1292- colvalue = colvalue . Replace ( "\r \n " , "<br/>" ) ; // \n New line
1293- colvalue = colvalue . Replace ( "\n " , "<br/>" ) ; // \n New line
1294- colvalue = colvalue . Replace ( "\r " , "<br/>" ) ; // \r Carriage return
1295+ colvalue = colvalue . Replace ( "\r \n " , "<br/>" ) ; // \r\n Carriage return + New line (win)
1296+ colvalue = colvalue . Replace ( "\n " , "<br/>" ) ; // \n New line (mac/linux)
1297+ colvalue = colvalue . Replace ( "\r " , "<br/>" ) ; // \r Carriage return (old mac)
12951298
1296- sb . Append ( string . Format ( "\t \t \t <td>{0}</td>\r \n " , colvalue ) ) ;
1299+ sb . Append ( string . Format ( "\t \t \t <td>{0}</td>\r \n " , colvalue ) ) ;
1300+ }
12971301 }
12981302
12991303 sb . Append ( "\t \t </tr>\r \n " ) ;
0 commit comments