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

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

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

    void setup() {
      // put your setup code here, to run once:
    
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
    
    }
    
  4. Select the post content.

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

:bug: 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”.

3 Likes

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

We’ll work on a fix.

2 Likes