mirror of
https://github.com/facebook/lexical.git
synced 2025-05-17 15:18:47 +08:00
[lexical-markdown] Bug Fix: Add import support for backslash escape sequences (#7476)
This commit is contained in:
@ -580,6 +580,10 @@ describe('Markdown', () => {
|
||||
html: '<p><b><code spellcheck="false" style="white-space: pre-wrap;"><strong>Bold Code</strong></code></b></p>',
|
||||
md: '**`Bold Code`**',
|
||||
},
|
||||
{
|
||||
html: '<p><span style="white-space: pre-wrap;">This is a backslash: \\</span></p>',
|
||||
md: 'This is a backslash: \\\\',
|
||||
},
|
||||
{
|
||||
html: '<p><span style="white-space: pre-wrap;">This is an asterisk: *</span></p>',
|
||||
md: 'This is an asterisk: \\*',
|
||||
|
@ -134,7 +134,7 @@ export function importTextTransformers(
|
||||
// Handle escape characters
|
||||
const textContent = textNode.getTextContent();
|
||||
const escapedText = textContent
|
||||
.replace(/\\([*_`~])/g, '$1')
|
||||
.replace(/\\([*_`~\\])/g, '$1')
|
||||
.replace(/&#(\d+);/g, (_, codePoint) => {
|
||||
return String.fromCodePoint(codePoint);
|
||||
});
|
||||
|
Reference in New Issue
Block a user