No matching definitions.

html/sax

src/html/sax.tur

tokenizer-level HTML events, via lexbor's tokenizer.

Since: 0.1.0

defstruct

HtmlSaxParser

(defstruct HtmlSaxParser :copy [raw : HtmlSaxRaw handler : (fn [SaxEvent])

a push tokenizer plus the handler it feeds.

defn

html-sax-parse-string-opts

(html-sax-parse-string-opts [src : cstr opts : HtmlOpts h : (fn [SaxEvent])

tokenize HTML with explicit caps.

srcthe markup
optsonly max-bytes applies (there is no tree to cap the depth of)
hcalled once per event; return (Continue) or (Stop)

(Result nil ParseError) -- err (Limit) only past max-bytes or on OOM.

(html-sax-parse-string-opts src (with (default-html-opts) [max-bytes 0]) h)

Since: 0.1.0

defn

html-sax-parse-string

(html-sax-parse-string [src : cstr h : (fn [SaxEvent])

tokenize HTML with the default caps.

srcthe markup
hcalled once per event

(Result nil ParseError)

(html-sax-parse-string "<a href=x>link</a>"
    (fn [e : SaxEvent] : SaxControl
      (match e
        (StartElement n as) (do (println (to-cstr n)) (Continue))
        _ (Continue))))

Since: 0.1.0

defn

html-sax-parser-new-opts

(html-sax-parser-new-opts [opts : HtmlOpts h : (fn [SaxEvent])

a push tokenizer with explicit caps.

optsonly max-bytes applies
hcalled once per event as chunks are fed

(Result HtmlSaxParser ParseError) -- err only when out of memory.

(html-sax-parser-new-opts (default-html-opts) h)

Since: 0.1.0

defn

html-sax-parser-new

(html-sax-parser-new [h : (fn [SaxEvent])

a push tokenizer with the default caps.

hcalled once per event as chunks are fed

(Result HtmlSaxParser ParseError)

(match (html-sax-parser-new h)
    (Ok p) (do (html-sax-feed! p "<p>he") (html-sax-feed! p "llo")
               (html-sax-finish! p) (html-sax-parser-free p))
    (Err e) ...)

Since: 0.1.0

defn

html-sax-feed!

(html-sax-feed! [p : HtmlSaxParser chunk : cstr] :)

feed the next chunk and deliver its events.

pthe push tokenizer
chunkthe next bytes

(Result nil ParseError)

(html-sax-feed! p "<div cla")
  (html-sax-feed! p "ss=x>")

Since: 0.1.0

defn

html-sax-finish!

(html-sax-finish! [p : HtmlSaxParser] :)

signal the end of input and deliver the last events.

pthe push tokenizer

(Result nil ParseError)

(html-sax-finish! p)

Since: 0.1.0

defn

html-sax-parser-free

(html-sax-parser-free [p : HtmlSaxParser] :)

release a push tokenizer.

pthe tokenizer, not used afterwards
(html-sax-parser-free p)

Since: 0.1.0

Internal definitions
HtmlSaxRaw-- internal: the C tokenizer state (c/html/turhtml.c).
__new-raw-- internal: a tokenizer (NULL on OOM).
__null?-- internal.
__free-- internal.
__set-string-- internal: tokenize `src` (borrowed for the parse).
__pump-- internal: 1 more, 0 done, -1 failed.
__feed-- internal: 0 ok, -1 failed.
__next-- internal: the next queued event's kind, or 0.
__stop-- internal.
__ev-name-- internal.
__ev-text-- internal.
__ev-pubid-- internal.
__ev-sysid-- internal.
__ev-nattrs-- internal.
__ev-attr-name-- internal.
__ev-attr-value-- internal.
__err-kind-- internal.
__err-msg-- internal.
__error-- internal: the recorded error (msg copied).
__oom-- internal.
__attrs-acc-- internal: attributes, built back to front.
__event-- internal: the current token as a SaxEvent.
__deliver-- internal: hand every queued event to the handler; true when
__deliver-chunk-- internal: one chunk's events inside a region, so the
__run-- internal: pump the configured string to the end.
__make-- internal: a tokenizer, or none on OOM.
__push-- internal: feed a chunk (or the end) and deliver its events.