Packages

Gleam bindings to htmerl, the fast and memory efficient Erlang HTML SAX parser.

Current section

Files

Jump to
htmgrrrl src htmgrrrl.erl
Raw

src/htmgrrrl.erl

-module(htmgrrrl).
-compile([no_auto_import, nowarn_ignored, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-export([sax/3]).
-export_type([sax_event/0, attribute/0]).
-type sax_event() :: start_document | end_document | {start_prefix_mapping, binary(), binary()} | {end_prefix_mapping, binary()} | {start_element, binary(), binary(), {binary(), binary()}, list(attribute())} | {end_element, binary(), binary(), {binary(), binary()}} | {characters, binary()} | {ignorable_whitespace, binary()} | {processing_instruction, binary(), binary()} | {comment, binary()} | start_cdata | end_cdata | {start_dtd, binary(), binary(), binary()} | end_dtd | {element_decl, binary(), binary()} | {attribute_declaration, binary(), binary(), binary(), binary(), binary()} | {internal_entity_declaration, binary(), binary()} | {external_entity_declaration, binary(), binary(), binary()} | {unparsed_entity_declaration, binary(), binary(), binary(), binary()} | {notation_declaration, binary(), binary(), binary()}.
-type attribute() :: {attribute, binary(), binary(), binary(), binary()}.
-file("src/htmgrrrl.gleam", 125).
-spec sax(binary(), DKT, fun((DKT, integer(), sax_event()) -> DKT)) -> {ok, DKT} | {error, nil}.
-doc(~" Iterate over a stream of SAX events, calling the given function for each
event.
The given function takes the current state, the line number of the event,
and the event itself, and returns the new state. The final state is
returned.
").
sax(A, B, C) ->
htmgrrrl_ffi:sax(A, B, C).