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');
|
||||
});
|
||||
|
||||
it('should not parse footnotes', () => {
|
||||
expect(process('[^a]')).toEqual('\\[^a]');
|
||||
it('should not escape footnote references', () => {
|
||||
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,
|
||||
|
||||
/**
|
||||
* Links, Images, References, and Footnotes
|
||||
* Links and Images
|
||||
*
|
||||
* Match strings surrounded by brackets. This could be improved to
|
||||
* specifically match only the exact syntax of each covered entity, but
|
||||
* doing so through current approach would incur a considerable performance
|
||||
* penalty.
|
||||
* Match strings surrounded by square brackets, except when the opening
|
||||
* bracket is followed by a caret. This could be improved to specifically
|
||||
* match only the exact syntax of each covered entity, but doing so through
|
||||
* current approach would incur a considerable performance penalty.
|
||||
*/
|
||||
/(\[)[^\]]*]/g,
|
||||
/(\[(?!\^)+)[^\]]*]/g,
|
||||
];
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user