You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
Simplify pass (#1)
* Say a thing once: one parent, one path, one vocabulary
Four places where the same fact was written twice, with nothing keeping
the copies honest.
The tree already knows each node's parent, so spaceOut no longer builds a
Map of what the parser recorded; worstRoadOverlap and pushApart read
node.parent and lose a parameter each.
The four edge constructions differed only in their d and class, yet two
of them spelled out the depth taper by hand. They now share svgPath().
A cross-link passes no depth and so still carries no stroke-width.
build() opened by repeating destroy() word for word. It calls it.
Four regexes answered the same yes/no question with four vocabularies:
spacing alone did not accept 0, so `spacing: 0` meant auto while
`legend: 0` meant off. isTrue and isFalse settle it, and `spacing: 0`
now reads as manual like every other 0. `spacing: manual` stays.
Verified against dev/preview.html: all 21 cases identical in bbox, node
geometry, path d, stroke and width, edge-label placement, warnings and
final transform.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* A box, a table, and a tree walked once
The box. A node records x as its left edge but y as the line of its
marker, and four places worked that asymmetry out for themselves.
nodeRect() says it once. worstOverlap gains by it twice over: it now
measures each box once a pass instead of twice for every pair.
The table. Nine settings, each nine lines of the same wiring, differing
only in a name, a note and which key they write. SETTINGS_UI is that
difference and nothing else, so a tenth setting is a row.
The tree. It cannot change once parsed — layout moves nodes but never
adds or drops one — so allNodes() walks it once and hands out the list,
cleared when a rebuild reparses.
Also: markerPoint, partRect and boxAnchor default their canvas offset
rather than making every caller write 0, 0; the two-spelling options go
through alias() instead of spelling out the ternary three times; and two
CSS rules that had been declared in two places each are declared once.
Verified against dev/preview.html: all 21 cases identical in geometry,
path data, computed style, warnings and transform. The settings tab was
driven through a recording stub — same nine settings in the same order,
same controls, limits and values, each handler still writing its own key
and saving once. Rebuilding with a changed source refreshes the node
list with no stale nodes, orphans or NaN transforms.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* Let the pattern and its handling sit together
renderInline dispatched on ten capture groups by hand: m[1] is code,
m[2] or m[3] is bold, and so on down a chain that only worked as long as
nobody inserted a pattern above it. The numbering lived in one place and
the meaning in another, twenty lines apart.
INLINE_RULES now carries both. Each rule holds its pattern and what to
build from it, and the group indices are counted off the table at load,
so inserting a rule renumbers the rest by itself. INLINE_RE is assembled
from the same table.
eachNode() replaces five hand-written walks. Two of them were doing more
than walking: a branch is one colour throughout, so assignColors sets it
rather than threading it down, and a re-parented root's depth is one past
its parent's, which a pre-order walk can simply state. The two walks that
genuinely carry changing state down -- bearings, and the vertical packing
-- are left as they are.
Verified against dev/preview.html: 21 render cases and the settings tab
identical as before, and renderInline checked against 57 inputs covering
every construct, nesting, unclosed marks, aliases, escaping and unicode
-- identical output, identical link targets. Group indices computed from
the table come out 1-9, as hand-written. Depths on hub-rooted and
single-rooted maps match the parent chain exactly.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>