StackExchange / StackExchange/Stacks-Editor

bug(commonmark) Round trip a backtick in a code block with code tag, weirdness ensues

Open
#180 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug commonmark
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

  1. MD mode, enter <code>&#96;</code>
  2. Go to RT, correctly displays the backtick in a code block
  3. Go to MD, now shows
<code>` ` </code>`
  1. Go to RT, now shows an empty code block (presumably the two backticks within the code html tag are confusing it)
  2. 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

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.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.