scripts/verify-links: add check for multi-line links
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
+14
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user