Jump to content

Wikipedia talk:Advanced template coding

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

What's the solution for wiki formatting with #if ?

[edit]

You describe the issue where MediaWiki wiki-formats the clauses inside #if, but you don't say how to solve it! I've got an #if template that needs to generate http links containing semicolons (mw:Template:git file), and it messes up, badly and almost randomly. Is there a solution? -- Skierpage (talk) 20:54, 21 September 2012 (UTC)[reply]

If it is just an address, using &#59; instead of ; will work. Or, if the link always contains git before the semicolon, try adding git inside of #if. — TAKASUGI Shinji (talk) 02:25, 25 January 2013 (UTC)[reply]
This issue came up today here. I found that using %3A URL encoding for the initial colon resolved the problem where using html encoding : produced inconsistent results apparently depending on context. I updated the doc for {{sortname}} to suggest this. Maybe it should be mentioned here, too? — jmcgnh(talk) (contribs) 05:13, 30 September 2022 (UTC)[reply]

...which is a soft redirect to the page of the same title on Meta. Should it be mentioned in the "See also" section? --SoledadKabocha (talk) 18:45, 10 November 2012 (UTC)[reply]

[edit]

I've been trying to add a hyperlink to an entry within a table on the following page (look for the "The 5th Dimension / Live!!" entry): The_5th_Dimension_discography

The closest I've been able to get is with this code:

|- ! scope="row" | The 5th Dimension / Live!! |

But that just gets me a link with reverse slashes in the URL. The double exclamation marks are a problem, but that was the original album title.

The page I would be linking to is here: The_5th_Dimension_/_Live!!

Pherank (talk) 08:02, 25 February 2025 (UTC)[reply]

@Pherank: I don't understand why you would want to use a backslash at all. Why would this not be suitable?
|-
! scope="row" |''[[The 5th Dimension / Live!!]]''
|
Or is there something else that you've not told us? --Redrose64 🌹 (talk) 09:31, 25 February 2025 (UTC)[reply]
I've tried what you've suggested above with both pairs of single quotes around the brackets, and just double quotes around the brackets, but it never parses correctly. So I'm just left confused. Here's a screenshot of code and results: [1]https://www.dropbox.com/scl/fi/7euu44hupucoxjjeuq3qy/code_result.png?rlkey=r5gbmkko95n2jap547v15dn1k&st=pjzyehek&dl=0 Pherank (talk) 09:42, 25 February 2025 (UTC)[reply]
Where are you doing this? I don't see anything in your recent edits which exhibits such problems. Also, please don't use dropbox. We have two recognised means of providing screenshots, one is WP:WPSHOT and the other is through phab:. --Redrose64 🌹 (talk) 09:51, 25 February 2025 (UTC)[reply]
Here's a link to the screenshot at WikiMedia Commons: https://commons.wikimedia.org/wiki/File:Code_result.png
All of my testing is within the Wikipedia page editor (Firefox 135.0.1 browser). But there is no reason for me to publish my changes with bad code - I'm just running the preview mode for now. Pherank (talk) 15:52, 25 February 2025 (UTC)[reply]
OK, well my investigations have so far revealed that the double exclamation marks are a problem inside a table because table headers begin with an exclamation mark. If my page link only required a single exclamation mark, there wouldn't be a problem parsing the page name/link. But the name has two exclamation marks and so it will only work in normal text situations. There doesn't look to be a way around this situation. Pherank (talk) 21:24, 25 February 2025 (UTC)[reply]
(edit conflict) @Pherank: We do have the WP:SANDBOX where you can save any number of bad test edits and nobody will complain, at all. As such, I've made this demo. From that I can see that it's a bug in the MediaWiki parser, which is taking the pair of exclamation marks as the beginning of a new cell. If you either (a) change the exclamation mark at the beginning of the line to a pipe character |; or (b) change either of the paired exclamation marks to its percent-encoded form (%21), like this, it works as expected.
BTW please note that your problem is out of scope for this page, which is about discussing improvements to the page Wikipedia:Advanced template coding. Moreover, your problem does not involve templates at all. A much better venue would have been WP:VPT, which not only specialises in this sort of thing, it has more than a hundred times as many watchers (3,688 as opposed to 31). --Redrose64 🌹 (talk) 21:45, 25 February 2025 (UTC)[reply]
Fantastic - a solution! (Or more appropriately: !!) Thanks very much, and thank you for pointing out a more appropriate place to ask about these parsing issues. Sorry to invade your space, but I'm obviously a relative newbie to the Wikipedia coding world. Cheers. Pherank (talk) 22:04, 25 February 2025 (UTC)[reply]