Page MenuHomePhabricator

Allow pre tag be indented as source can be
Closed, DuplicatePublic

Description

Insert following two examples to some wikipage and compare the outputs:
Example 1

Hello
:: Hi
::: Would you take a look on this code?
:::<pre>
code
</pre>

Example 2

Hello
:: Hi
::: Would you take a look on this code?
:::<source>
code
</source>

As you can see, the source tag is correctly indented, but the pre tag isn't. This behavior looks like a bug. If this behavior is intensional, then it should be reconsidered.

Currently there are some templates (like this one on cswiki) used as a hack to indent pre tag somehow, but it is not ideal.

Event Timeline

Dvorapa created this task.May 3 2017, 4:26 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMay 3 2017, 4:26 PM
Arlolra added a subscriber: Arlolra.

This can probably be closed as a duplicate of T3115

What's happening is,

> echo -e ":<pre>\nhi\n</pre>" | php maintenance/parse.php
<dl><dd><pre></dd></dl>
<p>hi
</p>
</pre>

and then,

echo -e ":<pre>\nhi\n</pre>" | php maintenance/parse.php --tidy
<p>hi</p>

The reason this works for <source> is because in doBlockLevels() extension tag content hasn't been replaced yet and so it all exists on a single line as a replacement token.

The same is true for the other pseudo-extension tag, <gallery>, as for <pre>.

> echo -e ":<gallery>\nhi\n</gallery>" | php maintenance/parse.php --tidy
<dl>
<dd>
<ul class="gallery mw-gallery-traditional"></ul>
</dd>
</dl>
<div style="width: 155px">
<div class="thumb" style="height: 150px;">Hi</div>
<div class="gallerytext"></div>
</div>

Note that Parsoid gives you what you want here,

> echo -e ":<pre>\nhi\n</pre>" | node bin/parse --normalize
<dl>
<dd><pre>hi</pre></dd>
</dl>
Arlolra triaged this task as Low priority.Jul 18 2017, 10:07 PM