From 03cbf9d1a020d739f0bec7a88f1ba02df92b5b65 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Tue, 24 Dec 2024 23:31:31 +0500 Subject: [PATCH] chore: added spaces outside of regex match Signed-off-by: Tokesh --- tools/src/prepare-for-vale/KeepDescriptions.ts | 5 ++++- tools/tests/prepare-for-vale/fixtures/spec.txt | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/src/prepare-for-vale/KeepDescriptions.ts b/tools/src/prepare-for-vale/KeepDescriptions.ts index b2d0d33f..002d7015 100644 --- a/tools/src/prepare-for-vale/KeepDescriptions.ts +++ b/tools/src/prepare-for-vale/KeepDescriptions.ts @@ -69,6 +69,9 @@ export default class KeepDescriptions { } remove_links(line: string): string { - return line.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') + return line.replace(/\[([^\]]+)\]\([^)]+\)/g, (match, p1) => { + const spaces = ' '.repeat(match.length - p1.length-1); + return ' ' + p1 + spaces; + }); } } diff --git a/tools/tests/prepare-for-vale/fixtures/spec.txt b/tools/tests/prepare-for-vale/fixtures/spec.txt index 3f29f1c0..8070b934 100644 --- a/tools/tests/prepare-for-vale/fixtures/spec.txt +++ b/tools/tests/prepare-for-vale/fixtures/spec.txt @@ -9,15 +9,15 @@ - For a successful response, this value is always true. On failure, an exception is returned instead Supported units. + For a successful response, this value is always true. On failure, an exception is returned instead Supported units . - The item level REST category class codes during indexing link with a title. + The item level REST category class codes during indexing link with a title . - Here is link one and link two. + Here is link one and link two . Line two