Page MenuHomePhabricator

Page status indicator tags leave whitespace behind
Open, LowPublic

Description

When a page status indicator is used, it is most probably on a line by itself, e.g.

== External links ==
* [http://www.example.com Foobar]

<indicator name="featured-article">☆ Featured</indicator>

[[Category:Foo]]

However, this causes a whitespace block between the external link and the category list, because the space occupied by the indicator tag gets rendered as <p><br /></p>.

By omitting both empty lines around it, the space disappears, but just one is enough to cause it, and it is quite difficult to get rid of all surrounding whitespace, especially when the indicator markup is inserted using templates (not to mention that two or more successive indicator tags would all need to be on a single line). Also note the empty line usually used before categories, and cf. the behavior of various parser constructs (e.g. __NOTOC__).

I don’t know whether this is an inherent limitation of the chosen implementation method (parser tag hook), or how to fix this correctly. I was able to suppress the space by changing CoreTagHooks::indicator to return '<!-- -->' (which does appear even in the final HTML, as it results in <p><!-- --></p>) instead of just '', but that is obviously quite a hack.

Event Timeline

Mormegil created this task.Nov 28 2014, 3:07 PM
Mormegil raised the priority of this task from to Needs Triage.
Mormegil updated the task description. (Show Details)
Mormegil added a project: MediaWiki-Parser.
Mormegil changed Security from none to None.
Mormegil added a subscriber: Mormegil.

Change 176481 had a related patch set uploaded (by Jackmcbarn):
Make indicators use nowiki strip markers

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

Patch-For-Review

See the patch history and the comments in Gerrit – this originally was implemented as a parser function, but was changed to a XML tag because of implementation problems with the parser-function implementation:

PS10 switches to XML-style tags. This conveniently rids us of the mess in action=expandtemplates API.

GOIII added a subscriber: GOIII.Dec 16 2014, 5:07 AM

Umm... The <p><br /></p> phenomenon is NOT indicator tag specific. The following will produce exactly the same result...

== External links ==
* [http://www.example.com Foobar]

<references />

[[Category:Foo]]

... for example. Wrapping the ''tag(s)'' inside a div like so...

== External links ==
* [http://www.example.com Foobar]

<div><indicator name="featured-article">☆ Featured</indicator></div>

[[Category:Foo]]
  • outsmarting the #&6^@! wiki mark-up's auto-insertion of an opening P<aragraph> tag in the process -- works in most cases.

As far as I know, this has been the case since the early days of wiki-mark-up's inception. Its been a galactic pain in the azz for projects like Wikisource and Wikibooks where faithful reproduction of published (or static) content is a major, if not the primary, project mission.
The ''other'' approach for a work-around to this phenomenon is to use some combination of

.mw-body p > br {
	display: none;
}
.mw-body p > br + br {
	display: block;
}
.mw-body p:empty {
	display: none;
}
.mw-body p > br:only-child {
	display: none;
}

... in a site or user specific .css (will eventually break something beyond just resolving just the intended instances in my travels to date). Wiki-wide, the 3rd .css entry might be something to look at in at least eliminating the generation of the <br /> tag some how (is ''new'' in css3 fwiw).

OK, as this seems to have stalled somehow (are we the only wiki to use this? or are we the only wiki to have noticed the redundant whitespace caused by this?), I have used the workaround on cswiki to wrap all <indicator> uses into (otherwise useless) <span>s.

Aklapper triaged this task as Low priority.Mar 23 2015, 5:20 PM
Aklapper added a subscriber: Aklapper.

OK, as this seems to have stalled somehow

https://gerrit.wikimedia.org/r/#/c/176481/ needs rework.

This is probably a wontfix per @GOIII above; this is a long-standing behavior that, while incredibly inconvenient, would be even more incredibly inconvenient to change.

matmarex removed a subscriber: matmarex.Mar 23 2015, 6:03 PM

What exactly is the long-standing behavior? <indicator> is a completely new tag, it has no long-standing behavior. How many long-standing XML-type tags are supposed to have empty output (and usually expected to be on a separate line)? Definitely not <references> – empty references are a marginal case.

As is, <indicator> is just unusable and needs to always be manually wrapped on wiki into a <span> or something. If such a hack is the only possible “solution”, so be it, but why not move it to MediaWiki and save some human time, at least? (And, if someone sometime comes with a better solution, the hack could be fixed at one place instead on every wiki.)

Or, we could just drop indicator and go back to on-wiki CSS hacks.

As is, <indicator> is just unusable and needs to always be manually wrapped on wiki into a <span> or something.

There is a much better workaround than wrapping into a <span>: Just place a <nowiki/> before the <indicator> or after the </indicator>. Example usages:

There is a much better workaround than wrapping into a <span>: Just place a <nowiki/> before the <indicator> or after the </indicator>. Example usages:

Great, just as I said, every single wiki will need to develop its own workarounds because of a feature already broken on arrival.

What exactly is the long-standing behavior? <indicator> is a completely new tag, it has no long-standing behavior. How many long-standing XML-type tags are supposed to have empty output (and usually expected to be on a separate line)? Definitely not <references> – empty references are a marginal case.

Indicator tag uses the core tag functions, similar to pre, gallery and co, which are long standing. It just a new type of that, is has no new wikitext parsing to ignore whitespaces.

As is, <indicator> is just unusable and needs to always be manually wrapped on wiki into a <span> or something. If such a hack is the only possible “solution”, so be it, but why not move it to MediaWiki and save some human time, at least? (And, if someone sometime comes with a better solution, the hack could be fixed at one place instead on every wiki.)

The most use of this indicator tag (at least on dewiki) is inside templates, so only some places have to handle the whitespaces correct, but when used plain in pages, it could be hard.

Change 176481 abandoned by Thiemo Kreuz (WMDE):
Make indicators use nowiki strip markers

Reason:
Via users GOIII and Bartosz. Also, this is 6 years old already.

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