From 5559acab7c71089447f9c54b22568228e174eff1 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 10 May 2024 09:52:37 +0200 Subject: [PATCH] scripts/verify-links: add check for multi-line links Signed-off-by: Patrik Oldsberg --- scripts/verify-links.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/verify-links.js b/scripts/verify-links.js index 94ffc497cd..26d31ce6f0 100755 --- a/scripts/verify-links.js +++ b/scripts/verify-links.js @@ -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);