diff --git a/pkg/html/shim/larva_html.c b/pkg/html/shim/larva_html.c
index 6d0df2d..b126b6f 100644
--- a/pkg/html/shim/larva_html.c
+++ b/pkg/html/shim/larva_html.c
@@ -1,37 +1,22 @@
-// The C side of pkg/html: the few lexbor calls that are inline functions, macros or
-// struct reads, which Odin cannot bind directly, plus the one hook the incremental
-// parser needs (see larva_html_begin). Everything else is bound from Odin
-// (pkg/html/lexbor.odin). Built by scripts/build-lexbor.sh.
-
#include
#include
#include
#include
#include
-// One per document being parsed. The tree builder installs its own token callback on
-// the tokenizer when chunk parsing begins; we wrap it so we see every token first.
typedef struct {
lxb_html_tokenizer_token_f orig;
void *orig_ctx;
lxb_html_tree_t *tree;
- lxb_dom_node_t *script; // the ` that is not
-// closing a script element (inside a comment, in plain text) never reaches here as an
-// end tag with that current node, so it is ignored.
static lxb_html_token_t *larva_hook_cb(lxb_html_tokenizer_t *tkz, lxb_html_token_t *token, void *ctx) {
larva_html_hook *h = ctx;
@@ -59,8 +39,6 @@ static lxb_html_token_t *larva_hook_cb(lxb_html_tokenizer_t *tkz, lxb_html_token
return h->orig(tkz, token, h->orig_ctx);
}
-// Starts chunked parsing of `doc` and installs the hook. NULL on failure; free with
-// larva_html_hook_free after the document's parse has ended.
larva_html_hook *larva_html_begin(lxb_html_document_t *doc) {
if (lxb_html_document_parse_chunk_begin(doc) != LXB_STATUS_OK) {
return NULL;
@@ -85,9 +63,6 @@ larva_html_hook *larva_html_begin(lxb_html_document_t *doc) {
return h;
}
-// Returns the script element closed since the last call, and clears it. *closed is
-// how many script end tags were seen in that time: the parser cuts its slices so that
-// it is never more than 1, and treats more as a failure rather than lose a script.
lxb_dom_node_t *larva_html_take_script(larva_html_hook *h, size_t *closed) {
lxb_dom_node_t *s = h->script;
*closed = h->closed;
@@ -104,8 +79,6 @@ lxb_dom_node_t *larva_html_document_node(lxb_html_document_t *doc) {
return lxb_dom_interface_node(doc);
}
-// textContent of `node`. The bytes belong to the document; release them with
-// larva_html_text_free.
lxb_char_t *larva_html_text(lxb_dom_node_t *node, size_t *len) {
return lxb_dom_node_text_content(node, len);
}
@@ -116,8 +89,6 @@ void larva_html_text_free(lxb_dom_node_t *node, lxb_char_t *text) {
}
}
-// The value of attribute `name` on element `node`, or NULL when absent. Owned by the
-// element; valid until the element changes.
const lxb_char_t *larva_html_attr(lxb_dom_node_t *node, const lxb_char_t *name, size_t name_len, size_t *len) {
return lxb_dom_element_get_attribute(lxb_dom_interface_element(node), name, name_len, len);
}
@@ -146,8 +117,6 @@ larva_css *larva_css_create(void) {
return NULL;
}
- // querySelectorAll reports a node once, however many selectors of a list
- // (`a, a.x`) it matches; lexbor's default reports it once per selector.
lxb_selectors_opt_set(e->selectors, LXB_SELECTORS_OPT_MATCH_FIRST);
return e;
}
@@ -162,7 +131,6 @@ void larva_css_destroy(larva_css *e) {
free(e);
}
-// NULL when `css` is not a valid selector list.
lxb_css_selector_list_t *larva_css_compile(larva_css *e, const lxb_char_t *css, size_t len) {
lxb_css_selector_list_t *list = lxb_css_selectors_parse(e->parser, css, len);
@@ -183,8 +151,6 @@ static lxb_status_t larva_css_found(lxb_dom_node_t *node, lxb_css_selector_speci
return f->found(node, f->ctx) ? LXB_STATUS_STOP : LXB_STATUS_OK;
}
-// Matches the descendants of `root` (not `root` itself), in tree order. A stop from
-// `found` is success, not an error.
bool larva_css_find(larva_css *e, lxb_dom_node_t *root, const lxb_css_selector_list_t *list, larva_css_found_f found,
void *ctx) {
larva_css_find_ctx f = {found, ctx};
@@ -192,7 +158,6 @@ bool larva_css_find(larva_css *e, lxb_dom_node_t *root, const lxb_css_selector_l
return st == LXB_STATUS_OK || st == LXB_STATUS_STOP || st == LXB_STATUS_STOPPED;
}
-// outerHTML of `node`.
lxb_status_t larva_html_serialize_node(lxb_dom_node_t *node, lxb_html_serialize_cb_f cb, void *ctx) {
return lxb_html_serialize_tree_cb(node, cb, ctx);
}
diff --git a/scripts/check-js-graph.test.mjs b/scripts/check-js-graph.test.mjs
index f5a4902..2084154 100644
--- a/scripts/check-js-graph.test.mjs
+++ b/scripts/check-js-graph.test.mjs
@@ -333,7 +333,8 @@ test('eager: a function-body require does not make its target eager', () => {
// that list equal to what the ratchet computes, so neither can drift alone.
test('eager: the Odin cross-check list matches the computed set', () => {
const odin = readFileSync(join(ROOT, 'cmd', 'lava', 'lazy_builtins_test.odin'), 'utf8');
- const m = /STATIC_EAGER :: \[\?\]string\{([^}]*)\}/.exec(odin);
+ // odinfmt writes `[?]string {`; older text had no space before the brace.
+ const m = /STATIC_EAGER :: \[\?\]string\s*\{([^}]*)\}/.exec(odin);
assert.ok(m, 'STATIC_EAGER not found in lazy_builtins_test.odin');
const listed = [...m[1].matchAll(/"([^"]+)"/g)].map((x) => x[1]).sort();
assert.deepEqual(listed, eagerModules(ROOT));
diff --git a/scripts/fmt-if.mjs b/scripts/fmt-if.mjs
index 2e4f94d..c0f7e7f 100644
--- a/scripts/fmt-if.mjs
+++ b/scripts/fmt-if.mjs
@@ -121,7 +121,8 @@ function formatSource(src, isC) {
const { code, state: next } = scan(line, state, isC);
state = next;
const indent = line.match(/^\s*/)[0];
- const spread = !isC && !startState.raw && !startState.block ? spreadOneLineBlock(line, code, indent) : null;
+ const spread =
+ !isC && !startState.raw && !startState.block ? spreadOneLineBlock(line, code, indent) : null;
out.push(...(spread ?? [line]));
}
@@ -162,11 +163,13 @@ function formatSource(src, isC) {
if (!seenOpen && !isC && / do /.test(src2[j])) break; // a `do` form odinfmt left
if (j - i > 2000) break;
}
- if (end + 1 < src2.length && !isBlank(src2[end + 1]) && !closesOrLabels(src2[end + 1])) blankAfter.add(end);
+ if (end + 1 < src2.length && !isBlank(src2[end + 1]) && !closesOrLabels(src2[end + 1]))
+ blankAfter.add(end);
}
for (let i = 0; i < src2.length; i++) {
- if (blankBefore.has(i) && !(result.length && isBlank(result[result.length - 1]))) result.push('');
+ if (blankBefore.has(i) && !(result.length && isBlank(result[result.length - 1])))
+ result.push('');
result.push(src2[i]);
if (blankAfter.has(i)) result.push('');
}