scripts/verify-links: add check for multi-line links

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-05-10 09:52:37 +02:00
parent 012c081663
commit 5559acab7c
+14 -1
View File
@@ -137,6 +137,15 @@ async function verifyFile(filePath, docPages) {
}
}
const multiLineLinks = content.match(/\[[^\]\n]+?\n[^\]\n]*?\]\(/g) || [];
badUrls.push(
...multiLineLinks.map(url => ({
url,
basePath: filePath,
problem: 'multi-line',
})),
);
return badUrls;
}
@@ -226,7 +235,7 @@ async function main() {
console.error(` From: ${basePath}`);
console.error(` To: ${url}`);
if (suggestion) {
console.error(` Replace With: ${suggestion}`);
console.error(` Replace with: ${suggestion}`);
}
} else if (problem === 'not-relative') {
console.error('Links within /docs/ must be relative');
@@ -238,6 +247,10 @@ async function main() {
);
console.error(` From: ${basePath}`);
console.error(` To: ${url}`);
} else if (problem === 'multi-line') {
console.error(`Links are not allowed to span multiple lines:`);
console.error(` From: ${basePath}`);
console.error(` To: ${url.replace(/\n/g, '\n ')}`);
}
}
process.exit(1);