From 5e598b8dbc6fba1fa3f745a04ada065ed1465043 Mon Sep 17 00:00:00 2001 From: r3770 Date: Thu, 16 Nov 2023 03:41:10 +0300 Subject: [PATCH] allow h1 tag to parse autolink & autoemail --- __tests__/ExpensiMark-HTML-test.js | 6 ++++++ lib/ExpensiMark.js | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/__tests__/ExpensiMark-HTML-test.js b/__tests__/ExpensiMark-HTML-test.js index 543ebde1..433a13bc 100644 --- a/__tests__/ExpensiMark-HTML-test.js +++ b/__tests__/ExpensiMark-HTML-test.js @@ -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('

Heading should have only one new line after it.


'); + + testString = '# hello test.com'; + expect(parser.replace(testString)).toBe('

hello test.com

'); + + testString = '# hello test@gmail.com'; + expect(parser.replace(testString)).toBe('

hello test@gmail.com

'); }); // Sections starting with > are successfully wrapped with
diff --git a/lib/ExpensiMark.js b/lib/ExpensiMark.js index 63aeb685..e12a5ff1 100644 --- a/lib/ExpensiMark.js +++ b/lib/ExpensiMark.js @@ -139,7 +139,7 @@ export default class ExpensiMark { process: (textToProcess, replacement) => { const regex = new RegExp( - `(?![^<]*>|[^<>]*<\\/)([_*~]*?)${MARKDOWN_URL_REGEX}\\1(?!((?:(?!|[^<]*(<\\/pre>|<\\/code>))`, + `(?![^<]*>|[^<>]*<\\/(?!h1>))([_*~]*?)${MARKDOWN_URL_REGEX}\\1(?!((?:(?!|[^<]*(<\\/pre>|<\\/code>))`, 'gi', ); return this.modifyTextForUrlLinks(regex, textToProcess, replacement); @@ -183,7 +183,7 @@ export default class ExpensiMark { { name: 'autoEmail', regex: new RegExp( - `([^\\w'#%+-]|^)${CONST.REG_EXP.MARKDOWN_EMAIL}(?!((?:(?!|[^<>]*<\\/(?!em))`, + `([^\\w'#%+-]|^)${CONST.REG_EXP.MARKDOWN_EMAIL}(?!((?:(?!|[^<>]*<\\/(?!em|h1))`, 'gim', ), replacement: '$1$2',