From 29c9a3ec9b56f82e7bf3973309973dc500106ebd Mon Sep 17 00:00:00 2001 From: David Edler Date: Wed, 5 Jun 2024 17:49:14 +0200 Subject: [PATCH] fix(docs) use doc link titles as link text in case they are available from the object.inv.txt content Signed-off-by: David Edler --- src/util/config.spec.ts | 2 +- src/util/config.tsx | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/util/config.spec.ts b/src/util/config.spec.ts index fcb93944a..882eb8c99 100644 --- a/src/util/config.spec.ts +++ b/src/util/config.spec.ts @@ -81,7 +81,7 @@ describe("toConfigFields and replaceDocLinks", () => { ); expect(result).toBe( - 'Specify a Pongo2 template string that represents the snapshot name.
This template is used for scheduled snapshots and for unnamed snapshots.

See instance options snapshots names for more information.', + 'Specify a Pongo2 template string that represents the snapshot name.
This template is used for scheduled snapshots and for unnamed snapshots.

See Automatic snapshot names for more information.', ); }); diff --git a/src/util/config.tsx b/src/util/config.tsx index 8b61f7c96..e54d0db92 100644 --- a/src/util/config.tsx +++ b/src/util/config.tsx @@ -58,7 +58,13 @@ export const configDescriptionToHtml = ( return; } const docPath = line.split(": ")[1]; - const linkText = token.replaceAll("-", " "); + const linkTextCandidate = line + .split(":")[0] + .replace(/\s\s+/g, " ") + .trim(); + const linkText = linkTextCandidate.includes(" ") // some lines in the object.inv.txt file have a description before the : and a link after + ? linkTextCandidate.substring(linkTextCandidate.indexOf(" ") + 1) + : token.replaceAll("-", " "); const link = `${linkText}`; result = result.replaceAll(tag, link);