Page MenuHomePhabricator

Never disturb whitespace / paragraph breaks when inserting templates containing categories
Open, Needs TriagePublic

Description

A template T containing a category,

A[[Category:B]]C

is safe in that it will not destroy any paragraph breaks here,

E

{{T}}

F

when rendered. Alas, if the template is

[[Category:B]]C

or

A[[Category:B]]

it will destroy the paragraph break neighboring the [[Category:B]]!

I becomes just like if the user used E{{T}} or {{T}}F.

(I am guessing that this is some kind of overcorrection for some earlier
behavior where there was always a paragraph break rendered before and
after [[Category:B]].)

Anyway the user now has no way to preserve his paragraph breaks, short
of having to use raw <p>'s:

E
<p></p>
{{T}}
<p></p>
F

(Why would anyone want to use such a template?
Well, to add a category to a page at the same time making a note on it.)

The user might want to use his template in all kinds of different
whitespace / paragraph break environments.

V {{T}}

W{{T}}X {{T}}Z

Mediawiki should never disturb (eat or add) any whitespace or paragraph
breaks when inserting templates containing categories.

(Or even if they don't contain categories, for that matter.)

(I did not test the case where there was no A or C. Please do. (Why
would someone make such a template with no A, C text at all? Well, e.g.,
T=[[Category:Bugs to be fixed by 2019]] so one could just adjust the
date of T instead of editing each page where {{T}} was used.))

Event Timeline

Example of page that would be affected by bug:
http://radioscanningtw.jidanni.org/index.php?title=台北市警察局中山分局

The first template
( http://radioscanningtw.jidanni.org/index.php?title=Template:Digital )
used in the page employs the ABC embedding technique above.

Alas for the second template,
http://radioscanningtw.jidanni.org/index.php?title=Template:C
there is no such room for a workaround.

Thankfully the the trailing text in the first template prevents the following paragraph break from getting eaten.

Jidanni renamed this task from Never disturb whitespace / paragraph breaks when inserting templates to Never disturb whitespace / paragraph breaks when inserting templates containing categories.Aug 11 2017, 8:21 PM
Jidanni updated the task description. (Show Details)
Jidanni updated the task description. (Show Details)

I'm thinking that if many pages depend on the broken behavior, then maybe there could be a zero width {{no-op}} operator, that one could put in the A or C positions, to ensure whitespace is not eaten... but this seems like just more badness...