From 6e084b4a73205f19ff7045ff23455846029ed0b7 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sat, 22 Jun 2024 16:13:13 -0700 Subject: [PATCH] enh: voice call skip code block & expression --- src/lib/utils/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index 1950a2f2a..755ef3550 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -506,12 +506,16 @@ export const removeEmojis = (str) => { return str.replace(emojiRegex, ''); }; +export const removeFormattings = (str) => { + return str.replace(/(\*)(.*?)\1/g, '').replace(/(```)(.*?)\1/gs, ''); +}; + export const extractSentences = (text) => { // Split the paragraph into sentences based on common punctuation marks const sentences = text.split(/(?<=[.!?])\s+/); return sentences - .map((sentence) => removeEmojis(sentence.trim())) + .map((sentence) => removeFormattings(removeEmojis(sentence.trim()))) .filter((sentence) => sentence !== ''); };