# c2html
A tool to add HTML syntax highlighting to C code.
# Installation and usage
c2html comes both as a C library and a command-line utility.
The library only exports one function
```c
char *c2html(const char *str, long len, _Bool table_mode,
const char *class_prefix, const char **error);
```
which, given a string of C code, returns the version highlighted using HTML tags.
For example, lets consider the
```c
/* .. include stdlib.h, string.h and stdio.h .. */
#include "c2html.h"
int main()
{
// Table mode refers to the structure of the output HTML.
// If table_mode is turned off, then the output lines are
// separated by
tags and there are no line numbers.
// Using table mode, then the lines are represented as rows
// of an HTML. The table has a first column with the line
// numbers and the second with their content.
_Bool table_mode = 0;
const char *prefix = NULL;
char *c =
"int main() {\n"
" int a = 5;\n"
" return 0;\n"
"}\n";
char *html = c2html(c, strlen(c), table_mode, prefix, NULL);
printf("%s\n", html);
free(html);
return 0;
}
```
will output:
```
| 1 | int main() { |
| 2 | int a = 5; |
| 3 | return 0; |
| 4 | } |
| 5 |