Skip to content

test(renderer): Canvas Candy callout-zone conformance (#16, slice 3) - #82

Merged
LeslieOA merged 1 commit into
developfrom
test/callouts-conformance
Oct 4, 2026
Merged

LeslieOA merged 1 commit into
developfrom
test/callouts-conformance

Conversation

@LeslieOA

Copy link
Copy Markdown
Member

Summary

Nothing tested parseCallouts — the code that turns >[!cc-header]-style markers into layout zones and strips them from the card body. This adds 59 tests for it, so a regression that left raw cc- markers visible in a card fails CI instead of shipping.

What is asserted

The eight demo-card texts from Canvas Candy's Headers and Labels.canvas vault, verbatim (header / footer / label-left / label-right, each with and without -noborder). Each card holds the live marker on one line and the same syntax repeated inside a fenced code block as a copy-paste example. Per card:

  • exactly one zone is extracted (the fenced example is not a second one)
  • the zone, text and noBorder are correct
  • the live marker is gone from the body
  • the fenced example is left verbatim in the body

Plus the hasCallouts prefilter, parseCallouts edge cases (continuation lines, centred callout, unknown cc- type stays in the body, ordinary blockquotes untouched, formatting preserved exactly), combinations (header+footer, left+right, label+header+footer), and the four zone getters.

The tests can fail

Mutation-checked before committing, source restored afterwards:

Deliberate breakage Result
markers left in the body 21 tests fail
-noborder ignored 4 tests fail

Correction to earlier scoping

Slice 3 of #16 was parked as ESM-blocked. That was wrong: callouts.ts imports only unified / remark-parse / remark-gfm, all CommonJS, so it runs under the existing ts-jest config with no mocking. The ESM problem is specific to hast-util-from-html in the parseToSegments chain.

Test plan

  • typecheck clean, lint 0 errors
  • 181 tests pass (59 new)
  • mutation-checked as above

Part of #16.

🤖 Generated with Claude Code

Nothing tested `parseCallouts`, the code that turns `>[!cc-header]`-style
markers into layout zones and strips them from the card body. A regression
that left raw markers visible in a card would have shipped silently.

Adds src/renderer/extensions/__tests__/callouts.test.ts (59 tests):

  - the eight demo-card texts from Canvas Candy's "Headers and Labels.canvas"
    vault, verbatim (header / footer / label-left / label-right, each with and
    without -noborder). Each card holds the live marker on one line and the
    same syntax repeated inside a fenced code block as a copy-paste example.
    Asserted per card: exactly one zone extracted, correct zone/text/noBorder,
    the live marker is gone from the body, and the fenced example is left
    verbatim (it is documentation, not a marker)
  - hasCallouts prefilter: with/without space after ">", plain text, standard
    Obsidian callouts (non cc-), and its deliberate looseness on fenced text
  - parseCallouts: zero-overhead path, continuation lines, centred callout,
    inline markdown kept in zone text, empty title, unknown cc- type left in
    the body, ordinary blockquotes untouched, non-callout formatting preserved
    exactly
  - combinations: header+footer, left+right labels, label+header+footer
    (supported since #64)
  - the four zone getters, present and absent

Verified the tests can fail: with markers left in the body 21 tests fail, and
with -noborder ignored 4 fail; source restored afterwards.

Slice 3 was parked as ESM-blocked. That was wrong: callouts.ts imports only
unified / remark-parse / remark-gfm, all CommonJS, so it runs under the
existing ts-jest config with no mocking. The ESM problem is specific to
hast-util-from-html in the parseToSegments chain.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@LeslieOA
LeslieOA force-pushed the test/callouts-conformance branch from 66d757d to 0d119c5 Compare October 4, 2026 20:09
LeslieOA added a commit that referenced this pull request Oct 4, 2026
Review of #32 before landing. The catalogue had upstream's class list
right but misfiled eleven of the classes:

- cc-header, cc-footer, cc-label-left and cc-label-right, with their
  -noborder variants, were listed as a CSS-class mechanism we skip. They
  are callouts (>[!cc-header]), which callouts.ts has supported all
  along, -noborder included.
- cc-image-cover and cc-image-clip were listed as cssclasses, with a
  card-outline clip as the effect. They are callouts that lay an image
  over the card; "clip" is an invalid object-fit value, so it stretches.
  They are a real gap: the raw marker shows in the card today.
- cc-shape-parallelogram was listed as a missing alias. Upstream's CSS
  defines only -left and -right, both of which we support.

It also adds the sticker convention (file names containing -cc-image),
which upstream's list leaves out, and drops the references to #29, which
was closed; the conformance tests landed as #67, #68 and #82.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LeslieOA added a commit that referenced this pull request Oct 4, 2026
Review of #31 before landing. The plan dates from May:

- It counted "168 tests" added by #29 as the contract. #29 was closed;
  the conformance tests landed as #67, #68 and #82, and only the
  src/core suites test code the port would replace.
- It predates src/gtk. The GTK renderer stays TypeScript too, and would
  load the wasm build, as the README paragraph already says.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LeslieOA
LeslieOA merged commit 36c6108 into develop Oct 4, 2026
1 check passed
@LeslieOA
LeslieOA deleted the test/callouts-conformance branch October 4, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant