Page MenuHomePhabricator

Implementing line breaks on wiki viewer for plain text content model
Closed, ResolvedPublic

Assigned To
Authored By
Kwj2772
Aug 21 2018, 4:21 PM
Referenced Files
F41464302: image.png
Nov 7 2023, 7:45 AM
F41464304: image.png
Nov 7 2023, 7:45 AM
Tokens
"Like" token, awarded by Novem_Linguae."Like" token, awarded by Pppery.

Description

For pages with a plain text content model, the wiki viewer should render the text as written, including line breaks.

Currently, if the text of a page includes line breaks, the viewer should process and render the line breaks, but it doesn't.*

Please implement line breaks on the wiki viewer for plain texts. Best regards.

Event Timeline

Could you explain why can't you manually put <pre> tags around the content instead?

<pre> tag may be used instead. But line breaks are completely ignored in plain text mode however many line breaks are inserted among lines. That's the problem.

That sounds like correct behavior if you throw random text in and get it interpreted as HTML.
I don't see a use case provided in this task why <pre> is not sufficient.

Bugreporter2 subscribed.

Kwj2772 is right.

If the content model of a page is plain text, it should be displayed as plain text, in a monospaced font, with carriage returns meaning carriage returns.

See e.g. https://teflpedia.com/MediaWiki:Sidebar

Such a page isn't wikitext, so shouldn't have a wikitext content model. Only wikitext pages should have a wikitext model.

Adding <pre> tags only works if the content model is wikitext. This is not a fix.

At present, plain text files are displayed in a variable-width font and carriage returns are ignored. It's not possible to fix this using CSS because the CSS doesn't distinguish between content models. (I think there could be a JavaScript-based fix, but standard CSS fix is better).

There should be a CSS element that identifies the content model as plain text.

A patch for this should probably modify something in includes/content/TextContentHandler.php

Change 972243 had a related patch set uploaded (by Novem Linguae; author: Novem Linguae):

[mediawiki/core@master] Plain text content model should convert line breaks to <br>

https://gerrit.wikimedia.org/r/972243

Thanks for taking the time to look at this, Novem_Linguae.

The patch seems to work and addresses the issue mentioned.

But, a plain text page is better presented in a monospace font such as Courier rather than as a proportional font. Remember when you source-edit a wiki, you're looking at that source code in monospace font -- the same when you open a plain text file in Notepad.exe

So, might you also be able to change the font to a monospace, or would that have to go into a separate bug (that might never get fixed)?

Bugreporter2 changed the task status from Open to In Progress.Nov 7 2023, 12:58 PM

Sure, worth looking into. I made an unresolved comment in the Gerrit patch so I don't forget.

But wrapping plain text in <pre> tags would now display it in monospaced font, right?

https://www.w3schools.com/tags/tag_pre.asp

Yes. That's what the code reviewer wanted. Seems reasonable.

Change 972243 merged by jenkins-bot:

[mediawiki/core@master] Plain text content model should show line breaks

https://gerrit.wikimedia.org/r/972243

Jdforrester-WMF assigned this task to Novem_Linguae.
Jdforrester-WMF subscribed.

Will ship to production this week.