No matching definitions.

html/dom

src/html/dom.tur

WHATWG HTML parsing into a dom-core Document, via lexbor.

Since: 0.1.0

defstruct

HtmlOpts

(defstruct HtmlOpts :copy [max-depth : int max-bytes : int])

caps for one HTML parse.

defn

default-html-opts

(default-html-opts :)

depth 512 (Blink's limit), 64 MiB of input.

HtmlOpts

(html-parse-opts src (default-html-opts))

Since: 0.1.0

defn

html-backend-version

(html-backend-version :)

the linked lexbor's version string.

cstr -- static, e.g. "3.0.1".

(println (html-backend-version))

Since: 0.1.0

defn

html-parse

(html-parse [src : cstr] :)

parse a whole HTML document. Never fails.

srcthe document (UTF-8)

Document -- always; release it with `dom-free`.

(let [d (html-parse "<p>one<p>two")]
    (tlength (find-all (dom-node d) "p"))   ; => 2
    (dom-free d))

Since: 0.1.0

defn

html-parse-opts

(html-parse-opts [src : cstr opts : HtmlOpts] :)

parse a whole HTML document with explicit caps.

srcthe document
optsdepth and byte caps

(Result Document ParseError) -- err (kind Limit) only when the input is longer than max-bytes.

(html-parse-opts src (with (default-html-opts) [max-depth 32]))

Since: 0.1.0

defn

html-parse-fragment

(html-parse-fragment [context : cstr src : cstr] :)

parse markup as the contents of an element.

contextthe context element's tag name ("body", "tr", "select", ...)
srcthe markup

Document -- always; release it with `dom-free`.

(node-child-count (dom-node (html-parse-fragment "tr" "<td>a<td>b")))  ; => 2

Since: 0.1.0

defn

html-parse-fragment-opts

(html-parse-fragment-opts [context : cstr src : cstr opts : HtmlOpts])

`html-parse-fragment` with explicit caps.

contextthe context element's tag name
srcthe markup
optsdepth and byte caps

(Result Document ParseError)

(html-parse-fragment-opts "div" src (default-html-opts))

Since: 0.1.0

defn

html-parse-file-opts

(html-parse-file-opts [path : cstr opts : HtmlOpts])

parse an HTML file with explicit caps.

paththe file (UTF-8)
optsdepth and byte caps

(Result Document ParseError) -- Io when the file cannot be read, Limit when it is longer than max-bytes.

(html-parse-file-opts "page.html" (with (default-html-opts) [max-bytes 0]))

Since: 0.1.0

defn

html-parse-file

(html-parse-file [path : cstr] :)

parse an HTML file with the default caps.

paththe file

(Result Document ParseError)

(html-parse-file "index.html")

Since: 0.1.0

Internal definitions
__null?-- internal.
__parse-raw-- internal: a turdom_doc, or NULL with the error recorded.
__fragment-raw-- internal: a turdom_doc for a fragment, or NULL.
__file-raw-- internal: a turdom_doc for a file, or NULL.
__must-- internal: a never-fails parse result; only OOM yields NULL.
__err-kind-- internal.
__err-msg-- internal.
__error-- internal: the recorded error (msg copied).
__wrap-- internal: a nullable tree as a Result.