From e6fd6966ec68c431a55325cc527e0570e4c87a20 Mon Sep 17 00:00:00 2001 From: Eric Han Date: Fri, 14 Jul 2023 17:46:37 +0800 Subject: [PATCH] fix: allow to add link with code block inside alias text part --- __tests__/ExpensiMark-HTML-test.js | 11 ++++++++++- lib/ExpensiMark.js | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/__tests__/ExpensiMark-HTML-test.js b/__tests__/ExpensiMark-HTML-test.js index 49280829..578357e0 100644 --- a/__tests__/ExpensiMark-HTML-test.js +++ b/__tests__/ExpensiMark-HTML-test.js @@ -1122,4 +1122,13 @@ test('Test here mention with @here@here', () => { const testString = '@here@here'; const resultString = '@here@here'; expect(parser.replace(testString)).toBe(resultString); -}); \ No newline at end of file +}); + +test('Test link with code fence inside the alias text part', () => { + const testString = '[```code```](google.com) ' + + '[test ```code``` test](google.com)'; + + const resultString = '[
code
](google.com) ' + + '[test
code
test](google.com)'; + expect(parser.replace(testString)).toBe(resultString); +}); diff --git a/lib/ExpensiMark.js b/lib/ExpensiMark.js index 8d2186f7..33149c00 100644 --- a/lib/ExpensiMark.js +++ b/lib/ExpensiMark.js @@ -457,7 +457,7 @@ export default class ExpensiMark { } replacedText = replacedText.concat(textToCheck.substr(startIndex, (match.index - startIndex))); - if (abort) { + if (abort || match[1].includes('
')) {
                 replacedText = replacedText.concat(textToCheck.substr(match.index, (match[0].length)));
             } else {
                 const urlRegex = new RegExp(`^${LOOSE_URL_REGEX}$|^${URL_REGEX}$`, 'i');