34

This question is not a duplicate of:

They are from a time when Stack Exchange (SE) used Prettify for highlighting which didn't support PowerShell. SE now uses highlight.js which does. It now comes down to:

open a question tagged [feature-request] to add syntax highlighting for a language which is supported by the highlight.js project, but it is not supported by the version of highlight.js used on Stack Exchange.

Can Stack please use a version of highlight.js that supports PowerShell?

5
  • @TessellatingHeckler Did you see the TamperMonkey script that can load new languages on demand from the Highlight.js CDN? meta.stackexchange.com/a/354427/853855 Might be helpful for languages SO truly decides they are not going to add to improve the experience of individuals. I'm sure it could easily be turned into a Chrome Extension or something also if anyone was interested. Commented Oct 18, 2020 at 2:57
  • you can raise a feature request on Meta to request that a new version of highlight.js be deployed @KonradRudolph That's definitely my plain understanding at a plain reading of the post. Commented Oct 19, 2020 at 21:57
  • 1
    I've bundled this support into a Chrome extension if that would be helpful to you: github.com/joshgoebel/se_highlightjs It pretty much adds all our missing languages to SE (when they are manually hinted). Also on the list is adding auto-hinting support - so any post tagged "powershell" would "just work". Commented Oct 29, 2020 at 12:18
  • 2022 feature request: meta.stackoverflow.com/questions/421016/…
    – cachius
    Commented Oct 20, 2023 at 7:51
  • Which links to: meta.stackexchange.com/a/368443 - basically no plans to do it. Commented May 30 at 12:56

1 Answer 1

2

For what it’s worth, Stack Overflow still does not provide a good option for PowerShell at all right now.

To show this, let's look at one of the most-basic items in PowerShell: the Get-Date cmdlet.

Starting with <!-- language: lang-powershell -->

Get-Date

Or ```sh

Get-Date

Both cases see the - as a subtraction operator and then show the words "Get" and "date" in different colors. Yet clearly this is one call to the Get-date cmdlet.

There's also ```powershell

Get-Date

which does nothing at all, and ```lang-default

Get-Date

which at least allows some kind of detection to work, but it still gets it wrong.

6
  • 4
    This isn't really an answer, just a corollary.
    – tripleee
    Commented Oct 11, 2023 at 11:43
  • 5
    Also, please don't post the same content to multiple questions.
    – tripleee
    Commented Oct 11, 2023 at 11:46
  • 4
    @zcoop98 Your addition here is based on an inaccurate assumption that it's a bug and introduces a red herring into the discussion. The version of highlight.js doesn't matter for this. The issue is that Stack Exchange doesn't include PowerShell syntax in the languages available in the page. Thus, all attempts to try to use PowerShell syntax highlighting on Stack Exchange won't pull in an actual highlighting definition. So, specifying powershell syntax highlighting does nothing (it might be useful, eventually, when at some point in the future SE includes the PowerShell syntax definition).
    – Makyen
    Commented Oct 12, 2023 at 15:05
  • Apologies @Makyen , you're totally right. I thought that PS highlighting was included; I see now that it's not in the list.
    – zcoop98
    Commented Oct 12, 2023 at 16:20
  • It may not make a difference for the syntax highlighting in this case, but Get-date is not the official spelling of the cmdlet (though it is case insensitive). For instance, for Java, it makes a difference: If the normal Java conventions are not followed (e.g., for variable names), the syntax highlighting will not be correct. Or in other words, the current syntax highlighter in some cases (or all cases?) expects the platform conventions to be followed Commented Oct 13, 2023 at 23:31
  • @This_is_NOT_a_forum corrected Commented Oct 20, 2023 at 13:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .