Skip to content

Colour matching brackets by nesting depth - #189

Open
d-morrison wants to merge 3 commits into
mainfrom
claude/project-thread-l5roas
Open

d-morrison wants to merge 3 commits into
mainfrom
claude/project-thread-l5roas

Conversation

@d-morrison

Copy link
Copy Markdown
Contributor

Requested by Ezra · project thread

Important

Merge rainbow-parens#1 first. This PR vendors the extension as it stands on that PR's branch; if review changes it, I re-vendor it here with quarto add Morrison-Lab/rainbow-parens after it merges.

Why

Nested brackets are hard to match by eye in the notes' math and in Racket code. Morrison-Lab/rainbow-parens colours each pair of matching brackets by nesting depth in HTML output (website and slides), with separate colourblind-safe palettes for the light and dark themes (palettes and contrast numbers are in that PR). PDF handouts are unchanged.

What

  • Vendors the extension in _extensions/Morrison-Lab/rainbow-parens/.
  • Adds Morrison-Lab/rainbow-parens to the project filters in _quarto.yml (the Lua filter does nothing outside HTML).
  • Notes the extension in CLAUDE.md's repository layout.

Verified

Rendered chapters/trees.qmd (math plus {racket} chunks) to HTML with Quarto 1.11.9: the page loads the extension's script and stylesheet with the default settings (data-code="*"), and with an earlier build of the extension 950 brackets on that page carried the depth classes after MathJax finished.


Generated by Claude Code

Nested brackets are hard to match by eye in the notes' math and code.
The new Morrison-Lab/rainbow-parens extension colours each pair of matching
brackets by its depth in HTML output (website and slides), with separate
palettes for the light and dark themes. PDF output is unchanged.

This vendors the extension in _extensions/Morrison-Lab/rainbow-parens/, as
the lab's other extensions are, and adds it to the project filters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9r1K3Li6E2V978FMAk
Copilot AI balanced review requested due to automatic review settings November 19, 2026 05:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Picks up the extension's review fixes (stricter settings, version read
from _extension.yml, MIT license file, US spelling) and breaks the
CLAUDE.md lines the semantic line-break check flagged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9r1K3Li6E2V978FMAk
Copilot AI balanced review requested due to automatic review settings November 19, 2026 05:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Picks up the extension's fixes: the dark palette on any dark page
background, no coloring of the code-tools page source (on here
site-wide), \right. closing a level, one coloring pass per formula
however often MathJax.typeset() runs, R backtick names skipped, and
case-insensitive `code` languages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9r1K3Li6E2V978FMAk
Copilot AI balanced review requested due to automatic review settings November 19, 2026 05:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

Copy link
Copy Markdown
Contributor

Claude finished review — View run


PR #189 is still open, as I just fetched with gh pr view. It isn't a draft, mergedAt is null, and its head is aecbf701eb91f62f332cc4573eff7653cb18d667. That is the commit I reviewed, so the review below applies to the current head.

I found no new issues in aecbf70. It hardens the vendored rainbow-parens extension and changes nothing outside it. The prior round-2 review (for 1d8174e) also said "Ready for merge", and that verdict still stands.

What I checked in 1d8174ec..aecbf701

  • rainbow-parens.lua: The version regex now accepts a quoted version: "0.1.0". The old pattern returned nil for a quoted value, and the filter would have failed. The unquoted form still matches.
  • rainbow-parens.css: body.rp-dark is added to the dark palette selector. Only the script sets that class.
  • rainbow-parens.js, math:
    • colorMath skips a root it has already colored, so repeated MathJax.typeset() passes do nothing.
    • addClass does not stack a second rp-d* class.
    • invisibleFence counts the empty fence from \left. or \right. as an opener or closer without coloring it, so cases and set-builder braces pair up. An ordinary empty <mo> has no fence attribute, or is not at the row edge, so it is unaffected.
    • The typeset stub stops Quarto's hover-time MathJax.typeset() call from throwing before MathJax loads. MathJax replaces the configuration object when it loads.
  • rainbow-parens.js, code:
    • Language matching is case-insensitive.
    • The #quarto-embedded-source-code-modal block is skipped.
    • An empty language list returns early.
    • The at class is skipped, so backtick-quoted R names stay uncolored.
  • rainbow-parens.js, dark detection:
    • syncDark sets rp-dark from the body's background luminance, with the root element's background as fallback.
    • The 0.179 threshold is where white and black text have equal contrast.
    • A color format that doesn't parse, or a transparent one, gives null, so the page keeps the light palette.
    • Toggling to the value the class already has does not change the attribute, so the MutationObserver on class does not loop.
    • document.body exists by the time onLoad runs.

Suggestion (not blocking)

I did not run a render or open a page in a browser, so I haven't confirmed that a bracket gets the rp-d1 class. The same goes for the new \left. pairing and rp-dark switching. Opening one chapter with cases math, with a dark theme selected, would close that gap.

Verdict

Ready for merge. No new findings in aecbf70.

Structured Review Data (JSON)
{
  "schema_version": "1.1",
  "reviewer": "claude",
  "commit_sha": "aecbf701eb91f62f332cc4573eff7653cb18d667",
  "verdict": "CLEAN",
  "findings": [],
  "detailed_assessment": "Traced rainbow-parens.js changes (invisible fence pairing, idempotent colorMath, typeset stub, rp-dark MutationObserver) and the Lua version regex; no loop, null-dereference or regression found.",
  "holistic_assessment": "The commit is a scoped hardening of a vendored extension with no PDF impact; the only open item is an optional in-browser check of math and dark-theme coloring that was not run here."
}

Reviewed commit: aecbf70

@github-actions

Copy link
Copy Markdown
Contributor

💰 Cost: $0.2489 (review) — run

@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.2
🚀 Preview available at: https://Morrison-Lab.github.io/mcs/pr-preview/pr-189/

Built to branch gh-pages at 2026-11-19 06:12 UTC.

@d-morrison

Copy link
Copy Markdown
Contributor Author

Cross-harness review (Antigravity agy CLI, gemini-4-hydrogen-high) of aecbf70

Read-only run (agy --mode plan) on the PR description and full diff at this head.

Summary

This PR vendors the Morrison-Lab/rainbow-parens Quarto extension to enable coloring of matching brackets by nesting depth in HTML output (math and syntax-highlighted code). It includes the extension's files in _extensions/Morrison-Lab/rainbow-parens/, adds the extension to the filters list in _quarto.yml, and documents it in CLAUDE.md.

What I checked

  • File Structure: Verified that the vendored extension files (_extension.yml, LICENSE, rainbow-parens.css, rainbow-parens.js, rainbow-parens.lua) were added correctly under _extensions/Morrison-Lab/rainbow-parens/.
  • _quarto.yml Integration: Confirmed that - Morrison-Lab/rainbow-parens was added to the filters list.
  • Lua Filter (rainbow-parens.lua):
    • Checked the logic to ensure the filter only runs for HTML output (quarto.doc.is_format("html")).
    • Verified the version retrieval logic from _extension.yml.
    • Checked configuration validation logic for math and code settings.
  • JavaScript (rainbow-parens.js):
    • Examined the logic for bracket nesting (stack-based), depth cycling, and MathJax render action integration.
    • Checked the syntax highlighting class exclusion list (SKIP_CLASSES).
    • Verified the dark theme background detection (syncDark).
  • CSS (rainbow-parens.css):
    • Verified the palette definitions for light and dark themes, including the !important overrides and the @media query for print/forced-contrast modes.
  • CLAUDE.md Documentation: Verified that the new extension is documented with instructions for updating it via quarto add.
  • PR Description Consistency: Verified that the implementation aligns with the description (vendoring, project filter update, documentation update, and PDF output remaining unchanged).

Findings

None.

VERDICT: CLEAN

Reviewed-Commit: aecbf70

Posted by Claude Code (AI agent) --- not written by a human.

@d-morrison

Copy link
Copy Markdown
Contributor Author

Annotation dispositions for head aecbf70:

  • review / claude-review (check run 135372987813), notice: "SUBMODULES_TOKEN is empty; cloning submodules anonymously". The submodules this repo uses are public, so the anonymous clone succeeded and the review ran and returned clean. No action.

Posted by Claude Code (AI agent) --- not written by a human.

This branch has not been deployed

No deployments
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.

3 participants