Skip to content

Conversation

@baptistejamin
Copy link
Contributor

[lexical-markdown] Option: $convertToMarkdownString with shouldPreserveWhitespaces

Description

By default, $convertToMarkdownString replaces whitespaces in somecases with HTML chars: **   foo   **, while it's not a big deal when exporting from Lexical and then rendering into Lexical, it breaks on other Markdown renderers.

@vercel
Copy link

vercel bot commented Nov 4, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
lexical Ready Ready Preview Comment Nov 9, 2025 11:09am
lexical-playground Ready Ready Preview Comment Nov 9, 2025 11:09am

@meta-cla meta-cla 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 Nov 4, 2025
@etrepum
Copy link
Collaborator

etrepum commented Nov 4, 2025

This fails the formatting check (should be able to fix with npm run prettier:fix) and is a breaking change because the default is not the current behavior

@baptistejamin
Copy link
Contributor Author

Thank you for the report.

It has been fixed.

Copy link
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.

The only thing missing here are tests to show that it does what it's supposed to

$convertToMarkdownString([...TRANSFORMERS], undefined, false, true),
);

expect(exported).toBe('** Hello **');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking closer at what this is supposed to do now that there are tests I don't think this is useful, because this is not something most markdown parsers will accept.

For example here's what github does with it:

** Hello **

The commonmark reference implementation also doesn't parse it as formatting

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.

2 participants