StackExchange / StackExchange/Stacks-Editor
bug(markdown) Adding code block around backticks doesn't work properly
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 437
- Forks
- 61
- Avg merge
- 16h 2m
- Merged PRs (30d)
- 8
Description
To Reproduce
- MD mode, type in 4 backticks
- Highlight them, set codeblock
- results in 3 lines with 3 backticks
- This gets mangled when go to RT, turning into 2 empty code blocks. So this translation is a problem.
- Going back to MD, ends up with 2 lines of 3 backticks, and empty line, and 2 lines of 3 backticks again (translation of the RT from step 4).
The MSE post points out several way to apply the codeblock to make this work, most practically in this case:
````
```
````
Which translates fine round-trip.
Expected behavior
Making this into a code block will do so in such a way that it can round trip and render properly
Screenshots

Desktop (please complete the following information):
Windows 11 Chrome 103
Additional context
https://meta.stackexchange.com/a/380356/51
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the four-backtick code-block case in MD mode, apply the codeblock formatting, and round-trip it through RT and back to MD. Trace the Markdown-to-rich-text and rich-text-to-Markdown conversion paths involved; done means the content remains a valid, correctly rendered code block through the round trip, including the example shown in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- markdown, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100