3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-18 22:25:44 +01:00

Answer prose round 1: 0 🔴, 9 🟡 (0 misread); state the entry's premises and measure, name withoutEdgeWhitespace for the replay, say every other node is linked

This commit is contained in:
2026-11-15 21:12:34 +01:00
committed by Lillem4n
parent 39cf161dad
commit a3dafe14bc
3 changed files with 29 additions and 20 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
## Unreleased
- `adfToPortableMarkdown` writes a line of whitespace-only text nodes beside a hard break, alternating linked and plain or emphasized, in time linear in its length, where `0.3.1` took time quadratic in it.
- `adfToPortableMarkdown` writes a line of whitespace-only text nodes beside a hard break, every other one linked, in time linear in the number of nodes, where `0.3.1` took time quadratic in it.
- `adfToPortableMarkdown` writes a line of code spans alternating with emphasized spaces in time linear in its length, where `0.3.1` took time quadratic in it.
- `adfToHtml` writes a media single, a media group and a caption as `<figure class="adf-media-single">` holding an
`<img>` and a `<figcaption>`, and as `<div class="adf-media-group">` of `<span class="adf-file">` files, where
+25 -16
View File
@@ -1187,25 +1187,34 @@ so it doesn't bound the walk's cost.
## After each trim pass, the reducer drops the edge whitespace the passes to come would drop, a round per pass
2026-11-15, item 190's chunk. Goal 9. Valid while `link` is the only kept mark that is not
edge-stripping, and every hard break the reducer hands the trim is alike.
2026-11-15, item 190's chunk. Goal 9. Valid while `link` is the only kept mark besides `code` that is
not edge-stripping, the trim leaves a `code` leaf as it is, every hard break the reducer hands the
trim is alike, and every leaf it hands the trim is text or a hard break.
`trimPass` judges every leaf against one snapshot, so a blank leaf reaches a line edge only the
pass after its neighbour dropped there: n blanks at a hard break took n + 1 passes, each linear.
`withoutEdgeWhitespace` replays those drops in rounds, one per pass to come, and a round judges only
the leaves beside a leaf the round before dropped, so all rounds together are linear. A round is
exact because whitespace at a line edge goes or stays by three facts no pass changes: its leaf's
outermost mark, the outermost mark of the leaf across the hard break, and whether a hard break lies
between. Three things keep it so, each found by the property test against the one-leaf-per-pass
reference: a round judges all its leaves before it changes any, since a leaf goes by a neighbour
that goes in the same pass; a round also judges the edge whitespace of a leaf holding text; and the
replay reads the pass's line merged, as `trimPass` merges before it judges. No round merges again:
a leaf that goes has a hard break or a line edge beside it, so it brings no two leaves together.
The replay runs after a
pass, never before the first: a pass also takes marks off whitespace by the line as it stands, and
the first pass must see the line as it came. Measured in passes
(§Cost fixes are measured, never timed): both of item 190's lines took 7, 101 and 1 001 passes at
6, 100 and 1 000 blanks, and take 2 at each, as at 100 000.
`withoutEdgeWhitespace` replays those drops in rounds, one per pass to come. A round after the
first judges only the leaves beside a leaf the round before dropped, and no judging reads a leaf's
text: each leaf's edge whitespace is counted once, and `trimmingRuns` is handed a one-character
stand-in. So all rounds together are linear. A line holding any other leaf, such as a mention, is
left to the passes, since a link run crosses such a leaf and a round reads only the leaves beside
an edge.
A round judges whitespace at a line edge by its leaf's marks, the marks of the leaf across the hard
break, and whether a hard break lies between. That it drops what the passes would is held by the
property test against its reference counts (`runsSharedWithNext`), which found three things a
round owes: it judges all its leaves before it changes any, since `trimPass` judges a leaf by its
neighbour as that stood before the pass, even where the neighbour goes in the same pass; it also
judges the edge whitespace of a leaf holding more than whitespace, such as `'x '`; and it reads
the pass's line merged, as `trimPass` merges before it judges. No round merges again: a leaf that
goes has a hard break or a line edge beside it, so it brings no two leaves together.
`withoutEdgeWhitespace` runs after a pass, never before the first: a pass also takes marks off
whitespace, and the first pass must see the line as it came.
Measured in counts (§Cost fixes are measured, never timed): both lines of `blankLines`
(`src/markdown/portable/inline-reduction.test.ts`) took 7, 101 and 1 001 passes at 6, 100 and 1 000
blanks, and take 2 at each, as at 100 000; and the trim reads the text of each leaf it keeps as
often at 1 000 blanks as at 6.
## Only the hard break holds a raw newline
+3 -3
View File
@@ -108,12 +108,12 @@ Forge's runtime, which no leg tests.
`portable/inline-reduction.ts`'s `leafEdges` finds the trail with an unanchored `/[ \t]*$/`,
quadratic in a run of blanks inside one leaf: a paragraph of `a`, 80 000 spaces, `b` takes 6.5 s in
`adfToPortableMarkdown`. Scan backward, as the expand title's trim does. `withoutLineEdges`, in the
same file, finds its trail with the same expression.
`adfToPortableMarkdown`. Scan backward, as the expand title's trim does. `edgeWhitespace`, in the
same file, counts a leaf's lead and trail by index.
### 191. Make the edge trim and the reference of its property test agree on a line whose strong link run ends in blanks before two hard breaks.
Found while shipping item 190, on `origin/main`'s trim as well as on that chunk's: fast-check seed 578490788, path `94554:1:8:16:15:15:16:16:16:16`, in `trims a spanned line as the reference counts trim it, in no more passes` (`src/markdown/portable/inline-reduction.test.ts`), about one random line in 100 000, so the gate's 3 000 runs on a fixed seed pass. The line, with `held` a link to `v` and `strong`: `'x '` holding `held` and `backgroundColor`, `' '` holding `held`, `' '` unmarked, a hard break, `' '` holding `held`, `' '` unmarked, a hard break. `trimmedEdges` returns the one leaf `'x'`; the reference, `trimPass` on `runsSharedWithNext`'s counts, also keeps a linked `' '`. Decide which is right by `docs/decisions.md` → "After 32 passes…" and the trim's entries, then fix the other and pin the line as a fixed test.
Found while shipping item 190, on `origin/main`'s trim as well as on that chunk's: fast-check seed 578490788, path `94554:1:8:16:15:15:16:16:16:16`, in `trims a spanned line as the reference counts trim it, in no more passes` (`src/markdown/portable/inline-reduction.test.ts`), about one random line in 100 000, so the gate's 3 000 runs on a fixed seed pass. The line, with `held` a link to `v` and `strong`: `'x '` holding `held` and `backgroundColor`, `' '` holding `held`, `' '` unmarked, a hard break, `' '` holding `held`, `' '` unmarked, a hard break. `trimmedEdges` returns the one leaf `'x'`; the reference, `trimPass` on `runsSharedWithNext`'s counts, also keeps a linked `' '`. Decide which is right by `docs/decisions.md` → "After 32 passes…" and the trim's entries, then fix the other and pin the line as a fixed test. A second line of the class, with no link and one hard break: seed -1783810909, path `201490:2:4:5:9:9:9:15:14:18:18:18:18:22:23:23`, the line `'x '` strong, `' '` code, `' '` strong, a hard break, `' '` unmarked, `'x '` strong, `' '` unmarked; the trim gives `x`, `' '`, `' '`, hard break, `x`, the reference `'x '`, `' '`, hard break, `x`.
### 31. Make the branch-coverage figure repeat across runs of an unchanged tree.