Last modified: 2011-04-30 01:16:44 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 18994 - When template evaluated, extraneous line break introduced
When template evaluated, extraneous line break introduced
Status: NEW
Product: MediaWiki
Classification: Unclassified
Templates (Other open bugs)
1.14.x
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: tidy
  Show dependency treegraph
 
Reported: 2009-05-28 23:46 UTC by Dan Nessett
Modified: 2011-04-30 01:16 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Tar file containing the html files described in Comment #10 (300.00 KB, application/x-tar)
2009-06-05 16:03 UTC, Dan Nessett
Details
test procedure used to illustrate the bug (834 bytes, text/plain)
2009-06-05 16:09 UTC, Dan Nessett
Details

Description Dan Nessett 2009-05-28 23:46:27 UTC
I don't know exactly what is the cause, but there is a definite problem. I can only explain the problem, not the solution. Do this: Use three Sandboxes. In the first save the following template definition:<nowiki><includeonly>'/n'{{#switch: {{{OP}}}'/n' | nop'/n' | note = <ref group=fn name=first></ref>}}'/n'</includeonly>'/n'</nowiki> (I am using the line break character here, because I don't know the rules for Bugzilla markup. Obviously, don't put in the nowiki tags. I am including them because I don't know whether Bugzilla parses wiki markup). In the second save the following <nowiki>{{subst:First Sandbox}}</nowiki>. In the third save: <nowiki>==Chapter 1{{Second Sandbox | OP = note}}==</nowiki>. In the Third Sandbox, the text between "Chapter 1" and the transcluded text from Second Sandbox is separated by a line break. Now, go back and edit the Second Sandbox. At the end is a line break character that was added when the Second Sandbox was saved. Delete this line break character (moving the cursor from the blank line at the end of the Sandbox to the end of the first non-blank line). Save the Second Sandbox. Now edit the Third Sandbox and again save <nowiki>==Chapter 1{{Second Sandbox | OP = note}}==</nowiki>. The result is there is no line break between "Chapter 1" and the text transcluded from the Second Sandbox. The Header line renders properly.
Comment 1 Mike.lifeguard 2009-05-29 00:49:51 UTC
I'm almost certain there is a duplicate bug somewhere... maybe bug 529, bug 12974 or bug 1878? Haven't looked very closely.
Comment 2 Dan Nessett 2009-05-29 00:56:39 UTC
(In reply to comment #1)
> I'm almost certain there is a duplicate bug somewhere... maybe bug 529, bug
> 12974 or bug 1878? Haven't looked very closely.
> 

I found two bugs that might be related, but the description is sufficiently different that I decided to submit the report. Bug 1878 reports that templates insert a newline character at the beginning of text. However, the behavior I observed was an extraneous line break at the end. Bug 12974 also describes something similar, but comment # 6 from Mormegil suggests that bug has something to do with template calls that start with {|, :, ;, #, or *. I am not sufficiently expert to decide whether either of these bugs are duplicates or not. It is interesting that Bug 1878 was originally submitted in 2005, yet it is still has the status of NEW (last comment was 05/2006).
Comment 3 Happy-melon 2009-06-04 16:23:30 UTC
Hang on, so you're saying that removing the linebreak from the *end* of the template code removes a linebreak from the *beginning* of the expansion when that template is transcluded?
Comment 4 Dan Nessett 2009-06-04 17:23:04 UTC
(In reply to comment #3)
> Hang on, so you're saying that removing the linebreak from the *end* of the
> template code removes a linebreak from the *beginning* of the expansion when
> that template is transcluded?
> 

If you would have asked me that question on Monday, I would have said yes. Now I have to qualify my response. Removing "the linebreak from the 'end' of the template code" does appear to remove "a linebreak from the 'beginning' of the expansion when that template is transcluded'" on my personal mediawiki installation (Mediawiki 1.14.0). However, now that I have moved the Bref template to Wikibooks, this tactic seems to fail. I am getting extraneous line feeds before the template transclusion text even when I clean up the line feed as described. (If you want to see for yourself, go to User:Dnessett/Template/Bref/Examples and click on Chapter 3 in Example 4 - the extra line break causes the footnote in the header to break the header transclusion) Frankly, I am pretty confused about what is going on. There seems to be something in the template expansion code that inserts line breaks for no apparent reason. I even tried to bracket the template calls with <span style="white-space:nowrap"></span> tags (using this idea from the {{nowrap begin}} {{nowrap end}} templates on Wikipedia), but that doesn't work either. This is a pernicious problem that I am having trouble solving.
Comment 5 Dan Nessett 2009-06-04 17:51:43 UTC
I found a workaround.

This doesn't fix the bug, but I seem to have found a workaround that may help identify what is going on. First, some background. The Bref template consists of a core template and several helper templates that use the core. If I change the Bref core template so there is no space between the {{switch keyword and an HTML comment in the core, the extraneous line break is eliminated. I don't have to delete the line break at the end of the helper templates as I did on my personal mediawiki installation. Since I haven't read the underlying template expansion code and therefore have no idea what it does, this is all a bit like magic to me. I can only report what happens, not why.
Comment 6 Dan Nessett 2009-06-04 17:55:24 UTC
Oops. I should have said "If I change the Bref core template so there is no space between the {{switch keyword and the <includeonly> tag. The helper templates have HTML comments. The core doesn't
Comment 7 Happy-melon 2009-06-04 21:56:28 UTC
That's Got To Be Tidy...  :-D

Is HTML Tidy enabled on your test wiki?  see [[w:HTML tidy]], [[mw:Manual:$wgUseTidy]], etc.  That's probably the biggest difference between your test wiki and WMF.

What does the HTML page source look like?
Comment 8 Dan Nessett 2009-06-04 23:47:52 UTC
(In reply to comment #7)
> That's Got To Be Tidy...  :-D
> 
> Is HTML Tidy enabled on your test wiki?  see [[w:HTML tidy]],
> [[mw:Manual:$wgUseTidy]], etc.  That's probably the biggest difference between
> your test wiki and WMF.
> 
> What does the HTML page source look like?
> 

No, HTML Tidy is not enabled on my personal wiki. I'm not sure how to answer your last question. Do you want me to save the HTML source generated by the Mediawiki parser and put it somewhere so you can examine it? Or do you mean something else?
Comment 9 Happy-melon 2009-06-05 08:54:05 UTC
(In reply to comment #8)
> Do you want me to save the HTML source generated by the
> Mediawiki parser and put it somewhere so you can examine it? 
> 

Yes please; if you could copy the snippet from the final output source from your test wiki and from somewhere that's got Tidy enabled and post them here, we can compare the two.  
Comment 10 Dan Nessett 2009-06-05 15:48:54 UTC
(In reply to comment #9) 
> 
> Yes please; if you could copy the snippet from the final output source from
> your test wiki and from somewhere that's got Tidy enabled and post them here,
> we can compare the two.  
> 

Well, things never seem to work out. Now both my test wiki and WIkibooks do not introduce an extraneous line break if I save the second sandbox, then reedit it and delete the line break at the end (see the original bug report text). I have the html files you requested, but I can't figure out a way to attach them to this reply in the bug report. I have sent them to you directly, but that doesn't provide a record of the problem in this bug report. The tar file comprises 10 html files. The first 3 (prefixed Test_1_) are the html generated when I perform the steps given in the original bug report text. The next 2 (Test_2_*) are the html generated when I reedit the second sandbox and delete the line break at the end of the switch statement, bringing the cursor up to the }} characters that end the switch statement. The last 5 files are the html for the same activity performed on Wikibooks. Let me know if there is a way to attach this tar file to this bug report record.
Comment 11 Dan Nessett 2009-06-05 16:03:17 UTC
Created attachment 6198 [details]
Tar file containing the html files described in Comment #10
Comment 12 Dan Nessett 2009-06-05 16:09:28 UTC
Created attachment 6199 [details]
test procedure used to illustrate the bug

This file contains the procedure that demonstrates the bug.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links