16

Is it possible to escape and keep the nonstandard | character as is in an URL in a template Wiki Markup within a table?

{| class="wikitable"
|-
! Test in Table
|-
| [http://example.org/{var1}|{var2}|{var3} Example]
|}

Should render something like this in the table cell

[http://example.org/1|2|3 Example]

and link to

http://example.org/1|2|3

with the vertical bars as is and not encoded like this

http://example.org/1%7C2%7C3

The 3rd party website requires «|» in the URL, I would fix the URL handling on the server side but that is out of my hands for now. Any help on a workaround?

I tried these:

[http://example.org/1|2|3 Example] doesn't work within a table   
[http://example.org/{var1}|{var2}|{var3} Example] works in tables

but both create valid standard URLs where the vertical bar is properly URL encoded as %7C like above which I would like to prevent.

mxfh
  • 386
  • 1
  • 2
  • 11
  • 3
    Do you mean in the code of a template or in a template call? `|` works correctly for me in the code of a template and `%7C` works correctly for me in a template parameter. – svick May 11 '12 at 17:45
  • I use it in the code of template, in which case I guess it shouldn't even matter if its a template or not. The final outgoing URL hast to contain the plain | character thats all. Currently the | breaks the parsing of the link. – mxfh May 11 '12 at 19:04
  • missed that, your right this works outside a table yet still gives me the URLencoded strings – mxfh May 11 '12 at 19:34
  • 2
    Take a look at [this en-wiki template](https://en.wikipedia.org/wiki/Template:!). It's commonly used to put "|" character into tables. Your link will look like `[http://example.org/1{{!}}2{{!}}3 Example]` instead of `[http://example.org/1|2|3 Example]` and still work inside table. – skalee Dec 09 '12 at 19:05

2 Answers2

6

External links, without support from additional extensions, can only be produced by the [url description] syntax or a plain URL itself. Although as mentioned by skalee, you can use {{!}} or other methods to prevent the pipe symbol from being interpreted as part of the Wikitext syntax, the final link will always be encoded.

Without help from extensions, a quick solution would be JavaScript. (If it is on your own MediaWiki site, that would be very simple. MediaWiki:Common.js contains JavaScript that will be loaded for all users).

BenMQ
  • 866
  • 1
  • 10
  • 26
  • Thanks, apparently there is currently no way to do this on wikipedia. Anyway the issue has been resolved by switching to more common characters. – mxfh Dec 21 '12 at 03:28
1

In addition to the syntax {{!}} previously mentioned, it is also possible to escape the vertical bar / pipe using {{pipe}} or using <nowiki>text containing the character | (pipe)</nowiki>. Using the HTML entity &#124; also works.

Source:

https://en.wikipedia.org/wiki/Template:Cite_web#Title

https://en.wikipedia.org/wiki/Help:Table#Rendering_pipe_itself

baptx
  • 3,428
  • 6
  • 33
  • 42