Skip to content

Commit

Permalink
Merge branch 'Expensify:main' into fix-#21753
Browse files Browse the repository at this point in the history
  • Loading branch information
agilejune authored Nov 18, 2023
2 parents 1d6b926 + 7c72af4 commit d5d7fcd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions __tests__/ExpensiMark-HTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ test('Test heading markdown replacement', () => {

testString = '# Heading should have only one new line after it.\n\n';
expect(parser.replace(testString)).toBe('<h1>Heading should have only one new line after it.</h1><br />');

testString = '# hello test.com';
expect(parser.replace(testString)).toBe('<h1>hello <a href=\"https://test.com\" target=\"_blank\" rel=\"noreferrer noopener\">test.com</a></h1>');

testString = '# hello [email protected]';
expect(parser.replace(testString)).toBe('<h1>hello <a href=\"mailto:[email protected]\">[email protected]</a></h1>');
});

// Sections starting with > are successfully wrapped with <blockquote></blockquote>
Expand Down
4 changes: 2 additions & 2 deletions lib/ExpensiMark.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default class ExpensiMark {

process: (textToProcess, replacement) => {
const regex = new RegExp(
`(?![^<]*>|[^<>]*<\\/)([_*~]*?)${MARKDOWN_URL_REGEX}\\1(?!((?:(?!<a).)+)?<\\/a>|[^<]*(<\\/pre>|<\\/code>))`,
`(?![^<]*>|[^<>]*<\\/(?!h1>))([_*~]*?)${MARKDOWN_URL_REGEX}\\1(?!((?:(?!<a).)+)?<\\/a>|[^<]*(<\\/pre>|<\\/code>))`,
'gi',
);
return this.modifyTextForUrlLinks(regex, textToProcess, replacement);
Expand Down Expand Up @@ -189,7 +189,7 @@ export default class ExpensiMark {
{
name: 'autoEmail',
regex: new RegExp(
`([^\\w'#%+-]|^)${CONST.REG_EXP.MARKDOWN_EMAIL}(?!((?:(?!<a).)+)?<\\/a>|[^<>]*<\\/(?!em))`,
`([^\\w'#%+-]|^)${CONST.REG_EXP.MARKDOWN_EMAIL}(?!((?:(?!<a).)+)?<\\/a>|[^<>]*<\\/(?!em|h1))`,
'gim',
),
replacement: '$1<a href="mailto:$2">$2</a>',
Expand Down

0 comments on commit d5d7fcd

Please sign in to comment.