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:
-
Open the composer.
-
Place the editor mode switch in the “rich text editor” position.
-
Add the following content to the post:
void setup() { // put your setup code here, to run once: } void loop() { // put your main code here, to run repeatedly: }
-
Select the post content.
-
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:
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 in “safe mode”.