Isometric line figures that answer the pointer. For React and for anything with a DOM.
Skill: build.mjs names the page from the hairline({ … }) call at the end of the figure, so a table with its own name: no longer gives the page the wrong name.
Lucas Marquesc214a73b5540
diff --git a/packages/hairline/test/skill/build.test.ts b/packages/hairline/test/skill/build.test.tsindex 51daecb..07e3e37 100644--- a/packages/hairline/test/skill/build.test.ts+++ b/packages/hairline/test/skill/build.test.ts@@ -32,6 +32,14 @@ it("names the page after the figure when no path is given", () => {expect(readFileSync(run.stdout.trim(), "utf8")).toContain("<title>");});+it("names the page from the hairline({ … }) call, not from an earlier name: in the figure", () => {+ const src = join(dir, "tables.js");+ writeFileSync(src, 'const LINES = [{ name: "other", at: 0 }];\n' + terrain);+ const run = node([SKILL + "build.mjs", src]);+ expect(run.status).toBe(0);+ expect(run.stdout.trim()).toMatch(/\/hairline-terrain\.html$/);+});+it("pastes text literally, so a figure may hold $& and $1", () => {const src = join(dir, "dollar.js"), out = join(dir, "dollar.html");const figure = terrain.replace("hairline({", () => 'const odd = "$& and $1 and $$";\nhairline({');diff --git a/skills/hairline-create/build.mjs b/skills/hairline-create/build.mjsindex e7a407b..78eae09 100644--- a/skills/hairline-create/build.mjs+++ b/skills/hairline-create/build.mjs@@ -19,8 +19,11 @@ export function assemble(figure) {.replace("/*FIGURE*/", () => `\n${figure.replace(/\r\n/g, "\n").trim()}\n`);}-/** The figure's name, read from its declaration. */-export const nameOf = (figure) => /\bname:\s*["'`]([a-z][a-z0-9-]*)["'`]/.exec(figure)?.[1] ?? null;+/** The figure's name, read from its declaration: the last hairline({ … }) call, as validate.mjs reads it, so a `name:` earlier in the figure is not taken for it. */+export function nameOf(figure) {+ const call = [...figure.matchAll(/\bhairline\s*\(\s*\{/g)].at(-1);+ return call ? /\bname:\s*["'`]([a-z][a-z0-9-]*)["'`]/.exec(figure.slice(call.index))?.[1] ?? null : null;+}/** Whether two resolved paths are one file. Windows paths ignore case, and the drive letter's case can differ between the two. */export const same = (a, b, platform = process.platform) => platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;