Skip to content

infra: fix Motoko sync — bare numeric-prefix links and em-dashes#263

Merged
marc0olo merged 1 commit into
mainfrom
infra/fix-sync-motoko
May 19, 2026
Merged

infra: fix Motoko sync — bare numeric-prefix links and em-dashes#263
marc0olo merged 1 commit into
mainfrom
infra/fix-sync-motoko

Conversation

@marc0olo
Copy link
Copy Markdown
Member

@marc0olo marc0olo commented May 19, 2026

Summary

Two postprocessor bugs in scripts/postprocess-motoko.mjs that caused PR #262 to produce broken links and em-dashes in synced Motoko docs.

Bug 1: Bare numeric-prefix links not rewritten

The linkRe regex only matched relative links starting with ./ or ../. Bare links like 10-contextual-dot.md (used by upstream in v1.8.0) were never passed to rewriteLink and landed in the synced output unchanged — a broken link, since the sync script strips numeric prefixes from filenames.

Fix: extend linkRe to also match \d+-name.md patterns. The existing rewriteLink() 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 static are preserved verbatim.

Both fixes are defensive

They become no-ops once caffeinelabs/motoko#6132 merges:

  • §5 removes numeric prefixes from filenames and §6 updates all links — no \d+-name.md links in source
  • §8 removes em-dashes from prose — nothing to replace

Next 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)

@marc0olo marc0olo requested a review from a team as a code owner May 19, 2026 20:18
@marc0olo marc0olo mentioned this pull request May 19, 2026
3 tasks
…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>
@marc0olo marc0olo force-pushed the infra/fix-sync-motoko branch from 36ebae1 to 75eafef Compare May 19, 2026 20:25
@marc0olo marc0olo merged commit 43b8f6e into main May 19, 2026
7 checks passed
@marc0olo marc0olo deleted the infra/fix-sync-motoko branch May 19, 2026 20:34
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.

2 participants