fix(whatsapp): convert Markdown bold/strikethrough to WhatsApp formatting (#14285)

* fix(whatsapp): convert Markdown bold/strikethrough to WhatsApp formatting

* refactor: Move `escapeRegExp` utility function to `utils.js`.

---------

Co-authored-by: Luna AI <luna@coredirection.ai>
This commit is contained in:
Ajay Rajnikanth
2026-02-12 06:09:02 +01:00
committed by GitHub
parent 2e03131712
commit e24d023080
4 changed files with 145 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import type { WebInboundMsg } from "./types.js";
import { chunkMarkdownTextWithMode, type ChunkMode } from "../../auto-reply/chunk.js";
import { logVerbose, shouldLogVerbose } from "../../globals.js";
import { convertMarkdownTables } from "../../markdown/tables.js";
import { markdownToWhatsApp } from "../../markdown/whatsapp.js";
import { sleep } from "../../utils.js";
import { loadWebMedia } from "../media.js";
import { newConnectionId } from "../reconnect.js";
@@ -29,7 +30,9 @@ export async function deliverWebReply(params: {
const replyStarted = Date.now();
const tableMode = params.tableMode ?? "code";
const chunkMode = params.chunkMode ?? "length";
const convertedText = convertMarkdownTables(replyResult.text || "", tableMode);
const convertedText = markdownToWhatsApp(
convertMarkdownTables(replyResult.text || "", tableMode),
);
const textChunks = chunkMarkdownTextWithMode(convertedText, textLimit, chunkMode);
const mediaList = replyResult.mediaUrls?.length
? replyResult.mediaUrls

View File

@@ -4,6 +4,7 @@ import { resolveMarkdownTableMode } from "../config/markdown-tables.js";
import { getChildLogger } from "../logging/logger.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
import { convertMarkdownTables } from "../markdown/tables.js";
import { markdownToWhatsApp } from "../markdown/whatsapp.js";
import { normalizePollInput, type PollInput } from "../polls.js";
import { toWhatsappJid } from "../utils.js";
import { type ActiveWebSendOptions, requireActiveWebListener } from "./active-listener.js";
@@ -34,6 +35,7 @@ export async function sendMessageWhatsApp(
accountId: resolvedAccountId ?? options.accountId,
});
text = convertMarkdownTables(text ?? "", tableMode);
text = markdownToWhatsApp(text);
const logger = getChildLogger({
module: "web-outbound",
correlationId,