diff --git a/lib/bridge.js b/lib/bridge.js index b0c9060..63688bd 100644 --- a/lib/bridge.js +++ b/lib/bridge.js @@ -828,7 +828,13 @@ export class TelegramBridge { async deliverHtml(chatId, markdown) { const chunks = splitMessage(markdown, this.maxMessageLength); for (const chunk of chunks) { - const html = markdownToHtml(chunk); + let html; + try { + html = markdownToHtml(chunk); + } + catch { + html = chunk; // Pathological markdown input: degrade to plain text instead of dropping. + } try { await this.withRetry(() => this.client.sendMessage(chatId, html, 'HTML')); } diff --git a/src/bridge.ts b/src/bridge.ts index 1b6429c..42e01d5 100644 --- a/src/bridge.ts +++ b/src/bridge.ts @@ -954,7 +954,12 @@ export class TelegramBridge { private async deliverHtml(chatId: number, markdown: string): Promise { const chunks = splitMessage(markdown, this.maxMessageLength) for (const chunk of chunks) { - const html = markdownToHtml(chunk) + let html: string + try { + html = markdownToHtml(chunk) + } catch { + html = chunk // Pathological markdown input: degrade to plain text instead of dropping. + } try { await this.withRetry(() => this.client.sendMessage(chatId, html, 'HTML')) } catch {