From b0e752cdacc8a0ab30568098191aedac1fad2c4a Mon Sep 17 00:00:00 2001 From: gaber Date: Fri, 5 Jul 2024 22:54:51 +0300 Subject: [PATCH] update htmlToMarkdownRules userMention and reportMention --- __tests__/ExpensiMark-Markdown-test.js | 6 ++++++ lib/ExpensiMark.ts | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/__tests__/ExpensiMark-Markdown-test.js b/__tests__/ExpensiMark-Markdown-test.js index bb1baf1f..3849bd69 100644 --- a/__tests__/ExpensiMark-Markdown-test.js +++ b/__tests__/ExpensiMark-Markdown-test.js @@ -786,6 +786,9 @@ test('Mention user html to markdown', () => { testString = ''; expect(parser.htmlToMarkdown(testString, extras)).toBe('@user@domain.com'); + + testString = ''; + expect(parser.htmlToMarkdown(testString, extras)).toBe('@user@domain.com'); }); test('Mention report html to markdown', () => { @@ -815,6 +818,9 @@ test('Mention report html to markdown', () => { testString = ''; expect(parser.htmlToMarkdown(testString, extras)).toBe('#room-name'); + + testString = ''; + expect(parser.htmlToMarkdown(testString, extras)).toBe('#room-name'); }); describe('Image tag conversion to markdown', () => { diff --git a/lib/ExpensiMark.ts b/lib/ExpensiMark.ts index 311974cb..f33c8b58 100644 --- a/lib/ExpensiMark.ts +++ b/lib/ExpensiMark.ts @@ -647,7 +647,7 @@ export default class ExpensiMark { { name: 'reportMentions', - regex: //gi, + regex: /|><\/mention-report>)/gi, replacement: (extras, _match, g1, _offset, _string) => { const reportToNameMap = extras.reportIDToName; if (!reportToNameMap || !reportToNameMap[g1]) { @@ -660,7 +660,7 @@ export default class ExpensiMark { }, { name: 'userMention', - regex: /(?:)|(?:(.*?)<\/mention-user>)/gi, + regex: /(?:|><\/mention-user>))|(?:(.*?)<\/mention-user>)/gi, replacement: (extras, _match, g1, g2, _offset, _string) => { if (g1) { const accountToNameMap = extras.accountIDToName;