Page MenuHomePhabricator

Use pre tag for preformatted text
Open, Needs TriagePublic

Description

The VisualEditor should use <pre>text</pre> when making text preformatted or when adding preformatted text instead of text. Using the pre tag allows for easy multiline preformatted paragraphs without having to preformat each individual line. It is also easier to understand that the text is preformatted when the pre tag is used when looking over the source code.

Event Timeline

JTannerWMF subscribed.

Thanks for this suggestion, we can't prioritize this at this time.

I'm not sure if this would make sense. In wikitext, <pre>text</pre> (pre tags) behave differently than text (indent-pre) – the tags disable all formatting (like <nowiki>), but the indent doesn't (you can have bold, italic, etc. inside the preformatted text). So we would have to change the markup to use indent-pre rather than pre tags if any formatting is applied in the visual editor, which would make for annoying diffs.

Currently, we actually have a separate popup tool for editing pre tags, which is the only way to make it impossible to add formatting to it inside visual editor.


Some screenshots and examples to illustrate:

I'm testing with wikitext like this:

<pre>
'''this text is not bold''', apostrophes are visible
</pre>

 '''this text is bold''', apostrophes are treated like markup

Wikitext editor and preview:

en.wikipedia.org_w_index.php_title=User_Matma_Rex_sandbox&action=submit(Laptop with small screen) (1).png (1×2 px, 206 KB)

In visual editor, the indent-pre can be edited directly on the editing surface and formatting can be added; but the content of pre tags can only be edited in the popup (or converted to indent-pre using the "Allow text styling" button).

en.wikipedia.org_w_index.php_title=User_Matma_Rex_sandbox&action=submit(Laptop with small screen) (2).png (1×2 px, 289 KB)
en.wikipedia.org_w_index.php_title=User_Matma_Rex_sandbox&action=submit(Laptop with small screen) (3).png (1×2 px, 294 KB)
en.wikipedia.org_w_index.php_title=User_Matma_Rex_sandbox&action=submit(Laptop with small screen) (4).png (1×2 px, 210 KB)

That makes sense. Maybe then an option to insert "Preformatted block" can be added under the "Insert" dropdown or when editing text that is preformatted with a space at the start, pressing enter (or at least shift + enter) can add a new preformatted line right below the current one.