Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions scripts/postprocess-motoko.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ function processFile(filePath) {
}
}

// Rewrite relative links (./ and ../ paths)
const linkRe = /\]\((\.[^)#]*?)(#[^)]+)?\)/g;
// Rewrite relative links (./ and ../ paths, plus bare numeric-prefix .md links like 10-name.md)
const linkRe = /\]\((\.[^)#]*?|\d+[^)#/\s]*\.md)(#[^)]+)?\)/g;
content = content.replace(linkRe, (match, path, anchor) => {
anchor = anchor || '';
const newUrl = rewriteLink(path, anchor, relPath);
Expand Down Expand Up @@ -392,6 +392,15 @@ function processFile(filePath) {
return match;
});

// Replace em-dashes in prose (banned per style guide). Skip fenced code blocks.
{
const parts = content.split(/(^```[\s\S]*?^```)/m);
const fixed = parts
.map((part, i) => (i % 2 === 0 ? part.replace(/ — /g, ': ') : part))
.join('');
if (fixed !== content) { content = fixed; changed = true; }
}

if (changed) writeFileSync(filePath, content);
return changed;
}
Expand Down
Loading