diff --git a/__tests__/ExpensiMark-HTML-test.js b/__tests__/ExpensiMark-HTML-test.js
index bba2665f..1417cc5a 100644
--- a/__tests__/ExpensiMark-HTML-test.js
+++ b/__tests__/ExpensiMark-HTML-test.js
@@ -79,7 +79,7 @@ test('Test italic markdown replacement', () => {
const italicTestStartString = 'Note that _this is correctly italicized_\n' + 'Note that `_this is correctly not italicized_` and _following inline contents are italicized_';
const italicTestReplacedString =
- 'Note that this is correctly italicized
' + 'Note that _this is correctly not italicized_
and following inline contents are italicized';
+ 'Note that this is correctly italicized
' + 'Note that _this is correctly not italicized_
and following inline contents are italicized';
expect(parser.replace(italicTestStartString)).toBe(italicTestReplacedString);
});
@@ -402,7 +402,7 @@ test('Test critical markdown style links', () => {
'second no http:// ' +
'third ' +
'third no https:// ' +
- 'link [inside another link](https://google.com)
' +
+ 'link [inside another link](https://google.com)
' +
'link with an @ in it ' +
'link with [brackets] inside of it ' +
'link with smart quotes ‘’“” ' +
@@ -499,7 +499,7 @@ test('Test inline code with multiple backtick symbols as content', () => {
test('Test inline code blocks with ExpensiMark syntax inside', () => {
const inlineCodeStartString = '`This is how you can write ~strikethrough~, *bold*, and _italics_`';
- expect(parser.replace(inlineCodeStartString)).toBe('This is how you can write ~strikethrough~, *bold*, and _italics_
');
+ expect(parser.replace(inlineCodeStartString)).toBe('This is how you can write ~strikethrough~, *bold*, and _italics_
');
});
test('Test inline code blocks inside ExpensiMark', () => {
@@ -1260,7 +1260,7 @@ test('Test for backticks with only space characters as content', () => {
// Code-fence with spaces as content
test('Test for inline code block with triple backtick with spaces as content', () => {
const testString = '``` ```';
- const resultString = '`` ``
';
+ const resultString = '`` ``
';
expect(parser.replace(testString)).toBe(resultString);
});
@@ -1417,7 +1417,7 @@ test('Test for user mention with text with codefence style', () => {
test('Test for user mention with text with inlineCodeBlock style', () => {
const testString = '`hi @username@expensify.com`';
- const resultString = 'hi @username@expensify.com
';
+ const resultString = 'hi @username@expensify.com
';
expect(parser.replace(testString)).toBe(resultString);
});
diff --git a/lib/ExpensiMark.ts b/lib/ExpensiMark.ts
index 4f0336f7..0bd16404 100644
--- a/lib/ExpensiMark.ts
+++ b/lib/ExpensiMark.ts
@@ -194,7 +194,8 @@ export default class ExpensiMark {
// must be present inside the backticks.
regex: /(\B|_|)`((?:`)*(?!`).*?[\S| |\u00A0]+?.*?(?|[^<]*<\/video>)/gm,
replacement: (_extras, _match, g1, g2, g3) => {
- return `${g1}${g2.replaceAll(' ', ' ')}
${g3}`;
+ const g2Value = g2.trim() === '' ? g2.replaceAll(' ', ' ') : g2;
+ return `${g1}${g2Value}
${g3}`;
},
},