more docs

This commit is contained in:
cozis
2022-05-05 19:38:13 +02:00
parent 8dd480e43b
commit f9b5a66b87
2 changed files with 7 additions and 32 deletions
+7
View File
@@ -56,6 +56,13 @@ The HTML comes with no styling. If you want to apply a CSS to it, you can provid
This will basically add a `<style>` element with the contents of the `style.css` file before the normal HTML output. This will basically add a `<style>` element with the contents of the `style.css` file before the normal HTML output.
### --prefix
By the fault, all of the HTML class names are prefixed with `c2h-` to avoid namespace collisions. You can change the prefix using the `--prefix` option, like this:
```sh
./c2html --input file.c --output file.html --prefix myprefix-
```
in which case, identifiers will be generated with the `myprefix-identifier` class name instead of the usual `c2h-identifier`.
## Using the library ## Using the library
The library only exports one function The library only exports one function
```c ```c
-32
View File
@@ -1,32 +0,0 @@
// Build with: gcc example.c c2html.c -o example -Wall -Wextra
#include <stdlib.h>
#include <string.h>
#include <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 <br /> 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);
/* .. check for errors .. */
printf("%s\n", html);
free(html);
return 0;
}