Skip to content

Commit

Permalink
Merge pull request #741 from ahmedGaber93/update-html-mention-rules
Browse files Browse the repository at this point in the history
update htmlToMarkdownRules userMention and reportMention
  • Loading branch information
marcaaron authored Jul 5, 2024
2 parents 2610f15 + b0e752c commit 14cc4dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions __tests__/ExpensiMark-Markdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,9 @@ test('Mention user html to markdown', () => {

testString = '<mention-user accountID="1234" />';
expect(parser.htmlToMarkdown(testString, extras)).toBe('@[email protected]');

testString = '<mention-user accountID="1234"></mention-user>';
expect(parser.htmlToMarkdown(testString, extras)).toBe('@[email protected]');
});

test('Mention report html to markdown', () => {
Expand Down Expand Up @@ -815,6 +818,9 @@ test('Mention report html to markdown', () => {

testString = '<mention-report reportID="1234" />';
expect(parser.htmlToMarkdown(testString, extras)).toBe('#room-name');

testString = '<mention-report reportID="1234"></mention-report>';
expect(parser.htmlToMarkdown(testString, extras)).toBe('#room-name');
});

describe('Image tag conversion to markdown', () => {
Expand Down
4 changes: 2 additions & 2 deletions lib/ExpensiMark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ export default class ExpensiMark {

{
name: 'reportMentions',
regex: /<mention-report reportID="(\d+)" *\/>/gi,
regex: /<mention-report reportID="(\d+)"(?: *\/>|><\/mention-report>)/gi,
replacement: (extras, _match, g1, _offset, _string) => {
const reportToNameMap = extras.reportIDToName;
if (!reportToNameMap || !reportToNameMap[g1]) {
Expand All @@ -660,7 +660,7 @@ export default class ExpensiMark {
},
{
name: 'userMention',
regex: /(?:<mention-user accountID="(\d+)" *\/>)|(?:<mention-user>(.*?)<\/mention-user>)/gi,
regex: /(?:<mention-user accountID="(\d+)"(?: *\/>|><\/mention-user>))|(?:<mention-user>(.*?)<\/mention-user>)/gi,
replacement: (extras, _match, g1, g2, _offset, _string) => {
if (g1) {
const accountToNameMap = extras.accountIDToName;
Expand Down

0 comments on commit 14cc4dd

Please sign in to comment.