diff --git a/__tests__/ExpensiMark-HTML-test.js b/__tests__/ExpensiMark-HTML-test.js index 1a137162..e2b68b59 100644 --- a/__tests__/ExpensiMark-HTML-test.js +++ b/__tests__/ExpensiMark-HTML-test.js @@ -495,19 +495,19 @@ test('Test code fencing with ExpensiMark syntax outside', () => { codeFenceExample = '*Test1 ```\ncode\n``` Test2*'; expect(parser.replace(codeFenceExample)).toBe('*Test1
codeTest2*'); - expect(parser.replace(codeFenceExample, {shouldKeepRawInput: true})).toBe('*Test1
code\nTest2*'); + expect(parser.replace(codeFenceExample, {shouldKeepRawInput: true})).toBe('*Test1
code\nTest2*'); codeFenceExample = '_Test1 ```\ncode\n``` Test2_'; expect(parser.replace(codeFenceExample)).toBe('_Test1
codeTest2_'); - expect(parser.replace(codeFenceExample, {shouldKeepRawInput: true})).toBe('_Test1
code\nTest2_'); + expect(parser.replace(codeFenceExample, {shouldKeepRawInput: true})).toBe('_Test1
code\nTest2_'); codeFenceExample = '~Test1 ```\ncode\n``` Test2~'; expect(parser.replace(codeFenceExample)).toBe('~Test1
codeTest2~'); - expect(parser.replace(codeFenceExample, {shouldKeepRawInput: true})).toBe('~Test1
code\nTest2~'); + expect(parser.replace(codeFenceExample, {shouldKeepRawInput: true})).toBe('~Test1
code\nTest2~'); codeFenceExample = '[```\ncode\n```](google.com)'; expect(parser.replace(codeFenceExample)).toBe('[
code](google.com)'); - expect(parser.replace(codeFenceExample, {shouldKeepRawInput: true})).toBe('[
code\n](google.com)'); + expect(parser.replace(codeFenceExample, {shouldKeepRawInput: true})).toBe('[
code\n](google.com)'); }); test('Test code fencing with additional backticks inside', () => { @@ -1274,6 +1274,12 @@ test('Test for user mention with codefence style', () => { expect(parser.replace(testString)).toBe(resultString); }); +test('Test for room mention with codefence style', () => { + const testString = '```\n#room\n```'; + const resultString = '
#room'; + expect(parser.replace(testString)).toBe(resultString); +}); + test('Test for user mention with inlineCodeBlock style', () => { const testString = '`@username@expensify.com`'; const resultString = '
@username@expensify.com
';
@@ -1783,14 +1789,14 @@ describe('when should keep raw input flag is enabled', () => {
test('quote with other markdowns', () => {
const quoteTestStartString = '> This is a *quote* that started on a new line.\nHere is a >quote that did not\n```\nhere is a codefenced quote\n>it should not be quoted\n```';
- const quoteTestReplacedString = 'This is a quote that started on a new line.\nHere is a >quote that did not\n
here is a codefenced quote\n>it should not be quoted\n'; + const quoteTestReplacedString = '
This is a quote that started on a new line.\nHere is a >quote that did not\n
here is a codefenced quote\n>it should not be quoted\n'; expect(parser.replace(quoteTestStartString, {shouldKeepRawInput: true})).toBe(quoteTestReplacedString); }); test('codeBlock with newlines', () => { const quoteTestStartString = '```\nhello world\n```'; - const quoteTestReplacedString = '
hello world\n'; + const quoteTestReplacedString = '
hello world\n'; expect(parser.replace(quoteTestStartString, {shouldKeepRawInput: true})).toBe(quoteTestReplacedString); }); diff --git a/lib/ExpensiMark.js b/lib/ExpensiMark.js index 6b77fcee..adea1428 100644 --- a/lib/ExpensiMark.js +++ b/lib/ExpensiMark.js @@ -46,9 +46,8 @@ export default class ExpensiMark { return `
${group}`; }, rawInputReplacement: (match, __, textWithinFences) => { - const withinFences = match.replace(/(?:```)([\s\S]*?)(?:```)/g, '$1'); - const group = textWithinFences.replace(/(?:(?![\n\r])\s)/g, ' '); - return `
${group}`; + const group = textWithinFences.replace(/(?:(?![\n\r])\s)/g, ' ').replace(/
${group}`; }, }, @@ -170,7 +169,7 @@ export default class ExpensiMark { { name: 'reportMentions', - regex: /(?|<\/code>))/gimu, replacement: '