1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-30 00:00:16 +01:00
libwebsockets/lib
Andy Green 63d2f844db lhp: Lightweight HTML Parser
Introduce a very lightweight html5 + css2.1+ stateful stream parser, along
the same lines as the lws json and cbor ones.

This is interesting primarily because of just how low-resource it is for
modest css + html, it uses an lwsac to hold the entirity of the css in
memory at once but the html is parsed in chunks without any need to keep
previous chunks around (chunks may be as small as 1 byte).

A user callback receives element entry and exit callbacks with payload and
all attributes parsed out, CSS related to the active element stack is
parsed to provide a list of active css attributes, which takes heap for the
duration of the parsing.

In effect this provides rich information about the html and css state to
the callback, which has the job of producing the layout in a user-defined
way.

As such, there is no DOM in memory at one time, there is only a stack of
active elements like <html><body><div>xxx with their associated attributes
(like class).  So as it is, it does not support DOM modification such as
JS changing elements after parsing, although elements with interesting IDs
could be kept around by the callback.  There is a corresponding tiny and
relatively flat heap usage regardless of html size.

Default CSS is specified as recommended in the CSS 2.1 standard.

Inline <style></style> elements are supported, but not pre-html5 style= in
element attributes, since these are incompatible with strict CSP.

What the attributes should mean on your system, eg, font-size, font-family
etc is left for the user callback to decide, along with how to lay out the
items using the CSS attributes, and render them.

Fixed point 32.32 constants are used (fraction expressed at parts in 100M)
instead of floating point.

If you have presentation needs, even on a constrained display on a
constrained microcontroller, this makes it feasible to use standardized
markup and styling instead of roll your own.
2022-05-04 08:43:26 +01:00
..
core threadpool: improve relationship with LWS_HAVE_PTHREAD_H 2022-04-11 06:53:47 +01:00
core-net validity: fix bad pointer access 2022-05-04 08:43:26 +01:00
cose coverity: 2021-12-1 uplevel fixes 2022-03-15 10:28:09 +00:00
drivers lws_display: SSD1675B 2022-04-10 06:56:12 +01:00
event-libs sspc: refactor to allow different transports 2021-10-08 09:48:41 +01:00
jose base64: improve sanity checking 2022-03-25 08:18:30 +00:00
misc lhp: Lightweight HTML Parser 2022-05-04 08:43:26 +01:00
plat plat: esp32: Remove esp_attr.h file 2022-04-23 07:39:43 +01:00
roles http: compression: fix selection 2022-05-04 08:43:26 +01:00
secure-streams coverity: ss: mqtt: remove needless wsi check 2022-05-04 08:43:14 +01:00
system coverity: reorder NULL check 2022-05-04 08:42:32 +01:00
tls mbedtls: some versions need x509 overallocation 2022-04-23 07:39:43 +01:00
CMakeLists.txt pkgconfig: use appropriate static lib name 2022-03-15 10:28:09 +00:00
README.md cleaning 2020-01-05 22:17:58 +00:00

Library sources layout

Code that goes in the libwebsockets library itself lives down ./lib

Path Sources
lib/core Core lws code related to generic fd and wsi servicing and management
lib/core-net Core lws code that applies only if networking enabled
lib/event-libs Code containing optional event-lib specific adaptations
lib/jose JOSE / JWS / JWK / JWE implementations
lib/misc Code for various mostly optional miscellaneous features
lib/plat Platform-specific adaptation code
lib/roles Code for specific optional wsi roles, eg, http/1, h2, ws, raw, etc
lib/system Code for system-level features, eg, dhcpclient
lib/tls Code supporting the various TLS libraries