# Inline formatting used when "preformatted text" formatting applied to multi-line selection

**URL:** https://meta.discourse.org/t/inline-formatting-used-when-preformatted-text-formatting-applied-to-multi-line-selection/378678
**Category:** Bug
**Tags:** composer
**Created:** [August 15, 2025, 2:04am UTC](https://meta.discourse.org/t/inline-formatting-used-when-preformatted-text-formatting-applied-to-multi-line-selection/378678 "2025-08-15T02:04:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![per1234](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/per1234/32/569645_2.png) [@per1234](https://meta.discourse.org/u/per1234)
#### Post date: [August 15, 2025, 2:04am UTC](https://meta.discourse.org/t/inline-formatting-used-when-preformatted-text-formatting-applied-to-multi-line-selection/378678/1 "2025-08-15T02:04:38Z")

</div>

### Priority/Severity:

Medium

### Platform

#### Operating System

Windows 11

#### Browser

Google Chrome 139.0.7258.67

#### Discourse

`dee24bd73b158ba97453f20035eabce430a1abcd`

### Description:

There are two styles of “preformatted text” formatting:

- inline: for use with non-prose content within a prose passage (e.g., “call the `foo` function”), or a single short line of non-prose content.
- block: for use with multiple lines of non-prose content

The user may take either of two approaches to applying formatting when using the composer:

- proactive: the formatting mode is toggled prior to adding the content to be formatted
- retroactive: the content is added in unformatted form, then selected and formatting applied to that selection

🐛 When using the composer in the “rich text editor” mode, applying “preformatted text” formatting retroactively when multiple lines are selected applies the inline style. This results in the post being difficult to read and the non-prose content being difficult to copy (a common requirement for shared code).

### Reproducible steps:

1. Open the composer.

2. Place the editor mode switch in the “rich text editor” position.

3. Add the following content to the post:

4. Select the post content.

5. Click the **\</\>** button on the composer toolbar.

🐛 Each of the selected lines was formatted individually in the inline style:

`void setup() {`

` // put your setup code here, to run once:`

`}`

`void loop() {`

` // put your main code here, to run repeatedly:`

`}`

The correct behavior would have been to put the content in a single code block:

```plaintext
void setup() {

  // put your setup code here, to run once:

}

void loop() {

  // put your main code here, to run repeatedly:

}

```

### Additional context

The Markdown editor has the correct behavior of placing the selected content in a code block when “preformatted text” formatting is applied retroactively to a multi-line selection.

* * *

I am able to reproduce the fault on [try.discourse.org](http://try.discourse.org) in “[safe mode](https://meta.discourse.org/t/how-to-use-discourse-safe-mode/53504)”.

---

<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: [August 15, 2025, 2:14am UTC](https://meta.discourse.org/t/inline-formatting-used-when-preformatted-text-formatting-applied-to-multi-line-selection/378678/2 "2025-08-15T02:14:16Z")

</div>

Thank you for the bug report, I can reproduce it.

We’ll work on a fix.

---

<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 14, 2025, 10:49pm UTC](https://meta.discourse.org/t/inline-formatting-used-when-preformatted-text-formatting-applied-to-multi-line-selection/378678/4 "2025-10-14T22:49:42Z")

</div>

Can you test again when you get a chance, please?

We have made some improvements in this PR: [DEV: make formatCode action more context-aware on rich editor by renato · Pull Request #35362 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/35362)

---

<div class="post-metadata">

### Author: ![per1234](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/per1234/32/569645_2.png) [@per1234](https://meta.discourse.org/u/per1234)
#### Post date: [October 15, 2025, 4:55am UTC](https://meta.discourse.org/t/inline-formatting-used-when-preformatted-text-formatting-applied-to-multi-line-selection/378678/5 "2025-10-15T04:55:23Z")

</div>

I confirm that the post is now formatted as expected when I perform the procedure provided in the report.

Thanks so much for the fix @renato, and for taking the time to post an update here!

---

<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 15, 2025, 12:53pm UTC](https://meta.discourse.org/t/inline-formatting-used-when-preformatted-text-formatting-applied-to-multi-line-selection/378678/6 "2025-10-15T12:53:28Z")

</div>


