Template talk:Code
<templatestyles src="Module:Message box/tmbox.css"/><templatestyles src="Talk header/styles.css" />
| This is the talk page for discussing improvements to the Code Template:Pagetype. |
|
| Archives: Template:Comma separated entries<templatestyles src="Template:Tooltip/styles.css" />Auto-archiving periodScript error: No such module "Check for unknown parameters".: Template:Human readable duration File:Information icon4.svg |
Script error: No such module "Check for unknown parameters".Script error: No such module "Check for deprecated parameters".
User:MiszaBot/config Template:Permprot Template:Copied
- REDIRECT Template:Archives
RFC Syntaxhighlighting one word code
User:ClueBot III/DoNotArchiveUntil There is no point in syntaxhighlighting a word code. Template:Qf The meaning of 'distinct' is "different from one another." -- Cedar101 (talk) 01:40, 22 January 2025 (UTC)
- Semantic markup. Also, not all users are sighted. No bots are. Not yet.
- And if that doesn't convince you, that's fine, too. I don't think there is anyone for whom Wikipedia is Template:Em like they think it should be. Paradoctor (talk) 02:05, 22 January 2025 (UTC)
- Template:Tl only means that the text is code, and provides little semantics for the language. Template:Tl, Template:Tl and other templates in Category:Programming typing-aid templates provide some more semantics. There should be some general consensus on whether to apply the template that provides semantics for the language. -- Cedar101 (talk) 05:17, 22 January 2025 (UTC)
Template:Moved discussion from Cedar101 (talk) 06:57, 23 January 2025 (UTC)
- I'm sorry, I don't understand what this RfC is about. The statement, as copied to WP:RFC/POLICY, consists of a broken Template:Tlx tag. It's broken because the closing double braces are after the timestamp, in violation of WP:RFC#Formatting example. --Redrose64 🌹 (talk) 23:17, 23 January 2025 (UTC)
- Okay, I moved and fixed Template:Tlx tag. -- Cedar101 (talk) 23:42, 23 January 2025 (UTC)
- Does this RFC mean something like this?
- "I don't want people to use this template if there is only one word inside the template. If you want to write 'The pun about sharing the pea soup relies on being familiar with the verb convention in Lisp, which treats
split-pas an action", then you should not use this template, because that's only one word." - Or does it mean something else? WhatamIdoing (talk) 08:11, 4 February 2025 (UTC)
- Oppose - Non-English words are italicized. Analogously, it is natural that programming keywords should be monospaced. This is a convention in programming: See how even single-word commands are monospaced in chapter 2 of
texdoc texbytopic. Also see the monospacing at malloc. However, theoretical computer science concepts are not monospaced: "ordered", "linear", "affine", and "relevant" in Substructural type system are not monospaced, but pseudocode is monospaced. - The goal of "distinct" here is not only Template:Tq, but also "different from the surrounding prose". The implied meaning also changes based on font:
- int - to intentionally lose a game
int- a 32-bit primitive data type in many programming languagesINT/INTEGER- a 32-bit SQL data type- Integer - any numeric data type, theoretically of any precision
Integer- a non-primitive 32-bit data type in Java
- 173.206.40.108 (talk) 17:37, 16 February 2025 (UTC)
Edit request 6 April 2025 - Performance improvement
Template:Edit template-protected
Hello, you may be interested by the code used by this template on frwiki: [1].
When the template is used without "lang" parameter, I figured out a way to use "code + nowiki" instead of "syntaxhighlight". The result is visually identical, but we avoid the expensive syntaxhighlight call.
(Refs a previous, failed attempt: Template talk:Code/Archive 1#Template-protected edit request on 4 March 2024.)
Od1n (talk) 18:03, 6 April 2025 (UTC)
- I have pushed (pushed back, actually) the suggested change to the sandbox. Note that, as it happens, there is a difference in behavior with HTML entities. See third table in the previous discussion. Od1n (talk) 01:19, 7 April 2025 (UTC)
- I note that Template:Diff removes the Template:Para parameter on the grounds that it's unused. That may be the case; but it was Template:Diff on the grounds of harmonisation. I think that it should not be removed. --Redrose64 🌹 (talk) 16:56, 7 April 2025 (UTC)
- Some relevant examples from the previous discussion have been copied to the testcases page. I see differences in rendering between the live template and the sandbox in the second "Markup behaviour" table. Are those differences intended? – Jonesey95 (talk) 18:37, 8 April 2025 (UTC)
- No opinion regarding the removal of the Template:Para parameter. I just synchronized with the production template, where it has been removed. I lean toward keeping it removed, but that’s a secondary consideration.
- I noticed the discrepancy with HTML entities only after posting the suggested change. On one hand, the change would make the template significantly faster (eliminating the expensive
<syntaxhighlight>call on all simple uses), but on the other hand, it introduces that discrepancy with HTML entities. Thoughts?
- Od1n (talk) 20:58, 10 April 2025 (UTC)
- Some relevant examples from the previous discussion have been copied to the testcases page. I see differences in rendering between the live template and the sandbox in the second "Markup behaviour" table. Are those differences intended? – Jonesey95 (talk) 18:37, 8 April 2025 (UTC)
- I note that Template:Diff removes the Template:Para parameter on the grounds that it's unused. That may be the case; but it was Template:Diff on the grounds of harmonisation. I think that it should not be removed. --Redrose64 🌹 (talk) 16:56, 7 April 2025 (UTC)
- What's the use case for this? Are there actually a significant number of pages running into the expensive parser function limit because of calls to this template with lang=text? Otherwise WP:PERF applies and it's not worth the extra complexity. * Pppery * it has begun... 20:17, 22 April 2025 (UTC)
- Are there any pages that have
lang=text? I for one have never seen any in the wild. 𝕁𝕄𝔽 (talk) 20:40, 22 April 2025 (UTC)- "Text" is the default, so any pages that don't specify a language would trigger this, which is probably fairly common. But even given that there are only 6 pages using this template with too many expensive parser function calls so I still don't think it's worth it. * Pppery * it has begun... 23:26, 24 April 2025 (UTC)
- Are there any pages that have
- File:X mark.svg Not done for now: please establish a consensus for this alteration before using the Template:Tlx template. jlwoodwa (talk) 01:35, 27 April 2025 (UTC)
- A great solution for this issue would be upstream, in the extension code: when no syntax highlighting is applied, there is no reason for the tag to be expensive.
- When using
lang="text", we should ensure that the tag execution is fast, and does not increment the expensive function count. For instance, I thought of an early return in SyntaxHighlight.php://if ( $lexer === null ) { if ( $lexer === null || $lexer === 'text' ) { // When syntax highlighting is disabled.. $status->value = self::plainCodeWrap( $code, $isInline ); return $status; }
- Od1n (talk) 20:36, 19 May 2025 (UTC)
- One caveat with the above change: it would break the "line numbers" feature on plain text, i.e.
<syntaxhighlight lang="text" line>. So my proposed change requires further refinement. - By the way, I noticed a related bug that would impact this change too: when using
<syntaxhighlight line>(erroneously omitting thelangattribute), the lines placeholder appears but does not contain line numbers. - Od1n (talk) 20:52, 19 May 2025 (UTC)
- One caveat with the above change: it would break the "line numbers" feature on plain text, i.e.