Note: After the discussion in the comments, a separate post was spun off from this one, linked to below.
Note:
- This isn't a duplicate of earlier posts such as Enable a "lang-powershell" option for Prettify on Stack Overflow, because (a) they are obsolete due to referring to the previous highlighting library and (b) the problem persists.
Please fully support PowerShell syntax highlighting on all relevant SE sites:
- PowerShell, even though it is supported by highlight.js in principle, is not currently supported on SE sites (section "Language codes currently available on Stack Exchange").
Note:
I am aware that such a request is "extremely likely to be considered low-priority"; the backstory is in this answer.
Syntax highlighting: Use "lang-bash" (or similar) as default language for tags [powershell] and [powershell-core] until PowerShell is fully supported is a related request for an interim, stopgap solution in order to improve the current PowerShell highlighting experience, which can be implemented by simple moderator action.
Tip of the hat to Henry Ecker and Makyen.
lang-powershell
is not a workaround for the problem. "Just because you type something in and it looks like it's highlighted correctly does not mean the identifier actually exists in the system. Keep in mind that invalid identifiers trigger an automatic language detection.". For example, the code in this answer when annotated withlang-powershell
defaults and highlights usinglang-php
Screenshotlang-powershell
it falls back to "automatic language detection" meaning there is no guarantee what highlighting will be used. More examples from the same question: the code in this answer is highlighted withlang-less
, the code here is highlighted withlang-python
. The code here islang-bash
andlang-delphi
regardless of if the block is annotated withlang-powershell
.lang-powershell
and not annotating anything.lang-powershell
, which can be done NOW" is false. That can not be done at this time (note: changing the language listed for a tag is a request for moderator action, not SE). PowerShell is not a supported highlighting language. Even if it was, it would need to be added to the list of selectable languages on tag pages (which list is a subset of those supported and the values are verified in SE's backend, so we, moderators, can't just add them).lang-php
orlang-bash
strike me as the superior, passable alternatives.