[lexical-markdown] Bug Fix: Escape ordered-list pattern in bullet list item export#8311
Merged
etrepum merged 3 commits intofacebook:mainfrom Apr 22, 2026
Conversation
…t item export When a bullet or check list item starts with a number-dot-space pattern (e.g. "1. foo"), the markdown exporter now escapes the dot to prevent double-escaping on round-trip. Previously, switching between WYSIWYG and markdown mode would turn "1\. foo" into "1\\. foo". Closes facebook#7824
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
reviewed
Apr 12, 2026
| skipExport: true, | ||
| }, | ||
| { | ||
| // Bullet list item starting with number-dot pattern should be escaped (Regression #7824) |
Collaborator
There was a problem hiding this comment.
Suggested change
| // Bullet list item starting with number-dot pattern should be escaped (Regression #7824) | |
| // Bullet list item starting with number-dot pattern should be escaped (#7824) |
Contributor
Author
There was a problem hiding this comment.
Fixed.
| output.push(indent + prefix + exportChildren(listItemNode)); | ||
| let childrenText = exportChildren(listItemNode); | ||
| if (listType !== 'number') { | ||
| childrenText = childrenText.replace(/^(\d+)(\.\s)/, '$1\\$2'); |
Collaborator
There was a problem hiding this comment.
It should allow for some spaces before the number as well
Suggested change
| childrenText = childrenText.replace(/^(\d+)(\.\s)/, '$1\\$2'); | |
| childrenText = childrenText.replace(/^(\s{0,3}\d+)(\.\s)/, '$1\\$2'); |
Contributor
Author
There was a problem hiding this comment.
Applied both — dropped the label and updated the regex to handle leading spaces.
etrepum
approved these changes
Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a bullet or check list item starts with a number-dot-space pattern (e.g.
1. foo), switching between WYSIWYG and markdown mode causes the exporter to double-escape the backslash:1\. foobecomes1\\. fooon each round-trip.The root cause is in
$listExport: the exporter outputs the list item text as-is without escaping the ordered-list pattern. On re-import,unescapeTextcorrectly strips the backslash from1\., but the exporter never re-adds it, causing the inline escape logic to double the existing backslash instead.Fixed by escaping the dot when a non-number list item's text starts with
\d+\.\s, producing1\. fooin the markdown output.Closes #7824
Test plan
Before
After WYSIWYG round-trip becomes:
After
Stable round-trip —
- 1\. foostays- 1\. foo.Added a unit test for bullet list items starting with ordered-list patterns.
All existing tests pass (329 markdown tests, 2742 total).