From 541d4396d511609facfb477a1388aa6b775fe207 Mon Sep 17 00:00:00 2001 From: emad Date: Fri, 17 Apr 2026 20:22:25 +0300 Subject: [PATCH] fix: escape each angle-bracket placeholder in JSDoc independently MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ref generator escapes JSDoc angle brackets so that placeholders like `` render as text rather than HTML tags. The previous regex, `/<(.+)>/` applied in a loop, is greedy: on a line like https://api.telegram.org/file/bot/ it matches from the first `<` to the last `>`, producing a single replacement that leaves the middle `>/<` untouched. The result is `bot<token>/]+` inside the capture group so each placeholder is handled on its own, and drop the while loop. Works on any number of placeholders per line without swallowing intermediate characters. Closes #1027. --- site/api/components/P.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/site/api/components/P.tsx b/site/api/components/P.tsx index b2be4ed3d0..4a40c9be90 100644 --- a/site/api/components/P.tsx +++ b/site/api/components/P.tsx @@ -21,9 +21,11 @@ export function P( continue; } if (!inCodeBlock) { - while (/<.+>/.test(part)) { - part = part.replace(/<(.+)>/, "<$1>"); - } + // Escape each pair of angle brackets individually. The inner class + // `[^<>]+` keeps a single `<...>` from greedily swallowing every + // bracketed placeholder in the same sentence — see + // https://github.com/grammyjs/website/issues/1027. + part = part.replace(/<([^<>]+)>/g, "<$1>"); newParts.push(part); } else { newParts.push(part);