fix: improve handling of italics in the presence of links (#11064)

* fix(formatters): don't escape * in links

* add test for * -> * in url

* `\S+` -> `\S*` (tested locally)

* @Qjuh: handle italics both inside+outside <url>s

* more accurate <link> matcher

---------

Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>
This commit is contained in:
Kendell R
2025-11-09 01:02:25 -08:00
committed by Jiralite
parent b6a8264d6b
commit 1c5701651a
2 changed files with 26 additions and 8 deletions

View File

@@ -23,6 +23,8 @@ const testURLs = [
'https://example.com/name_with_underscores',
'https://example.com/name__with__underscores',
'https://example.com/name_with_underscores_and__double__underscores',
'https://*.example.com/globbed/*',
'https://example.com/*before*/>/*after*',
];
describe('Markdown escapers', () => {
@@ -87,6 +89,16 @@ describe('Markdown escapers', () => {
test('url', () => {
for (const url of testURLs) expect(escapeItalic(url)).toBe(url);
});
test('after-url', () => {
const url = '<https://example.com>';
for (const [input, output] of [
['*hi*', '\\*hi\\*'],
['_hi_', '\\_hi\\_'],
]) {
expect(escapeItalic(url + input)).toBe(url + output);
}
});
});
describe('escapeUnderline', () => {