From b885b96deb1632062e9f1a9eff21dc5caf39d549 Mon Sep 17 00:00:00 2001 From: wonfen Date: Sat, 21 Mar 2026 22:47:47 +0800 Subject: [PATCH] fix: tg HTML parsing failure --- scripts/telegram.mjs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/telegram.mjs b/scripts/telegram.mjs index 214b76695..45aeb3891 100644 --- a/scripts/telegram.mjs +++ b/scripts/telegram.mjs @@ -44,17 +44,23 @@ async function sendTelegramNotification() { // Markdown 转换为 HTML function convertMarkdownToTelegramHTML(content) { + // Strip stray HTML tags and markdown bold from heading text + const cleanHeading = (text) => + text + .replace(/<\/?[^>]+>/g, '') + .replace(/\*\*/g, '') + .trim() return content .split('\n') .map((line) => { if (line.trim().length === 0) { return '' } else if (line.startsWith('## ')) { - return `${line.replace('## ', '')}` + return `${cleanHeading(line.replace('## ', ''))}` } else if (line.startsWith('### ')) { - return `${line.replace('### ', '')}` + return `${cleanHeading(line.replace('### ', ''))}` } else if (line.startsWith('#### ')) { - return `${line.replace('#### ', '')}` + return `${cleanHeading(line.replace('#### ', ''))}` } else { let processedLine = line.replace( /\[([^\]]+)\]\(([^)]+)\)/g,