Skip to content

Escaping '#' inside bullet lists doesn't round-trip #234

@dionrhys

Description

@dionrhys

Describe the bug
Within list items, # at the start of the text needs to be escaped to not turn the text into a heading. We can escape that by writing \#, but flipping between rich text and markdown removes the backslash, making the text within the list item a heading again.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://editor.stackoverflow.design/

  2. Switch to Markdown mode and paste:

    \# test
    
    - \# test
    
    \# test
  3. Flip to rich text mode, see that # is shown as expected

    Screenshot

    Screenshot showing rich text mode the first time

  4. Flip to Markdown mode, see that # is no longer escaped

    Screenshot

    Screenshot showing markdown mode with changed content

  5. Flip to rich text mode, see that the text is now a <h1> heading

    Screenshot

    Screenshot showing rich text mode the second time

Expected behavior
The editor should keep the needed backslash escape on the # character so that it doesn't turn the text into a heading.

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Firefox
  • Version: 107.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcommonmarkRelates to commonmark round-tripping or syntax

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions