A lightweight HTML and CSS Parser in C
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
htmlcss.xcodeproj
testsuite
.gitattributes
.gitignore
DOCUMENTATION.md
LICENSE
Makefile
NOTICE
README.md
common-private.h
common.c
common.h
css-compute.c
css-core.c
css-import.c
css-private.h
css-rule.c
css.h
default-css.h
default.css
dict.c
dict.h
file-private.h
file.c
file.h
font-core.c
font-extents.c
font-private.h
font.h
html-attr.c
html-core.c
html-find.c
html-load.c
html-node.c
html-private.h
html.h
htmlcss-128.png
htmlcss-160.png
htmlcss-256.png
htmlcss.h
htmlcss.opacity
pool-private.h
pool.c
pool.h
run.h
sha3.c
sha3.h
testhtmlcss.c
testhtmlcss.html

README.md

HTMLCSS v0.1

HTMLCSS is a lightweight HTML/CSS parser written in C that allows applications to prepare a HTML document for rendering or conversion. HTMLCSS is extremely portable and only requires a C99 compiler like GCC, Clang, Visual C, etc. HTMLCSS is also extremely memory efficient, utilizing a shared string pool and smart CSS cache to minimize the size of a HTML document in memory.

I'm providing HTMLCSS as open source under the Apache License Version 2.0 with exceptions for use with GPL2/LGPL2 applications which allows you do pretty much do whatever you like with it. Please do provide feedback and report bugs to the Github project page so that everyone can benefit.

Features

Features include:

  • HTML 5 markup parser
  • CSS 3 stylesheet parser
  • OFC/OFF/TTC/TTF font file parser (metadata only)
  • GIF/JPG/PNG image file parser (metadata only)
  • Functions to calculate CSS properties for a given node in a HTML document
  • Functions to extract HTML "runs" consisting of CSS properties, content strings, and image references that can be rendered directly, including the :before and :after content from a stylesheet

HTMLCSS does not support dynamic HTML content created using Javascript in a HTML document, as such content is typically used for interactive web pages while HTMLCSS is intended for use with static content.

Requirements

You'll need a C99 compiler like GCC, Clang, or Visual C, along with a POSIX- compliant make program.

Building

Run make to build the library and unit test program.

Installing

Run make install to install the library and header files under /usr/local. To install in a different location, specify the "prefix" variable, e.g.:

make install prefix=/some/other/directory

Using

See the file DOCUMENTATION.md for documentation on using the library.

Legal Stuff

HTMLCSS is Copyright © 2018 by Michael R Sweet.

HTMLCSS is licensed under the Apache License Version 2.0 with an exception to allow linking against GPL2/LGPL2-only software. See the files "LICENSE" and "NOTICE" for more information.