Skip to content

Commit

Permalink
Merge pull request #558 from eh2077/22492-fix-allow-to-add-link-with-…
Browse files Browse the repository at this point in the history
…code-block-inside-alias-text

fix: allow to add link with code block inside alias text part
  • Loading branch information
Hayata Suenaga authored Jul 19, 2023
2 parents d7e4249 + e6fd696 commit fea1a75
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion __tests__/ExpensiMark-HTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1122,4 +1122,13 @@ test('Test here mention with @here@here', () => {
const testString = '@here@here';
const resultString = '<mention-here>@here</mention-here><mention-here>@here</mention-here>';
expect(parser.replace(testString)).toBe(resultString);
});
});

test('Test link with code fence inside the alias text part', () => {
const testString = '[```code```](google.com) '
+ '[test ```code``` test](google.com)';

const resultString = '[<pre>code</pre>](<a href="https://google.com" target="_blank" rel="noreferrer noopener">google.com</a>) '
+ '[test <pre>code</pre> test](<a href="https://google.com" target="_blank" rel="noreferrer noopener">google.com</a>)';
expect(parser.replace(testString)).toBe(resultString);
});
2 changes: 1 addition & 1 deletion lib/ExpensiMark.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ export default class ExpensiMark {
}
replacedText = replacedText.concat(textToCheck.substr(startIndex, (match.index - startIndex)));

if (abort) {
if (abort || match[1].includes('<pre>')) {
replacedText = replacedText.concat(textToCheck.substr(match.index, (match[0].length)));
} else {
const urlRegex = new RegExp(`^${LOOSE_URL_REGEX}$|^${URL_REGEX}$`, 'i');
Expand Down

0 comments on commit fea1a75

Please sign in to comment.