Web pages: a link to any address opens as an article, as Wikipedia's do
A url link now opens in the app instead of the browser. The server fetches the page (robots.txt honoured, public addresses only, size and time caps), keeps a snapshot on disk until it is reloaded, and cuts it into a lead and sections: by its headings, else by pseudo-headings, else in chunks, or by a model when asked (s), within a daily budget. The pane has its own amber ground, the author and date in its head when the page gives them, and the source in its foot. W opens the original, R reads it again. See docs/pages.md. Pictures and videos are kept, in web pages and in Wikipedia articles: pictures through the server (only addresses seen in a page that was read), videos as a still that loads the player on a click. A section that is only a link (a target, no text, no sections) opens as its article at once, and L opens a target to the right of the node's own pane, never under it. Article text is sized to read like the reader's own. Panes: a pane that already has all its column can give beside the others' tabs no longer peeks over them on hover, and the curves of tabs under a peeking pane are no longer drawn over it. The keypress timing test judges each of its two passes on its own, so a stall from outside the app does not fail it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
a3f25fbdcc
commit
f8c6576ea1
58 files changed
+8606
-367
No files matched your search
@@ -75,4 +75,33 @@ describe("article text", () => {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("an annotation made on an article's text before pictures were kept lands on the same words once its figures' captions are text too", async () => {
|
||||
// Grey heron as the sanitiser now makes it, and as the old one did (the same text, no figures).
|
||||
const a = await article("Grey heron");
|
||||
const parts = [{ path: [] as string[], html: a.lead }, ...a.sections.map((s) => ({ path: [s.heading], html: s.html }))];
|
||||
const now = parts.map((p) => ({ path: p.path, t: build(p.html) }));
|
||||
const before = parts.map((p) => ({ path: p.path, t: build(p.html.replace(/<figure[^]*?<\/figure>/g, "").replace(/<p>Herons at the weir<\/p>/, "")) }));
|
||||
expect(now[0].t.text.startsWith("An adult at a weir\n\nThe grey heron")).toBe(true);
|
||||
expect(before[0].t.text.startsWith("The grey heron")).toBe(true);
|
||||
const secsNow = now.map((x) => ({ path: x.path, text: x.t.text }));
|
||||
let checked = 0;
|
||||
for (const [i, s] of before.entries()) {
|
||||
// Every sentence, and a word the captions also use ("weir", "heron"), wherever it occurs.
|
||||
const ranges = [...sentences(s.t.text), ...[...s.t.text.matchAll(/\b(weir|heron)\b/g)].map((m): [number, number] => [m.index!, m.index! + m[0].length])];
|
||||
for (const r of ranges) {
|
||||
const anchor = makeAnchor(s.t.text, r, s.path, a.revisionId);
|
||||
const got = reanchor(anchor, secsNow);
|
||||
if ("detached" in got) throw new Error(`detached: ${anchor.q}`);
|
||||
expect(got.sec).toBe(i);
|
||||
// The same words, in the same place: the text around them is the text that was around them.
|
||||
const t = secsNow[got.sec].text;
|
||||
expect(t.slice(...got.range)).toBe(anchor.q);
|
||||
expect(t.slice(Math.max(0, got.range[0] - anchor.pre.length), got.range[0])).toBe(anchor.pre);
|
||||
expect(t.slice(got.range[1], got.range[1] + anchor.post.length)).toBe(anchor.post);
|
||||
checked++;
|
||||
}
|
||||
}
|
||||
expect(checked).toBeGreaterThan(10);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user