Skip to content

Bug: Trailing whitespace being formatted produces invalid Common Mark Markdown #7575

@ldrick

Description

@ldrick

Lexical version: 0.31.2

Steps To Reproduce

  1. Go to https://playground.lexical.dev/
  2. Mark in the sentence Make "sure to check "out the various[...] (only mark the Text in double quotes and the trailing whitespace is important) and format it bold by pressing "B" Symbol
  3. The trailing whitespace get's converted to HTML representation   and behind the result will become Make **sure to check **out the various[...]
  4. That is invalid common mark (and also gfm) and would other editors to print the surrounding "**" before and after.
  5. Please compare to this playground https://spec.commonmark.org/dingus/?text=test%20**test**%20test%5C%0Atest%20**test%20**%20test%5C%0Atest%20**test%20**test%5C%0Atest%20**test%26%2332%3B**test%5C%0Atest%20**test%26%2332%3B**%20test

Link to code example:

The current behavior

HTML space   is added, but space to following word is removed - which breaks Common Mark Syntax

The expected behavior

Any valid Common Mark dealing the trailing whitespace, see Step 5 in reproduction, to get a idea, what it could be (maybe examples are incomplete and there is much more)

Impact of fix

Happens always if within a text some words are marked to be formatted and makes it impossible to process the resulting Common Mark properly with other tools.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions