Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update htmlToMarkdownRules userMention and reportMention #741

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading