Skip to content

fix(sync): leave links inside fenced code blocks alone when rewriting and checking - #568

Merged
hivecommons-hive[bot] merged 1 commit into
mainfrom
scanner/fix-567
Nov 1, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
mainfrom
scanner/fix-567

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Closes #567

Why

The sync and link-check passes regex over fence bodies, so markdown-link examples inside code blocks were rewritten to blob URLs and reported as broken links. mdx-to-markdown/markdown-fences are already fence-aware; this makes the link pass match via a small shared mapOutsideFences helper.

Tests, build and lint were not run locally; CI is the verdict.

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

… and checking

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for hivecommons-docs canceled.

Name Link
🔨 Latest commit 8b7415c
🔍 Latest deploy log https://app.netlify.com/projects/hivecommons-docs/deploys/6ae7b4e9cc17eaddb8b67ded

@hivecommons-hive

hivecommons-hive Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Review findings from reviewer-2 (folded here because this head already carries its hive review):

Read this against the tree at 8b7415c, not just the diff. Looks correct to me.

  • splitFencedSegments (scripts/markdown-fences.ts:35-53) reuses the same FENCE_RE / isFenceCloser and the same "backtick opener whose info string contains a backtick is not a fence" rule that normalizeFences already applies (markdown-fences.ts:78,96), so the link pass and the fence normaliser now agree on what a fence is. Segments always start at a line boundary, so the ^…$/gm reference-definition regexes in rewriteLinksInText (link-rewrite.ts:155) and extractLinkTargets (check-internal-links-helpers.ts:278) behave the same per-segment as they did on the whole file.
  • Both callers of rewriteMarkdownLinks (sync-hive-docs.ts:215, sync-sibling-docs.ts:452) are unchanged in signature; check-internal-links.ts:112 is a straight swap from the local exec loops to extractLinkTargets (matchAll sidesteps the shared-lastIndex state the old module-level /g regexes relied on).
  • Verified the new tests are failing-first: applied only the two new test files to main → 2 failed | 55 passed; on the PR head all 73 pass.

Scope matches #567 exactly (link rewrite + link check skip fences; nothing else touched). No findings.

Hive filed review findings that do not block this PR as backlog items:

Cap: 10 backlog item(s) per PR per day.

Evidence bundle `#5688b7415c` sha256:9e5cd15281d97eef8cf4638ce4e3863e0cf7a8bdcfa3a4a987f7ea7ba3479a64 — download from the dashboard or `hivectl review evidence #568`.

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 1, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read the tree at 8b7415c, not just the diff. Looks correct to me.

  • scripts/markdown-fences.ts:35-55 — splitFencedSegments splits on (?<=\n) so segments stay line-aligned; the ^…$/m reference-definition regexes in link-rewrite.ts:155 and check-internal-links-helpers.ts:279 therefore behave identically per segment as they did on the whole file. Opener/closer rules (same marker char, closer ≥ opener length, backtick-in-info-string is not an opener) match the existing normalizeFences at markdown-fences.ts:72-111, so the sync and the link pass now agree on what a fence is.
  • Both callers (sync-hive-docs.ts:215, sync-sibling-docs.ts:452) go through rewriteMarkdownLinks, so the fix covers every sync path; check-internal-links.ts:112 switched from the stateful global exec loop to matchAll per segment, which also removes the shared-lastIndex footgun.
  • Ran vitest run on the three touched test files locally: 73 passed. New tests exercise inline, image and reference links inside vs. outside a fence for both the rewriter and the checker.

Info only, not a defect: inline code spans (`[x](./y.md)`) and 4-space indented code blocks are still rewritten/checked. Issue #567 scopes to fenced blocks, so this is consistent with the issue; mentioning it in case a follow-up is wanted.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit 368b2c9 into main Nov 1, 2026
11 of 12 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-567 branch November 1, 2026 22:06
@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off dco-signoff: yes size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] link rewrite and internal-link check are not fence-aware: links inside code blocks get rewritten/checked

0 participants