From a3e0e88f80648a0d292742fe8b3e19305ee20a28 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Tue, 18 Jun 2024 00:16:07 +0530 Subject: [PATCH] Use new logic to check bold text --- lib/ExpensiMark.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ExpensiMark.ts b/lib/ExpensiMark.ts index 9d0eb89b1..cdb216940 100644 --- a/lib/ExpensiMark.ts +++ b/lib/ExpensiMark.ts @@ -547,7 +547,14 @@ export default class ExpensiMark { { name: 'bold', regex: /<(b|strong)(?:"[^"]*"|'[^']*'|[^'">])*>([\s\S]*?)<\/\1>(?![^<]*(<\/pre>|<\/code>))/gi, - replacement: '*$2*', + replacement: (match, tagContent, innerContent) => { + const fontWeightMatch = innerContent.match(/style="(.*?)"/); + const isFontWeightBold = fontWeightMatch + ? fontWeightMatch[1].replaceAll(/\s/g, '').includes('font-weight:bold;') || fontWeightMatch[1].replaceAll(/\s/g, '').includes('font-weight:700;') + : false; + const isBold = fontWeightMatch ? isFontWeightBold : true; + return isBold ? `*${innerContent}*` : innerContent; + }, }, { name: 'strikethrough',