[lexical-markdown] Bug Fix: Add import support for backslash escape sequences (#7476)

This commit is contained in:
Bob Ippolito
2025-04-16 12:19:40 -07:00
committed by GitHub
parent 9ed0893a4b
commit 06f651b9da
2 changed files with 5 additions and 1 deletions

View File

@ -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: \\*',

View File

@ -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);
});