Page MenuHomePhabricator

Signature appears de-indented when comment ends in multi-line template
Open, Needs TriagePublic

Description

The signature appears outside of the Preview area in the Reply tool's source mode:

Screen Shot 2020-06-17 at 7.27.50 PM.png (1×1 px, 373 KB)

Event Timeline

ppelberg renamed this task from Signature appears outside of Preview to [Regression] Signature appears outside of Preview.Jun 18 2020, 2:44 AM

This works fine on live, this is just an incorrectly configured template on beta so it is essentially the same root cause as T253150.

Indeed if you save this comment the signature ends up de-indented, so the preview is correctly showing you how the template is broken when you sign immediately after it (e.g. {{quote}}~~~~)

The only way to avoid that would be to have a linebreak after the template:

{{quote}}
~~~~

however this would break templates which are supposed to be inline, e.g. {{support}} ~~~~

As we really have no way of telling if a template should have whitespace after it, we can't fix this.

Esanders renamed this task from [Regression] Signature appears outside of Preview to Signature appears de-indented when comment ends in multi-line template.Jun 22 2020, 2:17 PM
JTannerWMF subscribed.

We have yet to observe or receive reports of this happening in production so we will depriortize this.

As we usually insert spaces before signatures, incorrectly setup templates can cause the signature to appear preformatted (monospace, with a grey box around);

{{Welcome box}} ~~~~

expands to

{|
welcomebox table
|}
 ~~~~

Note the leading space on the last line of the expanded wikitext.

The solution is again to fix the template to remove any trailing newlines, it will then expand to:

{|
welcomebox table
|} ~~~~

which renders as expected.

As we usually insert spaces before signatures, incorrectly setup templates can cause the signature to appear preformatted (monospace, with a grey box around);

This seems to have happened again to @Patriccck at cs.wiki. [i]

Although this time, the "preformatting" seems to have been caused by the topic's author inserting a blank line [by pressing ] in the New Discussion Tool's Description field.

Note: I've been able to reproduce this as well.[ii]


i. https://cs.wikipedia.org/w/index.php?diff=19529578&oldid=19529565&title=Diskuse_s_wikipedistou:Patka&curid=371991&diffmode=source
ii. https://en.wikipedia.beta.wmflabs.org/w/index.php?title=Talk%3ACats&type=revision&diff=480481&oldid=476829

This seems to have happened again to @Patriccck at cs.wiki. [i]

Although this time, the "preformatting" seems to have been caused by the topic's author inserting a blank line [by pressing ] in the New Discussion Tool's Description field.

Note: I've been able to reproduce this as well.[ii]

Luckily that's an easier bug, I submitted a patch on T276612.

Also, the bug with preformatted text is currently not reflected in previews. Patch https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DiscussionTools/+/669121 "fixes" it so that the wikitext preview also displays the preformatted text, exactly like it will look after saving.

As for actually fixing the problem (without modifying the templates)… here's a stupid idea: what if we just replace the normal space with &nbsp;, or with <nowiki /> , whenever the wikitext of the reply ends with a template?