Home

Awesome

This project is not maintained anymore.

Build status

modest_html

This library wraps functionality of lexborisovs Modest. It is written in in pure C99 and exposes a lot of useful features to parse and manipulate a html DOM. Internally it makes use of rxis excellent vec, map and dmt libraries.

Modest is a fast HTML renderer implemented as a pure C99 library with no outside dependencies.

Current Version

2.0.1

Example

For more examples please checkout tests.

#include "modest_html.h"
/*
modest_html is build around a workspace struct.
The workspace holds all allocated memory and frees it in html_destroy().
*/
html_workspace_t *w = html_init();

// parse some html
const char *html = "<p>Hello</p><p>World</p>";
int tree_index = html_parse_tree(w, html, strlen(html));

// serialize the tree into a buffer
int buffer_index = html_serialize_tree(w, tree_index, "body");

// get buffer and join into a string
html_vec_str_t *buffer = html_get_buffer(w, buffer_index);
char* result = html_vec_str_join(buffer, "");
printf("%s\n", result);

// test result
if(result != NULL && strcmp(result, "<body><p>Hello</p><p>World</p></body>") != 0){
  fprintf(stderr, "Failed\n");
  html_free(result);
  html_destroy(w);
  return false;
}

// free result
html_free(result);

// destroy our workspace
html_destroy(w);

return true;

Dependencies

cmake 3.x

Compile and test

The script compiles Modest and configures the library.

./configure

Build libmodest_html.a into build/.

cd build
make

Execute tests.

make test

Check for leaks.

valgrind --leak-check=yes test/example_test

Cloning

git clone git@github.com:f34nk/modest_html.git
cd modest_html

All dependencies are added as submodules in the libs/ folder.

git submodule update --init --recursive --remote

Roadmap

See CHANGELOG.

License

modest_html is under LGPL license. Check the LICENSE file for more details.