Page MenuHomePhabricator

MediaWiki unable to render any <pre> tags with indents.
Closed, DuplicatePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Make a pre block with an indent, as such:
:<pre>
import pywikibot
site = pywikibot.Site("wikidata", "wikidata")
data = {"claims": []}
claim = pywikibot.Claim(site, "P31")
claim.setTarget(pywikibot.ItemPage(site, "Q5"))
data.append(claims.toJSON())
new_item = pywikibot.ItemPage(site)
new_item.editEntity(data, summary="Making new item...")
</pre>

What happens?: The text renders in a single line outside of the <pre> tags. From Special:ExpandTemplates, this is rendered:

<div class="mw-parser-output"><dl><dd><pre></pre></dd></dl>
<p>import pywikibot
site = pywikibot.Site("wikidata", "wikidata")
data = {"claims": []}
claim = pywikibot.Claim(site, "P31")
claim.setTarget(pywikibot.ItemPage(site, "Q5"))
data.append(claims.toJSON())
new_item = pywikibot.ItemPage(site)
new_item.editEntity(data, summary="Making new item...")
</p>
</div>

What should have happened instead?: The code should be inside the <pre> tag.

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.): The VisualEditor is able to correctly render it for some reason.

Event Timeline

RPI2026F1 updated the task description. (Show Details)
Reedy renamed this task from Mediawiki unable to render any <pre> tags with indents. to MediaWiki unable to render any <pre> tags with indents..Dec 2 2022, 2:59 PM

Don't use : markup to indent something. It is a definition list item, not an indent. If you want to indent a pre, use <pre style="margin-left: 1em"> (or other number).

That aside, I'll be closing this duplicate momentarily.

Why does almost every Wikipedia use it for replying to talk page comments if it's not an indent?

Why does almost every Wikipedia use it for replying to talk page comments if it's not an indent?

Inertia. And no viable wikitext alternative for that use case.

Seems like every so often someone tries to make a good replacement but everyone hates it on the basis that it's new and that you cannot edit multiple sections at once.