Skip to content

[RFC][lexical-markdown] Replace whitespace with code point when the string has leading and trailing whitespaces#7400

Merged
etrepum merged 1 commit intomainfrom
yunclu/issue6526_fix
Mar 29, 2025
Merged

[RFC][lexical-markdown] Replace whitespace with code point when the string has leading and trailing whitespaces#7400
etrepum merged 1 commit intomainfrom
yunclu/issue6526_fix

Conversation

@lilshady
Copy link
Copy Markdown
Contributor

Description

Currently, exportTextFormat in MardownExports trim the input first to handle the case looking like ** foo **
An edge case here is if the string consists only of whitespaces, the trimmed string will be empty.
Based on the discussion here, one possible solution is replacing the whitespace with its corresponding code points, which is also compatible with CommonMark.

Also, modify some test cases that have leading and trailing whitespaces.
Closes #6526

Test plan

Add a new unit test

Before

Screen.Recording.2025-03-26.at.12.03.16.mov

After

Screen.Recording.2025-03-27.at.13.02.50.mov

Test other whitespaces

Screen.Recording.2025-03-27.at.22.43.29.mov

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 29, 2025 1:12pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 29, 2025 1:12pm

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 29, 2025
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Mar 29, 2025
Copy link
Copy Markdown
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it works well, nice job!

@etrepum etrepum added this pull request to the merge queue Mar 29, 2025
Merged via the queue into main with commit 4d459e3 Mar 29, 2025
43 checks passed
@takuyakanbr takuyakanbr deleted the yunclu/issue6526_fix branch March 30, 2025 13:22
@etrepum etrepum mentioned this pull request Apr 7, 2025
fantactuka pushed a commit that referenced this pull request Aug 11, 2025
reinseth added a commit to reinseth/lexical that referenced this pull request Nov 8, 2025
…en the string has leading and trailing whitespaces (facebook#7400)"

This reverts commit 4d459e3.

# Conflicts:
#	packages/lexical-markdown/src/__tests__/unit/LexicalMarkdown.test.ts
#	packages/lexical-markdown/src/importTextTransformers.ts
reinseth added a commit to reinseth/lexical that referenced this pull request Feb 23, 2026
…en the string has leading and trailing whitespaces (facebook#7400)"

This reverts commit 4d459e3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Styling format should be removed from the whitespace

3 participants