src/c2html.c

changeset 30
0bfd4d6f086a
parent 27
53fd8595378c
child 35
abaf2489c549
equal deleted inserted replaced
29:ec6e97454e64 30:0bfd4d6f086a
156 } 156 }
157 WRITECONST(stream, out, "<pre>\n"); 157 WRITECONST(stream, out, "<pre>\n");
158 158
159 int lnw = lnint(in->count); 159 int lnw = lnint(in->count);
160 for (int i = 0 ; i < in->count ; i++) { 160 for (int i = 0 ; i < in->count ; i++) {
161 char *ln = line;
162 if (highlighter) { 161 if (highlighter) {
163 highlighter->parser(in->lines[i], line, highlighter); 162 highlighter->parser(in->lines[i], line, highlighter);
164 } else { 163 } else {
165 ln = in->lines[i]; 164 char *c = in->lines[i];
166 } 165 size_t dp = 0;
167 166 while (*c) {
167 dp = writeescapedchar(line, dp, *c);
168 c++;
169 }
170 line[dp] = '\0';
171 }
172
168 // write line number 173 // write line number
169 if (showln) { 174 if (showln) {
170 WRITECONST(stream, out, "<span class=\"c2html-lineno\">"); 175 WRITECONST(stream, out, "<span class=\"c2html-lineno\">");
171 char lnbuf[128]; 176 char lnbuf[128];
172 int len; 177 int len;
179 out(lnbuf, 1, len, stream); 184 out(lnbuf, 1, len, stream);
180 WRITECONST(stream, out, "</a></span> "); 185 WRITECONST(stream, out, "</a></span> ");
181 } 186 }
182 187
183 // write formated (or plain) code line 188 // write formated (or plain) code line
184 out(ln, 1, strlen(ln), stream); 189 out(line, 1, strlen(line), stream);
185 } 190 }
186 191
187 WRITECONST(stream, out, "</pre>\n"); 192 WRITECONST(stream, out, "</pre>\n");
188 free(line); 193 free(line);
189 return 0; 194 return 0;

mercurial