cetz skill: correct the anchor gotcha's mechanism, and add four more - #598
Open
lmoresi wants to merge 1 commit into
Open
cetz skill: correct the anchor gotcha's mechanism, and add four more#598lmoresi wants to merge 1 commit into
lmoresi wants to merge 1 commit into
Conversation
The skill said cetz 'treats anchor: specially'. It does not. The cause is the import cetz.draw: * that a drawing helper needs in its own body: it runs inside the function after the parameters are bound and shadows any parameter sharing a name with a cetz.draw export. Isolated by removing the inner import from an otherwise identical helper, which compiles. That turns a one-name warning into a rule, and covers fill and stroke as well — a parameter named fill fails with 'expected color, gradient, tiling, or none, found function' reported inside cetz's canvas.typ, nowhere near the helper. Four more, each one compile failure during the rotated-BC figure: - let h(x) shadows Typst's horizontal-spacing h(), so a figure defining a surface height breaks every #h(0.4em) in a label, with an error naming neither; - a multi-line arithmetic expression in a let ends at the first newline unless parenthesised, reported as 'unknown variable: x'; - content() anchored west centres a multi-line block vertically, so a caption that wraps grows upwards into the heading above it — nothing errors, it just overlaps; - joining nodes by a distance threshold is not a triangulation and silently omits nodes, plus the two follow-ons for a non-convex domain: Delaunay fills the convex hull so cull by centroid, and a perfect lattice gives degenerate triangles so stagger the rows. Underworld development team with AI support from Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All six entries cost a compile failure during the rotated-boundary-conditions figure, so they are diagnosed rather than recalled.
The existing entry had the wrong mechanism
The skill said cetz "treats
anchor:specially". It does not. The cause is theimport cetz.draw: *that a drawing helper needs in its own body — it runs inside the function after the parameters are bound, and shadows any parameter sharing a name with acetz.drawexport.Isolated: the same helper without the inner import compiles fine. That is what identifies the import rather than the parameter name.
This matters because it converts a one-name warning into a rule. A parameter named
fillfails the same way, with an error that is much harder to read:— reported inside cetz's own source, nowhere near the helper. And it gives the second fix: if the helper does not actually draw, drop the inner import instead of renaming.
Four new entries
let h(x) = ...shadows Typst'sh(). A figure defining a surface height ash(x)breaks every#h(0.4em)used for spacing in a label, failing with "cannot add length and float" — an error naming neither the function nor the label.letends at the first newline unless parenthesised, reported asunknown variable: x, which sends you looking at the wrong line.content()anchored"west"centres a multi-line block vertically, so a caption that wraps grows upwards into the heading above it. Nothing errors — it only shows up in the PNG.Documentation only — no code paths touched.
Underworld development team with AI support from Claude Code