This is the talk page for discussing improvements to the Code template. |
|
Archives: 1Auto-archiving period: 6 months |
Template:Code is permanently protected from editing because it is a heavily used or highly visible template. Substantial changes should be proposed here first. If the proposal is uncontroversial or has been discussed and is supported by consensus, editors may use ((edit template-protected)) to notify an administrator or template editor to make the requested edit. Usually, any contributor may edit the template's documentation to add usage notes or categories.
Any contributor may edit the template's sandbox. Functionality of the template can be checked using test cases. |
Text and/or other creative content from this version of Template:Code was copied or moved into incubator:Template:Wp/nod/code with this edit. The former page's history now serves to provide attribution for that content in the latter page, and it must not be deleted so long as the latter page exists. |
|
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Update template to match this edit I made to Template:Code/Sandbox. 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):
− | ((#tag: | + | ((#tag:((#ifeq:(({lang|(({2|text))))))|text|code|syntaxhighlight))|(({code|(({1))))))|lang=(({lang|(({2|text))))))|class=(({class|))}|id=(({id|))}|style=(({style|))}|inline=1))<noinclude> |
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)
plain | ''ABC'' | <b>bold</b> | ((mdash)) | ((PAGENAME)) | |
---|---|---|---|---|---|
((code)) | plain
|
''ABC''
|
<b>bold</b>
|
—
|
Code
|
((code/sandbox)) | plain
|
''ABC''
|
<b>bold</b>
|
—
|
Code
|
<syntaxhighlight inline> | plain
|
''ABC''
|
<b>bold</b>
|
((mdash))
|
((PAGENAME))
|
<code><nowiki> | plain
|
''ABC''
|
<b>bold</b>
|
((mdash))
|
((PAGENAME))
|
<code> | plain
|
ABC
|
bold
|
—
|
Code
|
((code)) | plain |
''ABC'' |
<b>bold</b> |
— |
Code
|
((code/sandbox2)) | plain |
ABC |
bold |
— |
Code
|
– | – lang=something | |
---|---|---|
((code)) | –
|
–
|
((code/sandbox)) | –
|
–
|
((code/sandbox2)) (your original request) |
–
|
–
|
<syntaxhighlight inline> | –
|
–
|
<code><nowiki> | –
|
–
|
<code> | –
|
–
|
<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 mw:SyntaxHighlight though. 🔥HOTm̵̟͆e̷̜̓s̵̼̊s̸̜̃🔥 (talk・edits) 12:35, 6 March 2024 (UTC)