# Escaped tildes in the new rich text editor are buggy

**URL:** <https://meta.discourse.org/t/escaped-tildes-in-the-new-rich-text-editor-are-buggy/376788>\
**Category:** Bug\
**Tags:** composer\
**Created:** [July 31, 2025, 10:06pm UTC](https://meta.discourse.org/t/escaped-tildes-in-the-new-rich-text-editor-are-buggy/376788 "2025-07-31T22:06:41Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbauman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mbauman/32/139835_2.png) [@mbauman](https://meta.discourse.org/u/mbauman)\
**Post date:** [July 31, 2025, 10:06pm UTC](https://meta.discourse.org/t/escaped-tildes-in-the-new-rich-text-editor-are-buggy/376788/1 "2025-07-31T22:06:41Z")

</div>

When writing a paragraph that contains escaped tildes, typing subsequent tildes does not work as expected. Specifically, if I have some text that `uses a ` (tilde)` like this, then pressing the ` key again later in the same paragraph causes the inline code span to toggle about.

The escaped ` is also problematic.

Copy-paste the following into the rich text editor to replicate it:

```md
Specifically, if I have some text that `` uses a ` (tilde) `` like this,
then pressing the <kbd>\`</kbd> key again later in the same paragraph
causes the inline code span to toggle about.

The escaped \` is also problematic.

```

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [August 1, 2025, 3:03am UTC](https://meta.discourse.org/t/escaped-tildes-in-the-new-rich-text-editor-are-buggy/376788/2 "2025-08-01T03:03:42Z")

</div>

This is a tricky one, `\` is actually not given any special semantics from what I can tell it is simply converted from `\` to `\\` during the round trip.

@renato may have some ideas here, interesting edge case.

---

<div class="post-metadata">

**Author:** ![renato](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renato/32/383632_2.png) [@renato](https://meta.discourse.org/u/renato)\
**Post date:** [October 21, 2025, 1:01am UTC](https://meta.discourse.org/t/escaped-tildes-in-the-new-rich-text-editor-are-buggy/376788/9 "2025-10-21T01:01:02Z")

</div>

> [@mbauman](#):
>
> Specifically, if I have some text that `uses a ` (tilde)` like this, then pressing the ` key again later in the same paragraph causes the inline code span to toggle about.

This should be fixed now, can you still reproduce this issue running `latest` (eg. on Meta/Try)?

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [October 22, 2025, 6:00am UTC](https://meta.discourse.org/t/escaped-tildes-in-the-new-rich-text-editor-are-buggy/376788/10 "2025-10-22T06:00:18Z")

</div>

```plaintext
\` still behaves somewhat weird for me. particularly \` becomes \\\` and then when you look add an extra ` stuff closes.

```

Feels like a real tough one to sort the whole way.

---

<div class="post-metadata">

**Author:** ![renato](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renato/32/383632_2.png) [@renato](https://meta.discourse.org/u/renato)\
**Post date:** [October 22, 2025, 6:01am UTC](https://meta.discourse.org/t/escaped-tildes-in-the-new-rich-text-editor-are-buggy/376788/11 "2025-10-22T06:01:14Z")

</div>

Sorry, I don’t follow. \` is not supposed to escape it when typed directly in the rich editor.

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [October 22, 2025, 6:03am UTC](https://meta.discourse.org/t/escaped-tildes-in-the-new-rich-text-editor-are-buggy/376788/12 "2025-10-22T06:03:03Z")

</div>

In markdown type

```plaintext
\`hello

```

Then flick to to rich and type

```plaintext
` 

```

That creates a code block and technically it should render

`hello`

---

<div class="post-metadata">

**Author:** ![renato](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renato/32/383632_2.png) [@renato](https://meta.discourse.org/u/renato)\
**Post date:** [October 22, 2025, 6:06am UTC](https://meta.discourse.org/t/escaped-tildes-in-the-new-rich-text-editor-are-buggy/376788/13 "2025-10-22T06:06:41Z")

</div>

This is working as intended, the escaping is lost when parsed (when toggled from Markdown to rich text) and that’s expected as escaping with the \ is a markdown/code concept.

The supported way of escaping in rich editor mode is backspacing after the input rule takes place: `like this`.

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [October 22, 2025, 6:10am UTC](https://meta.discourse.org/t/escaped-tildes-in-the-new-rich-text-editor-are-buggy/376788/14 "2025-10-22T06:10:15Z")

</div>

Oh I see, thanks for clarifying

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mbauman/32/139835_2.png) [@mbauman](https://meta.discourse.org/u/mbauman)\
**Post date:** [October 27, 2025, 8:45pm UTC](https://meta.discourse.org/t/escaped-tildes-in-the-new-rich-text-editor-are-buggy/376788/16 "2025-10-27T20:45:45Z")

</div>

Yes, this is a little better, but it’s still impossible to actually write any inline code that has a ``` in it without some fiddling after first getting it wrong. You can’t preemptively use more than one ```. Typing that ` from above or the escaped code that creates it (`<kbd>\`</kbd>`) are perfect examples of things that are nigh-impossible to do with the WYSIWYG mode, even with fiddling.

I get that you can backspace to undo formatting and implicitly “escape” it, but I have a hard time predicting when formatting will take affect. For example, ``4*5*6`` writes naturally when immediately preceded by that hanging-open ```, but that’s not always the case. `4*5*6=120` types nicely but `120=456` doesn’t (the five was transiently italicized there).

---

<div class="post-metadata">

**Author:** ![renato](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renato/32/383632_2.png) [@renato](https://meta.discourse.org/u/renato)\
**Post date:** [October 27, 2025, 8:51pm UTC](https://meta.discourse.org/t/escaped-tildes-in-the-new-rich-text-editor-are-buggy/376788/17 "2025-10-27T20:51:37Z")

</div>

What do you suggest we do in these specific cases? Do you have an example of another product that does it in a way we can take inspiration from?

You can type `, select it, then type ``` or `cmd+E` to toggle it to inline mark.

You can hit `cmd+E` _and then_ type `. You can use `cmd+E` to toggle the code mark for the next character when typing, just the same you can with `cmd+B` for bold or `cmd+I` for italic.

The `<kbd>` input rule auto-selects an empty character (to keep the browser from auto-deleting an empty node), so you just have to deselect it first (because hitting ` in this case makes an inline mark of the selection – we can potentially remove that behavior, though, as we have `cmd+E` for this).

I understand those may not be ideal, but they are the compromises we have for all the particularities we have within Discourse. We’re open to suggestions, if you can share how you’d like it to work instead.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mbauman/32/139835_2.png) [@mbauman](https://meta.discourse.org/u/mbauman)\
**Post date:** [October 27, 2025, 9:10pm UTC](https://meta.discourse.org/t/escaped-tildes-in-the-new-rich-text-editor-are-buggy/376788/19 "2025-10-27T21:10:08Z")

</div>

Well, I opened this topic when it was looking like enabling the WYSIWYG editor would make the markdown one monospace (cf [Monospace font in the Markdown-only editor - #58 by mbauman](https://meta.discourse.org/t/monospace-font-in-the-markdown-only-editor/359936/58) ). I’m very glad that’s no longer the case and that this is now configurable, because, yeah, I’ve never met a markdown WYSIWYG editor I liked. This is getting close, though. 🙂

I write _a lot_ of markdown in a _lot_ of text-boxes (in both rendered and non-rendered contexts… to the point that I almost consider un-rendered markdown “formatted”), and I know I’m quite the outlier. I do think, though, that there’s a cluster of us outliers, and we tend to gather in the context of programming language forums.

The most valuable part is to make the auto-formatting as predictable as possible, so I can learn when I need to backspace, but that’s quite hard to learn in my experience.
