diff --git a/__tests__/ExpensiMark-HTML-test.js b/__tests__/ExpensiMark-HTML-test.js index 1417cc5a..f0408322 100644 --- a/__tests__/ExpensiMark-HTML-test.js +++ b/__tests__/ExpensiMark-HTML-test.js @@ -560,6 +560,9 @@ test('Test code fencing with additional backticks inside', () => { expect(parser.replace(nestedBackticks)).toBe( '
`This is how you can write ~strikethrough~, *bold*, _italics_, and [links](https://www.expensify.com)`
', ); + + nestedBackticks = '```\n`test`👋\n```'; + expect(parser.replace(nestedBackticks)).toBe('
`test`👋
'); }); test('Test combination replacements', () => { diff --git a/lib/ExpensiMark.ts b/lib/ExpensiMark.ts index 0a17a763..65e72d3f 100644 --- a/lib/ExpensiMark.ts +++ b/lib/ExpensiMark.ts @@ -192,7 +192,7 @@ export default class ExpensiMark { // but we should not replace backtick symbols if they include
 tags between them.
                 // At least one non-whitespace character or a specific whitespace character (" " and "\u00A0")
                 // must be present inside the backticks.
-                regex: /(\B|_|)`((?:`)*(?!`).*?[\S| |\u00A0]+?.*?(?|[^<]*<\/video>)/gm,
+                regex: /(\B|_|)`((?:`)*(?!`).*?[\S| |\u00A0]+?.*?(?)[^<]*(?:<(?!pre>)[^<]*)*<\/pre>|[^<]*<\/video>)/gm,
                 replacement: (_extras, _match, g1, g2, g3) => {
                     const g2Value = g2.trim() === '' ? g2.replaceAll(' ', ' ') : g2;
                     return `${g1}${g2Value}${g3}`;