- | 1 | int main() { |
- | 2 | int a = 5; |
- | 3 | return 0; |
+ | 1 | int main() { |
+ | 2 | int a = 5; |
+ | 3 | return 0; |
| 4 | } |
| 5 | |
diff --git a/c2html.c b/c2html.c
index b5c8215..6c2ff57 100644
--- a/c2html.c
+++ b/c2html.c
@@ -350,7 +350,12 @@ static void print_escaped(buff_t *buff, const char *str, long len)
long off = j;
- while(j < len && str[j] != '<' && str[j] != '>')
+ while(j < len
+ && str[j] != '<'
+ && str[j] != '>'
+ && str[j] != ' '
+ && str[j] != '\n'
+ && str[j] != '\t')
j += 1;
long end = j;
@@ -359,11 +364,22 @@ static void print_escaped(buff_t *buff, const char *str, long len)
if(j == len)
break;
- assert(str[j] == '<' || str[j] == '>');
- if(str[j] == '<')
- buff_printf(buff, "<");
- else
- buff_printf(buff, ">");
+ switch(str[j]) {
+ case '<': buff_printf(buff, "<"); break;
+ case '>': buff_printf(buff, ">"); break;
+ case '\n': buff_printf(buff, "
"); break;
+ case '\t': buff_printf(&buff, " "); break;
+
+ case ' ':
+ if(j == 0 || str[j-1] != ' ')
+ buff_printf(buff, " ");
+ else
+ buff_printf(buff, " ");
+ break;
+
+ default: assert(0);
+ }
+
j += 1;
}
}