I'm seeing this weird anomaly in wiki syntax. Suppose you have this template, called A:
{{#switch: {{{1}}} | foo = [[File:foo.png]] | bar = [[File:bar.png]] | baz = [[File:baz.png]] | UNKNOWN }}
Now, with something like
{{A|foo}} and {{A|bar}}.
I get
<p><img src="foo.png"/> </p> <pre>and <img src="bar.png"/> </pre> <p>. </p>
That is, the " and {{A|bar}}" is treated as a new paragraph. However, if I have
[[File:foo.png]] and [[File:bar.png]].
I get
<p><img src="foo.png"/> and <img src="bar.png"/>. </p>
So there is something with the newlines that are at the end of each case, I'd presume. Compacting this all into one line appears not to help. How can I change Template:A so that I get the more desirable second outcome?
Kelvin Chung wrote:
So there is something with the newlines that are at the end of each case, I'd presume. Compacting this all into one line appears not to help. How can I change Template:A so that I get the more desirable second outcome?
You have a new line at the bottom (and/or the top) of Template:A
MW 1.15.1 (and before)
Does anyone know what causes this and how to remedy?
Wiki code only recognizes table commands ("{|", "|-", "|}") when they begin on a new line. Therefore if your template is using these commands, the first line of your template MUST be a newline - otherwise the wiki code is likely to be continued on the line in which it is referenced.
In the mediawiki article editor, this newline is stripped when it is re-edited and must be manually reinserted. So if you create a template such as this (note the necessary preceeding empty new line): --------
{| class="smwtable sortable" ! Col Hdr 1 ! Col Hdr 2 --------
When you go in and edit again - even though the preceeding new line had been saved, it will be removed, and you will need to add it again. Example, before line reinserted:
-------- {| class="smwtable sortable" ! Col Hdr 1 ! Col Hdr 2 --------
Any ideas?
Jack
Hi,
2010/1/21 Jack D. Pond jack.pond@psitex.com:
MW 1.15.1 (and before)
Does anyone know what causes this and how to remedy?
Wiki code only recognizes table commands ("{|", "|-", "|}") when they begin on a new line. Therefore if your template is using these commands, the first line of your template MUST be a newline - otherwise the wiki code is likely to be continued on the line in which it is referenced.
In the mediawiki article editor, this newline is stripped when it is re-edited and must be manually reinserted. So if you create a template such as this (note the necessary preceeding empty new line):
{| class="smwtable sortable" ! Col Hdr 1 ! Col Hdr 2
When you go in and edit again - even though the preceeding new line had been saved, it will be removed, and you will need to add it again. Example, before line reinserted:
{| class="smwtable sortable" ! Col Hdr 1 ! Col Hdr 2
Any ideas?
You could circumvent the issue by adding a dummy tag or text on the first line in the template, like <noinclude></noinclude>. That way the first line is no longer empty, doesn't get stripped and should have no further ill side effects.
Jack D. Pond wrote:
MW 1.15.1 (and before)
Does anyone know what causes this and how to remedy?
Wiki code only recognizes table commands ("{|", "|-", "|}") when they begin on a new line. Therefore if your template is using these commands, the first line of your template MUST be a newline - otherwise the wiki code is likely to be continued on the line in which it is referenced.
The bug 529 hack should make this unnecessary, if the template starts with {|. The bug report is a bit vague, but search Parser.php for "bug 529" to see what I mean.
What is the template invocation code?
-- Tim Starling
Using SMW for invocation. See full details at:
http://wiki.montcopa.org/TestWiki/index.php?title=JDPTestPage
-----Original Message----- From: mediawiki-l-bounces@lists.wikimedia.org [mailto:mediawiki-l-bounces@lists.wikimedia.org] On Behalf Of Tim Starling Sent: Thursday, January 21, 2010 10:11 PM To: mediawiki-l@lists.wikimedia.org Subject: Re: [Mediawiki-l] Maintaining newline as first line of a template
Jack D. Pond wrote:
MW 1.15.1 (and before)
Does anyone know what causes this and how to remedy?
Wiki code only recognizes table commands ("{|", "|-", "|}")
when they
begin on a new line. Therefore if your template is using these commands, the first line of your template MUST be a newline - otherwise the wiki code is likely to be continued on the
line in which it is referenced.
The bug 529 hack should make this unnecessary, if the template starts with {|. The bug report is a bit vague, but search Parser.php for "bug 529" to see what I mean.
What is the template invocation code?
-- Tim Starling
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org