Skip to content

Commit

Permalink
fix: allow to add link with code block inside alias text part
Browse files Browse the repository at this point in the history
  • Loading branch information
eh2077 committed Jul 14, 2023
1 parent d7e4249 commit e6fd696
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 e6fd696

Please sign in to comment.