29

The main "What is Syntax Highlighting and how does it work?" Meta question instructs us 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. PowerShell is such a language, so here's a question for it.

At a glance, this question looks a duplicate of:

But Stack Exchange has moved away from Prettify, which didn't support PowerShell, but highlight.js does, so it now comes down to:

  1. Check that the language is supported by highlight.js

If a language is already on the list but not used on Stack Exchange, please raise a feature request here on Meta to have it deployed on the network.

4
  • @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. 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. 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". Oct 29, 2020 at 12:18
  • 2022 feature request: meta.stackoverflow.com/questions/421016/…
    – cachius
    Oct 20 at 7:51

1 Answer 1

1

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
  • 3
    This isn't really an answer, just a corollary.
    – tripleee
    Oct 11 at 11:43
  • 5
  • 3
    @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
    Oct 12 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
    Oct 12 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 Oct 13 at 23:31
  • @This_is_NOT_a_forum corrected Oct 20 at 13:35

You must log in to answer this question.

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