StackExchange / StackExchange/Stacks-Editor
bug(commonmark) Round trip a backtick in a code block with code tag, weirdness ensues
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 437
- Forks
- 61
- Avg merge
- 16h 2m
- Merged PRs (30d)
- 8
Description
Describe the bug
Weird things happen when you try to encode a backtick, either as an escaped backtick or as an html entity (`).
There is probably more than one issue here, though definitely something up with having a backtick inside code html tag, and in general just having that html tag around.
To Reproduce
- MD mode, enter
<code>`</code> - Go to RT, correctly displays the backtick in a code block
- Go to MD, now shows
<code>` ` </code>`
- Go to RT, now shows an empty code block (presumably the two backticks within the code html tag are confusing it)
- Back to MD and it shows
` ` \`
Expected behavior
Round-trip returns same code
Desktop (please complete the following information):
Windows 11 Chrome 103
Additional context
https://meta.stackexchange.com/a/380357/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 reported MD → RT → MD sequence using the provided ` example, then compare each serialized result with the original input. Trace the round-trip handling for backticks inside code tags and confirm that returning to MD preserves the same code and renders correctly in RT.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html, markdown, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100