fix: prevent escaping of footnotes and references (#3646)
Prevent footnotes ([^1]:blah) and footnote references ([^1]) from being incorrectly escaped when switching between Markdown and Rich Text modes. Co-authored-by: Pedr <pedr@sleepstation.org.uk>
This commit is contained in:
parent
cf57284f40
commit
028ab535df
@ -73,7 +73,13 @@ describe('remarkEscapeMarkdownEntities', () => {
|
|||||||
expect(process('a b <pre>*c*</pre> d e')).toEqual('a b <pre>*c*</pre> d e');
|
expect(process('a b <pre>*c*</pre> d e')).toEqual('a b <pre>*c*</pre> d e');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not parse footnotes', () => {
|
it('should not escape footnote references', () => {
|
||||||
expect(process('[^a]')).toEqual('\\[^a]');
|
expect(process('[^a]')).toEqual('[^a]');
|
||||||
|
expect(process('[^1]')).toEqual('[^1]');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not escape footnotes', () => {
|
||||||
|
expect(process('[^a]:')).toEqual('[^a]:');
|
||||||
|
expect(process('[^1]:')).toEqual('[^1]:');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -124,14 +124,14 @@ const escapePatterns = [
|
|||||||
/(`+)[^`]*(\1)/g,
|
/(`+)[^`]*(\1)/g,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Links, Images, References, and Footnotes
|
* Links and Images
|
||||||
*
|
*
|
||||||
* Match strings surrounded by brackets. This could be improved to
|
* Match strings surrounded by square brackets, except when the opening
|
||||||
* specifically match only the exact syntax of each covered entity, but
|
* bracket is followed by a caret. This could be improved to specifically
|
||||||
* doing so through current approach would incur a considerable performance
|
* match only the exact syntax of each covered entity, but doing so through
|
||||||
* penalty.
|
* current approach would incur a considerable performance penalty.
|
||||||
*/
|
*/
|
||||||
/(\[)[^\]]*]/g,
|
/(\[(?!\^)+)[^\]]*]/g,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user