Template talk:Code

Template-protected edit request on 4 March 2024
Update template to match [/index.php?title=&diff=prev&oldid=]. The specific change to line 1, and is as follows, compared to the current version of Template:Code (disregard the mangled noinclude in the left/old one, it's an issue with Template:TextDiff, new version is on the right anyway):

The change has been tested in Template:Code/testcases, and produces the expected output.

Purpose of change: makes this template use #tag:code instead of #tag:syntaxhighlight when lang/param 2 is either undefined or has been defined as 'text', but still uses #tag:syntaxhighlight in all other cases. #tag:syntaxhighlight is a WP:EXPENSIVE parser function, and current template behaviour always uses #tag:syntaxhighlight, even when unnecessary (as 'lang=text' has no syntax highlighting) - but, this change ensures that the non-expensive #tag:code will be used instead when syntax highlighting is not necessary. 🔥HOTm̵̟͆e̷̜̓s̵̼̊s̸̜̃🔥 (talk・edits) 20:01, 4 March 2024 (UTC)


 * It needs some additional work first. There are differences in markup behavior:
 * {| class="wikitable"

! ! plain ! ABC ! bold ! — !
 * plain
 * ABC
 * bold
 * &lt;syntaxhighlight inline&gt;
 * &lt;code&gt;&lt;nowiki&gt;
 * &lt;syntaxhighlight inline&gt;
 * &lt;code&gt;&lt;nowiki&gt;
 * &lt;syntaxhighlight inline&gt;
 * &lt;code&gt;&lt;nowiki&gt;
 * &lt;syntaxhighlight inline&gt;
 * &lt;code&gt;&lt;nowiki&gt;
 * &lt;syntaxhighlight inline&gt;
 * &lt;code&gt;&lt;nowiki&gt;
 * &lt;syntaxhighlight inline&gt;
 * &lt;code&gt;&lt;nowiki&gt;
 * &lt;syntaxhighlight inline&gt;
 * &lt;code&gt;&lt;nowiki&gt;
 * &lt;code&gt;&lt;nowiki&gt;
 * &lt;code&gt;&lt;nowiki&gt;
 * &lt;code&gt;&lt;nowiki&gt;
 * &lt;code&gt;&lt;nowiki&gt;
 * &lt;code&gt;&lt;nowiki&gt;
 * &lt;code&gt;&lt;nowiki&gt;


 * }
 * See this template's documentation about how syntaxhighlight works like code plus nowiki (except that with this template inner templates/magic words expand first). SilverLocust 💬 08:54, 5 March 2024 (UTC)
 * {| class="wikitable"|-


 * || plain || ABC || bold || — ||
 * }
 * I have made a new version in Template:Code/sandbox2 that may be correct — but it could use more checking. [ Edit: Now that my changes have been moved to /sandbox, I have put HotMess's original version in /sandbox2. ] SilverLocust 💬 10:16, 5 March 2024 (UTC)
 * @SilverLocust I've incorporated those changes into Template:Code/sandbox, and updated Template:Code/testcases with those additional checks (and a couple extra checks) - and it appears to be functioning correctly now. 🔥HOTm̵̟͆e̷̜̓s̵̼̊s̸̜̃🔥 (talk・edits) 13:13, 5 March 2024 (UTC)
 * I have made a new version in Template:Code/sandbox2 that may be correct — but it could use more checking. [ Edit: Now that my changes have been moved to /sandbox, I have put HotMess's original version in /sandbox2. ] SilverLocust 💬 10:16, 5 March 2024 (UTC)
 * @SilverLocust I've incorporated those changes into Template:Code/sandbox, and updated Template:Code/testcases with those additional checks (and a couple extra checks) - and it appears to be functioning correctly now. 🔥HOTm̵̟͆e̷̜̓s̵̼̊s̸̜̃🔥 (talk・edits) 13:13, 5 March 2024 (UTC)


 * There is also a difference for how they treat html codes.
 * {| class="wikitable"

! ! &amp;ndash; ! &amp;ndash; lang=something
 * (your original request)
 * &lt;syntaxhighlight inline&gt;
 * &lt;code&gt;&lt;nowiki&gt;
 * }
 * For context about the need for the change, is there a page/situation where you encountered an issue because of the current template? (It is, of course, possible to have an issue by just using the template 501 times, or on a page with 500 other expensive calls, but I want to know how much this has been an issue.) SilverLocust  💬 23:43, 5 March 2024 (UTC)
 * Well, the context behind this change was seeing Comparison of programming languages (basic instructions) in Category:Pages with too many expensive parser function calls (as this template is used 663 times within that page). I noticed that the current behaviour of this template upon reaching the WP:EXPENSIVE limit is to just present the code within regular <code ></code> blocks, so, y'know, figured that it would make sense to default to <code ></code> unless the expensive syntax-highlighting functionality is desired. Genuinely have no idea how to replicate the 'not needing to escape & within HTML character entities' functionality of SyntaxHighlight though. <b style="color:red;">🔥HOT<i style="color:orange;">m̵̟͆e̷̜̓s̵̼̊s̸̜̃</i>🔥</b> (talk・edits) 12:35, 6 March 2024 (UTC)
 * I have substituted most all of those with {{subst:codenowiki}}. That should keep that page under 500 hopefully forever. (I also then removed extra nowiki tags, though there may be some nowiki over- or under-inclusion errors left on the page that I haven't caught.) <small style="color:#667;background:#fff;border:2px solid;border-radius:.4em;padding:0 .3em">SilverLocust 💬 14:04, 6 March 2024 (UTC)
 * (your original request)
 * &lt;syntaxhighlight inline&gt;
 * &lt;code&gt;&lt;nowiki&gt;
 * }
 * For context about the need for the change, is there a page/situation where you encountered an issue because of the current template? (It is, of course, possible to have an issue by just using the template 501 times, or on a page with 500 other expensive calls, but I want to know how much this has been an issue.) <small style="color:#667;background:#fff;border:2px solid;border-radius:.4em;padding:0 .3em">SilverLocust  💬 23:43, 5 March 2024 (UTC)
 * Well, the context behind this change was seeing Comparison of programming languages (basic instructions) in Category:Pages with too many expensive parser function calls (as this template is used 663 times within that page). I noticed that the current behaviour of this template upon reaching the WP:EXPENSIVE limit is to just present the code within regular <code ></code> blocks, so, y'know, figured that it would make sense to default to <code ></code> unless the expensive syntax-highlighting functionality is desired. Genuinely have no idea how to replicate the 'not needing to escape & within HTML character entities' functionality of SyntaxHighlight though. <b style="color:red;">🔥HOT<i style="color:orange;">m̵̟͆e̷̜̓s̵̼̊s̸̜̃</i>🔥</b> (talk・edits) 12:35, 6 March 2024 (UTC)
 * I have substituted most all of those with {{subst:codenowiki}}. That should keep that page under 500 hopefully forever. (I also then removed extra nowiki tags, though there may be some nowiki over- or under-inclusion errors left on the page that I haven't caught.) <small style="color:#667;background:#fff;border:2px solid;border-radius:.4em;padding:0 .3em">SilverLocust 💬 14:04, 6 March 2024 (UTC)
 * &lt;code&gt;&lt;nowiki&gt;
 * }
 * For context about the need for the change, is there a page/situation where you encountered an issue because of the current template? (It is, of course, possible to have an issue by just using the template 501 times, or on a page with 500 other expensive calls, but I want to know how much this has been an issue.) <small style="color:#667;background:#fff;border:2px solid;border-radius:.4em;padding:0 .3em">SilverLocust  💬 23:43, 5 March 2024 (UTC)
 * Well, the context behind this change was seeing Comparison of programming languages (basic instructions) in Category:Pages with too many expensive parser function calls (as this template is used 663 times within that page). I noticed that the current behaviour of this template upon reaching the WP:EXPENSIVE limit is to just present the code within regular <code ></code> blocks, so, y'know, figured that it would make sense to default to <code ></code> unless the expensive syntax-highlighting functionality is desired. Genuinely have no idea how to replicate the 'not needing to escape & within HTML character entities' functionality of SyntaxHighlight though. <b style="color:red;">🔥HOT<i style="color:orange;">m̵̟͆e̷̜̓s̵̼̊s̸̜̃</i>🔥</b> (talk・edits) 12:35, 6 March 2024 (UTC)
 * I have substituted most all of those with {{subst:codenowiki}}. That should keep that page under 500 hopefully forever. (I also then removed extra nowiki tags, though there may be some nowiki over- or under-inclusion errors left on the page that I haven't caught.) <small style="color:#667;background:#fff;border:2px solid;border-radius:.4em;padding:0 .3em">SilverLocust 💬 14:04, 6 March 2024 (UTC)
 * }
 * For context about the need for the change, is there a page/situation where you encountered an issue because of the current template? (It is, of course, possible to have an issue by just using the template 501 times, or on a page with 500 other expensive calls, but I want to know how much this has been an issue.) <small style="color:#667;background:#fff;border:2px solid;border-radius:.4em;padding:0 .3em">SilverLocust  💬 23:43, 5 March 2024 (UTC)
 * Well, the context behind this change was seeing Comparison of programming languages (basic instructions) in Category:Pages with too many expensive parser function calls (as this template is used 663 times within that page). I noticed that the current behaviour of this template upon reaching the WP:EXPENSIVE limit is to just present the code within regular <code ></code> blocks, so, y'know, figured that it would make sense to default to <code ></code> unless the expensive syntax-highlighting functionality is desired. Genuinely have no idea how to replicate the 'not needing to escape & within HTML character entities' functionality of SyntaxHighlight though. <b style="color:red;">🔥HOT<i style="color:orange;">m̵̟͆e̷̜̓s̵̼̊s̸̜̃</i>🔥</b> (talk・edits) 12:35, 6 March 2024 (UTC)
 * I have substituted most all of those with {{subst:codenowiki}}. That should keep that page under 500 hopefully forever. (I also then removed extra nowiki tags, though there may be some nowiki over- or under-inclusion errors left on the page that I haven't caught.) <small style="color:#667;background:#fff;border:2px solid;border-radius:.4em;padding:0 .3em">SilverLocust 💬 14:04, 6 March 2024 (UTC)
 * }
 * For context about the need for the change, is there a page/situation where you encountered an issue because of the current template? (It is, of course, possible to have an issue by just using the template 501 times, or on a page with 500 other expensive calls, but I want to know how much this has been an issue.) <small style="color:#667;background:#fff;border:2px solid;border-radius:.4em;padding:0 .3em">SilverLocust  💬 23:43, 5 March 2024 (UTC)
 * Well, the context behind this change was seeing Comparison of programming languages (basic instructions) in Category:Pages with too many expensive parser function calls (as this template is used 663 times within that page). I noticed that the current behaviour of this template upon reaching the WP:EXPENSIVE limit is to just present the code within regular <code ></code> blocks, so, y'know, figured that it would make sense to default to <code ></code> unless the expensive syntax-highlighting functionality is desired. Genuinely have no idea how to replicate the 'not needing to escape & within HTML character entities' functionality of SyntaxHighlight though. <b style="color:red;">🔥HOT<i style="color:orange;">m̵̟͆e̷̜̓s̵̼̊s̸̜̃</i>🔥</b> (talk・edits) 12:35, 6 March 2024 (UTC)
 * I have substituted most all of those with {{subst:codenowiki}}. That should keep that page under 500 hopefully forever. (I also then removed extra nowiki tags, though there may be some nowiki over- or under-inclusion errors left on the page that I haven't caught.) <small style="color:#667;background:#fff;border:2px solid;border-radius:.4em;padding:0 .3em">SilverLocust 💬 14:04, 6 March 2024 (UTC)