Skip to content

Commit

Permalink
Use new logic to check bold text
Browse files Browse the repository at this point in the history
  • Loading branch information
ShridharGoel committed Jun 24, 2024
1 parent 61a71d7 commit a3e0e88
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/ExpensiMark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit a3e0e88

Please sign in to comment.