diff --git a/c2html.c b/c2html.c index b1287dc..d087b8e 100644 --- a/c2html.c +++ b/c2html.c @@ -456,11 +456,7 @@ static void print_escaped(buff_t *buff, const char *str, long len) long off = j; - while(j < len - && str[j] != '<' - && str[j] != '>' - && str[j] != ' ' - && str[j] != '\t') + while(j < len && str[j] != '<' && str[j] != '>') j += 1; long end = j; @@ -472,14 +468,6 @@ static void print_escaped(buff_t *buff, const char *str, long len) switch(str[j]) { case '<': buff_printf(buff, "<"); break; case '>': buff_printf(buff, ">"); break; - case '\t': buff_printf(buff, "    "); break; - case ' ': - if(j == 0 || j == len-1 || (str[j-1] == ' ' || str[j-1] == '\t')) - buff_printf(buff, " "); - else - buff_printf(buff, " "); - break; - default: assert(0); } @@ -538,17 +526,12 @@ char *c2html(const char *str, long len, _Bool table_mode, const char *class_pref break; case T_SPACE: - if(tokens[i].len == 1) - buff_printf(&buff, " ", 1); - else { - for(int j = 0; j < tokens[i].len; j += 1) - buff_printf(&buff, " "); - } + buff_puts(&buff, str + tokens[i].off, tokens[i].len); break; case T_TAB: for(int j = 0; j < tokens[i].len; j += 1) - buff_printf(&buff, "    "); + buff_printf(&buff, " "); break; case T_KWORD: diff --git a/style.css b/style.css index fa08ab0..cff936e 100644 --- a/style.css +++ b/style.css @@ -42,11 +42,16 @@ } div.c2h-code table td:first-child { + user-select: none; text-align: right; padding: 0 10px; color: hsla(210, 13%, 40%, 0.7); } + div.c2h-code table td:last-child { + white-space: pre; + } + .c2h-comment { color: hsl(221, 12%, 69%); }