refactor(plugins): finish provider and whatsapp cleanup

This commit is contained in:
Vincent Koc
2026-03-22 19:13:14 -07:00
parent 2131981230
commit 042669d8c8
22 changed files with 156 additions and 1396 deletions

View File

@@ -0,0 +1,22 @@
/**
* Strip lightweight markdown formatting from text while preserving readable
* plain-text structure for TTS and channel fallbacks.
*/
export function stripMarkdown(text: string): string {
let result = text;
result = result.replace(/\*\*(.+?)\*\*/g, "$1");
result = result.replace(/__(.+?)__/g, "$1");
result = result.replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, "$1");
result = result.replace(/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g, "$1");
result = result.replace(/~~(.+?)~~/g, "$1");
result = result.replace(/^#{1,6}\s+(.+)$/gm, "$1");
result = result.replace(/^>\s?(.*)$/gm, "$1");
result = result.replace(/^[-*_]{3,}$/gm, "");
result = result.replace(/`([^`]+)`/g, "$1");
result = result.replace(/\n{3,}/g, "\n\n");
return result.trim();
}