Skip to content

<code> not rendered correctly; incorrectly escapes when switching #12

@chwarr

Description

@chwarr

Describe the bug

The Stacks Editor does not properly render <code> elements and incorrectly escapes them when toggling from Markdown mode to rendered mode.

To Reproduce

  1. Start a new post. Make sure you are in Markdown mode, not rendered/rich edit mode.
  2. Enter the following Markdown: <code>this should be code formatted <i>with some italics inside</i></code>
    screenshot of the editor with the sample Markdown input
  3. Click the toggle to switch to rendered/rich edit mode.
  4. Click the toggle to switch back to Markdown mode.

Expected behavior

  • After step 3, the rendered post looks like: this should be code formatted with some italics inside
  • After step 3, the Markdown should be exactly what was entered after step 2

Actual behavior

  • After step 3, the rendered post has literal <code> and </code> shown. None of the sentence has typewriter formatting. The italics are shown correctly:
    screenshot of the incorrectly rendering output

  • After step 3, the Markdown has had <code> changed to `<code>` and similarly for </code>:

    `<code>`this should be code formatted <i>with some italics inside</i>`</code>`
    

    screenshot with the incorrectly escaped Markdown

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Firefox 85.0, Edge 88.0.705.56

Additional context

If I submit the answer/edit without previewing, the <code> elements are rendered correctly.

I first encountered this on a StackOverflow Enterprise installation. I have the same experience on Meta Stack Exchange.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions