Last modified: 2007-08-02 21:17:23 UTC
There is a Problem with wikilinks in template parameters. I wanted to use the template http://de.wikipedia.org/wiki/Vorlage:Infobox_Bahnhof Some of the parameters add [[ and ]] to the parameter text in order to automatically generate wikilinks. I want to use the parameter Art, to display two links. Therefore I tried the parameter text" Link1]] , [[Link2". the brakets in the beginning and the end should be inserted automatically, as you can see in the source code: {{#if: {{{Art|}}} | ! [[Bahnhof#Bahnhofsarten|Art]] {{!}} [[{{{Art|}}}]] }} However, the result is not as supposed. Instead, the layout gets totally messed up, as you can see here: http://de.wikipedia.org/wiki/Benutzer:Blauerflummi/Testseite_Infobox_Bahnhof_2 (Use the version history, to see, what it should look like. What is the reason for this problem, and how can It be solved?
I think the parser is getting confused when it sees the end of a wikilink without being able to find the start of it, and it never realises that it is in a template parameter, so ends up not parsing anything at all and just outputs the wikitext. It's possible the parser could be altered to work better in this situation, but I doubt it would be easy. I think your best bet is to alter the template (perhaps add an alternative parameter which doesn't have [[ and ]] added to it).
The problem is that once the parser starts parsing the [[, then the | is used for that. The solution is to delay parsing the link until after the template is parsed. I've already fixed the example page listed; this behavior is inherent in the syntax, so changing the parser wouldn't help.
This is not a parser bug. Simple change the template: {{#ifexist: {{{Art}}} | [[{{{Art}}}]] | {{{Art}}} }} Then almost all kinds of parameter text can be used: Art = Link1 Art = [[Link1]] Art = [[Link1]], [[Link2]]
That's not perfect - really you want an #isAValidPageName rather than #ifexist, otherwise you won't get redlinks for pages that could exist but don't.