Add table to builtins

pull/744/head
Zef Hemel 2024-02-23 10:21:13 +01:00
parent 4056c4f2f2
commit 702474dca1
2 changed files with 6 additions and 5 deletions

View File

@ -91,6 +91,11 @@ export const builtins: Record<string, Record<string, string>> = {
pos: "!number", pos: "!number",
hooks: "hooksSpec", hooks: "hooksSpec",
}, },
table: {
ref: "!string",
page: "!string",
pos: "!number",
},
// System builtins // System builtins
syscall: { syscall: {

View File

@ -1,4 +1,4 @@
import { CompleteEvent, IndexTreeEvent, ObjectValue } from "$type/types.ts"; import { IndexTreeEvent, ObjectValue } from "$type/types.ts";
import { collectNodesMatching, ParseTree } from "$lib/tree.ts"; import { collectNodesMatching, ParseTree } from "$lib/tree.ts";
import { indexObjects } from "./api.ts"; import { indexObjects } from "./api.ts";
import { collectNodesOfType } from "$lib/tree.ts"; import { collectNodesOfType } from "$lib/tree.ts";
@ -30,7 +30,6 @@ function concatChildrenTexts(nodes: ParseTree[]): string {
} }
export async function indexTables({ name: pageName, tree }: IndexTreeEvent) { export async function indexTables({ name: pageName, tree }: IndexTreeEvent) {
console.log(`Indexing tables in '${pageName}'`);
const result: ObjectValue<TableRowObject>[] = []; const result: ObjectValue<TableRowObject>[] = [];
collectNodesMatching(tree, (t) => !!t.type?.startsWith("Table")).forEach( collectNodesMatching(tree, (t) => !!t.type?.startsWith("Table")).forEach(
@ -65,12 +64,9 @@ export async function indexTables({ name: pageName, tree }: IndexTreeEvent) {
tableRow[label!] = content; tableRow[label!] = content;
}); });
result.push(tableRow); result.push(tableRow);
//console.log("Cells", cells);
} }
}, },
); );
console.log("Found", result.length, "row(s)");
await indexObjects(pageName, result); await indexObjects(pageName, result);
} }