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,