;
abc :
a';
+ expect(parser.replace(testString)).toBe(resultString);
+});
+
+test('Test for backticks with an escaped backtick character inside it without prefix and suffix', () => {
+ const testString = '`#` abc `:`';
+ const resultString = '#
abc :
';
+ expect(parser.replace(testString)).toBe(resultString);
+});
+
+test('Test for backticks with complete escaped backtick characters inside it', () => {
+ const testString = 'a `&` b `#` c `x` d `6` e `0` f `;` g `test` h';
+ const resultString = 'a &
b #
c x
d 6
e 0
f ;
g test
h';
+ expect(parser.replace(testString)).toBe(resultString);
+});
+
// Backticks with no content are not replaced with
test('Test for backticks with no content', () => {
const testString = '` `';
diff --git a/lib/ExpensiMark.ts b/lib/ExpensiMark.ts
index b961cb83..48e05b0d 100644
--- a/lib/ExpensiMark.ts
+++ b/lib/ExpensiMark.ts
@@ -190,8 +190,8 @@ export default class ExpensiMark {
// Use the url escaped version of a backtick (`) symbol. Mobile platforms do not support lookbehinds,
// so capture the first and third group and place them in the replacement.
// but we should not replace backtick symbols if they include tags between them.
- regex: /(\B|_|)`(.*?(?![`])\S.*?)`(\B|_|)(?!`|[^<]*<\/pre>|[^<]*<\/video>)/gm,
- replacement: '$1$2
$3',
+ regex: /(\B|_|)`((?:`)*)(?!`)(.*?\S+?.*?)(?|[^<]*<\/video>)/gm,
+ replacement: '$1$2$3$4
$6',
},
/**