mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-04-13 05:20:28 +08:00
fix: tg HTML parsing failure
This commit is contained in:
parent
06d8f0c06b
commit
c1a3077649
@ -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 `<b>${line.replace('## ', '')}</b>`
|
||||
return `<b>${cleanHeading(line.replace('## ', ''))}</b>`
|
||||
} else if (line.startsWith('### ')) {
|
||||
return `<b>${line.replace('### ', '')}</b>`
|
||||
return `<b>${cleanHeading(line.replace('### ', ''))}</b>`
|
||||
} else if (line.startsWith('#### ')) {
|
||||
return `<b>${line.replace('#### ', '')}</b>`
|
||||
return `<b>${cleanHeading(line.replace('#### ', ''))}</b>`
|
||||
} else {
|
||||
let processedLine = line.replace(
|
||||
/\[([^\]]+)\]\(([^)]+)\)/g,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user