Skip to content

Commit

Permalink
Merge pull request #605 from r3770/fix-#26942
Browse files Browse the repository at this point in the history
  • Loading branch information
cead22 committed Nov 16, 2023
2 parents 1b51807 + 5e598b8 commit 7c72af4
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 @@ -139,7 +139,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 @@ -183,7 +183,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 7c72af4

Please sign in to comment.