Page MenuHomePhabricator

Line breaks may be inserted in preformatted text in tables
Closed, InvalidPublic

Description

When preformatted text is put in a table (using <pre>), line breaks are sometimes inserted. This seems to depend on the content of cells in other columns; more content -> bigger cell -> less space for the cell with preformatted text.

Steps to Reproduce:

  1. Edit a page with Edit Source
  2. Paste the following wikitext:
{| class="wikitable"
|-
!Option
!Default value
!Documentation
|-
| WikispeechServerUrl
| <pre>"https://morf.se/wikispeech/"</pre>
| The URL for the TTS server to use.
|-
| WikispeechRemoveTags
|
<pre>{
    "editsection": true,
    "toc": true,
    "table": true,
    "sup": { "class": "reference" },
    "div": { "class": "thumb" },
    "ul": true,
    "ol": true
}</pre>
| Lists which tags should be removed completely, i.e. including any content. Keys are tag names and the values determine whether a tag should be removed, as follows:
* If <code>true</code>, remove all tags of that type.
* If an object (array in [[Manual:LocalSettings.php | ''LocalSetting.php'']]) containing the <code>"class"</code> key, only tags that also have the value of <code>"class"</code> as class will be removed.
* If false, tags of that type will not be removed. This can be used to override default criteria in ''LocalSetting.php''.
|}
  1. Preview

Actual Result:
The preformatted text contains line breaks:

preformatted-line-breaks.png (424×938 px, 56 KB)

This depends on window size.

Expected Result:
The preformatted text is displayed as in the code. Other cells may be shrunk as a result.

Other Information:
This was tested on www.mediawiki.org in FIrefox (48.0) and Google Chrome (52.0.2743.116) with the same result. When the HTML code for the table is used on another page, the preformatted text behaves as expected.

Event Timeline

Aklapper edited projects, added MediaWiki-Parser; removed MediaWiki-General.

There are css rules with "white-space: pre-wrap" for the elements your are refer. So it looks like this works as expected.

Try

<pre style="white-space:pre;">

to get another behaviour or define a fix width on the table column (in the header) to get enough space for the <pre> to show the text without line breaks.

That worked as a work around. Thank you.

matmarex subscribed.

I think this is the intended behavior,