infra: fix Motoko sync — bare numeric-prefix links and em-dashes#263
Merged
Conversation
…stprocessor Two postprocessor bugs that caused PR #262 to produce broken links and em-dashes in synced Motoko docs: 1. Link regex only matched `./` and `../` relative links. Bare numeric-prefix links like `10-contextual-dot.md` (used by upstream in v1.8.0) were never passed to `rewriteLink` and remained broken. The updated regex also matches `\d+-name.md` patterns; `rewriteLink` already strips numeric prefixes and resolves slugs at line 214. 2. Em-dashes (` — `, banned per style guide) were not replaced during sync. Added a prose-only replacement pass (` — ` → `: `) after the link rewrites, with a fenced-code-block split so code comments like `// ERROR — not static` are preserved verbatim. Both fixes are defensive: they become no-ops once upstream PR caffeinelabs/motoko#6132 (§5 numeric prefixes, §8 em-dashes) merges. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36ebae1 to
75eafef
Compare
raymondk
approved these changes
May 19, 2026
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.
Summary
Two postprocessor bugs in
scripts/postprocess-motoko.mjsthat caused PR #262 to produce broken links and em-dashes in synced Motoko docs.Bug 1: Bare numeric-prefix links not rewritten
The
linkReregex only matched relative links starting with./or../. Bare links like10-contextual-dot.md(used by upstream in v1.8.0) were never passed torewriteLinkand landed in the synced output unchanged — a broken link, since the sync script strips numeric prefixes from filenames.Fix: extend
linkReto also match\d+-name.mdpatterns. The existingrewriteLink()at line 214 already strips numeric prefixes and resolves slugs.Bug 2: Em-dashes not replaced
Em-dashes (
—) are banned per the style guide, but the postprocessor had no replacement rule. 22 instances were present in already-synced v1.7.0 files.Fix: added a prose-only em-dash replacement pass (
—→:) after the link rewrites. Uses a fenced-code-block split so code comments like// ERROR — not staticare preserved verbatim.Both fixes are defensive
They become no-ops once
caffeinelabs/motoko#6132merges:\d+-name.mdlinks in sourceNext steps after this merges
Trigger a new Motoko sync to get a clean v1.8.0 bump (PR #262 was closed due to these bugs).
Sync recommendation
hand-written(postprocessor infrastructure)