StackExchange / StackExchange/Stacks-Editor

Rich text editor can generate potentially invalid commonmark

Open
#59 0 comments 0 reactions 1 assignee View on GitHub

@tmcentee is already working on this.

Since Jul 11, 2022.

bug commonmark
Dominant language
TypeScript
Stars
437
Forks
61
Avg merge
16h 2m
Merged PRs (30d)
8

Description

Reported on Meta.SE

Describe the bug

Overlapping bold/italic formatting leads to incorrect formatting when toggling to Markdown mode.

  1. In rich text mode, write some text.
    • this is bold, now italic, and now?!
  2. Select part of the text.
  3. Make the selection italic.
    • this is bold, now italic, and now?!
  4. Select some overlapping text.
  5. Make the selection bold.
    • this is bold, now italic, and now?!

(Now bold and italic formatting is correctly applied to overlapping portions of the text.)

When switching to Markdown, the formatting is screwed up because Markdown doesn’t support overlapping formatting in this way: adjacent */** is ambiguous at the best of times, but Markdown wouldn’t support this even when using _ to format italics.

Here’s what the editor generates:

**this is bold, *now italic****, and now?!*

… but as mentioned, even the following isn’t really supported by Markdown as far as I’m aware (it certainly isn’t on this site):

**this is bold, _now italic**, and now?!_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.