Skip to content

Fix misplaced anchors for remark and proof-like divs - #79

Open
d-morrison wants to merge 1 commit into
mainfrom
fix/remark-anchors
Open

d-morrison wants to merge 1 commit into
mainfrom
fix/remark-anchors

Conversation

@d-morrison

Copy link
Copy Markdown
Contributor

Port div-anchors extension fix from Morrison-Lab/qwt#160 (Morrison-Lab/qwt#159).

Problem

Quarto theorem environments render titles with class .theorem-title, while proof-like environments (proof, remark, solution) render titles with class .proof-title. Previously, div-anchors.js only queried .theorem-title when relocating AnchorJS anchor links inline, causing remark and other proof-like divs to leave the anchor link at the bottom of the div rather than next to the title.

Solution

  • Support .proof-title alongside .theorem-title in div-anchors.js.
  • In div-anchors.js, trim trailing whitespace from .proof-title (which ends with '. ') so the non-breaking separator and anchor stay attached to the title, and ensure a trailing space separates the anchor from subsequent body content if not already spaced.
  • Add rem and sol aliases and crossref ID prefix matching (rem-, thm-, def-, etc.) to is_theorem_div in both Lua and JS.

Port div-anchors extension fix from Morrison-Lab/qwt#160 (Morrison-Lab/qwt#159).

Quarto theorem environments render titles with class .theorem-title,
while proof-like environments (proof, remark, solution) render titles
with class .proof-title. Previously, div-anchors.js only queried
.theorem-title when relocating AnchorJS anchor links inline, causing
remark and other proof-like divs to leave the anchor link at the bottom
of the div rather than next to the title.

- Support .proof-title alongside .theorem-title in div-anchors.js
- Trim trailing whitespace from .proof-title (which ends with '. ')
  so the non-breaking separator and anchor stay attached to the title,
  and ensure a space separates the anchor from subsequent body content
- Add 'rem' and 'sol' aliases and crossref ID prefix matching (rem-,
  thm-, def-, etc.) to is_theorem_div in both Lua and JS
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

Claude finished review — View run


Upstream didn't bump the version either, so this PR is consistent with that precedent — not a concern.

I've completed a thorough review: read the full diff, inspected the complete resulting files, confirmed this is a byte-for-byte port of the already-merged upstream fix (Morrison-Lab/qwt#160, merged), and actually executed the patched div-anchors.js logic in a jsdom harness against several scenarios (nested <strong> inside .proof-title, flat text title, no trailing sibling, id-prefix-only matching with no known class, and a pre-existing .theorem-title regression case) to confirm the anchor-relocation and whitespace-trimming logic behaves correctly in every case, including the edge case where the following sibling already starts with whitespace.

Findings

No bugs found in the ported JS/Lua logic — verified by direct execution, not just reading. No CLAUDE.md violations: the change is tightly scoped to the two files it touches, doesn't reformat unrelated code, isn't R (so .lintr.R/tidyverse rules don't apply), doesn't touch generated files (_site/, _freeze/, README.md), and is consistent with the repo's documented practice of porting fixes from the qwt template scaffolding. No fabricated APIs, references, or URLs — the PR's citations (Morrison-Lab/qwt#159, #160) are real and #160 is merged with an identical diff to what's ported here.

One minor, non-blocking observation: there are currently no remark/solution/proof divs anywhere in this repo's .qmd content, so this fix can't be visually confirmed in a live render here — but since it's an exact port of an upstream-merged, already-reviewed fix, that's a low-risk, forward-looking addition rather than a defect.

Verdict

Ready for merge

Structured Review Data (JSON)
{
  "schema_version": "1.1",
  "reviewer": "claude",
  "commit_sha": "3d48f48d8c851803b326e922b4cb12672dbb160e",
  "verdict": "CLEAN",
  "findings": [],
  "detailed_assessment": "Executed the patched div-anchors.js in a jsdom harness across nested-element, flat-text, no-sibling, id-prefix-only, and theorem-title regression cases; anchor relocation and whitespace trimming behaved correctly in every scenario with no logic defects found.",
  "holistic_assessment": "Change is a scoped, byte-identical port of the already-merged Morrison-Lab/qwt#160 fix, touches only the two intended extension files, introduces no regression to existing theorem-title handling, and needs no test infrastructure beyond what already exists for this vendored extension."
}

Reviewed commit: 400258b

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

💰 Cost: $0.8142 (review) — run

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://Morrison-Lab.github.io/sds/pr-preview/pr-79/

Built to branch gh-pages at 2026-10-06 17:51 PDT.
Preview will be ready when the GitHub Pages deployment is complete.

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.

1 participant