Giter Club home page Giter Club logo

htmlcss's Introduction

HTMLCSS - Lightweight HTML/CSS Library

Version Apache 2.0 Build Coverity Scan Status LGTM Grade LGTM Alerts

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 and metrics 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-2022 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.

htmlcss's People

Contributors

michaelrsweet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

htmlcss's Issues

SVG support

Add support for the W3C's SVG file format, in order to get dimension information for formatting.

win32 support?

Hello!

I just attempted a very basic compilation with cl *.c -Fetesthtmlcss.exe to see how far it would go. Turns out, very far.

The only files conflicting are:

> grep -r unistd .
./common-private.h:#    include <unistd.h>
./font-find.c:#include <unistd.h>
./sha3.c:#include <unistd.h>

common-private.h already does a win32 check. Do you think it would be possible to port the other candidates?

Thanks and kind regards,
Ingwie

How to use it

I suppose that there should be how to use it in DOCUMENTATION.md, however there is not, and I do not know how to use it.

Add support for raster images (GIF, JPEG, PNG)

Add support for raster images (GIF, JPEG, PNG), probably using external libraries and/or a little custom code. The purpose is for getting the dimensions of the images for formatting, not for actual decode.

Support kerning

Right now the hc_font_t API does not expose the kerning information in a font. This should be supported in a future version of the library so that per-character kerning can be applied for formatting (and extents calculations).

Potential ASAN memory leak

Hello,I found a issue with your code(testhtmlcss)

when run with command line(./testhtmlcss --html test.html) and with Vulnerability detector tool ASAN
I could get the message:

==2423395==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1280 byte(s) in 5 object(s) allocated from:
#0 0x7f2fb0cd2961 in realloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98961)
#1 0x40fc89 in hc_create_props /home/software/htmlcss/css-compute.c:2666
#2 0x40fc89 in hcNodeComputeCSSProperties /home/software/htmlcss/css-compute.c:1854

    Direct leak of 160 byte(s) in 5 object(s) allocated from:
#0 0x7f2fb0cd279a in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9879a)
#1 0x43b98a in hcDictNew /home/software/htmlcss/dict.c:161

    Direct leak of 160 byte(s) in 5 object(s) allocated from:
#0 0x7f2fb0cd279a in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9879a)
#1 0x43b121 in hcDictCopy /home/software/htmlcss/dict.c:59

    Indirect leak of 384 byte(s) in 5 object(s) allocated from:
#0 0x7f2fb0cd2961 in realloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98961)
#1 0x43bed4 in hcDictSetKeyValue /home/software/htmlcss/dict.c:237

    Indirect leak of 224 byte(s) in 5 object(s) allocated from:
#0 0x7f2fb0cd279a in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9879a)
#1 0x43b26c in hcDictCopy /home/software/htmlcss/dict.c:66

    SUMMARY: AddressSanitizer: 2208 byte(s) leaked in 25 allocation(s).


you can click [this ](https://github.com/wanghualei2/crash_collect/blob/master/htmlcss/test.html)to get test.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.