52

I wrote an answer on Stack Overflow with some PowerShell code examples, but there's no syntax highlighting. There are currently 29,611 (as of 2015-12-08) questions tagged on Stack Overflow. Please add prettified syntax highlighting to PowerShell questions.

These are the one's I experimented with in my original testing.

<!-- language: lang-ps-->
<!-- language: lang-ps1-->
<!-- language: lang-powershell-->
<!-- language: lang-posh-->

Side note: there are only 5,591 (as of 2015-12-08) questions tagged on Stack Overflow, and it is already supported


Close voters, please read my comment below before casting your vote. I believe Stack Overflow is maintaining their own version now, so forking the original and adding posh support would NOT solve this feature request.

19
  • 1
    Last updated Aug 25 '11: list of supported languages.
    – Arjan
    Commented Feb 14, 2013 at 19:51
  • 1
    Doesn't seem that there is support for powershell.
    – nhahtdh
    Commented Feb 14, 2013 at 20:59
  • You can try putting it through another syntax highlighter like Pygments and copying the HTML. I make no guarantee that the sanitizer will like the HTML that comes out though.
    – Linuxios
    Commented Feb 14, 2013 at 22:49
  • 1
    hmmm, @Linuxios, I'm not sure that will accomplish what I'm asking. This needs to be implemented on SO... Commented Feb 14, 2013 at 23:33
  • @nhahtdh, you appear to be right. I wonder how hard the additional implementation would be. Commented Feb 14, 2013 at 23:34
  • 3
    This should really be a feature request, it would dramatically improve readability on powershell questions
    – Mgetz
    Commented Jul 10, 2013 at 15:51
  • 5
    Not sure I like the cute shorthand like ps by itself - people may think it is PostScript, or PL/SQL, or PostgreSQL, who knows. posh would probably be less ambiguous and not really all that much more painful to write (especially since all the powershell-related tags should trigger that as the default formatting once it is implemented).
    – Aaron Bertrand Staff
    Commented Jul 10, 2013 at 19:15
  • never thought of posh, but you're probably right. Commented Jul 10, 2013 at 19:16
  • trying to write this myself as per my question... lack of documentation on prettify itself is becoming a problem
    – Mgetz
    Commented Jul 10, 2013 at 19:31
  • I've done some format testing in the sandbox it would be plausible to use the csh highlighting until such a plugin was developed
    – Mgetz
    Commented Jul 10, 2013 at 20:25
  • 8
    There is an open issue for Prettify that includes a language file for PowerShell. It’s incomplete but definitely better than no syntax highlighting at all (current situation). Can we reopen the question and get that language file added to the highlighter?
    – poke
    Commented Dec 21, 2013 at 1:45
  • 1
    @poke I've voted to re-open - the issue tracker says "the only thing I know it has trouble with is delimited comments, which follow the pattern <# comment #>" which sounds a lot better than nothing.
    – user6854914
    Commented Dec 21, 2014 at 21:20
  • 1
    How is this not implemented yet in 2018? PS has been around for almost 12 YEARS! It's pre-posh-terous (lol) that this hasn't been prettified yet! >.< ... and while posh is a fine shorthand, I think psh is in better keeping with existing shorthands like csh and bsh. PLEASE IMPLEMENT THIS!!! ;)
    – Chiramisu
    Commented Jan 18, 2018 at 23:04
  • 1
    See the duplicate, specifically the How do I report a bug or request a new language? section.
    – Martijn Pieters Mod
    Commented Jan 19, 2018 at 19:56
  • 1
    For an updated feature request that accounts for the change from prettify.js to highlight.js, please see meta.stackoverflow.com/q/421016/45375
    – mklement0
    Commented Oct 23, 2022 at 12:52

1 Answer 1

3

Currently the best option I have found for PowerShell is CoffeeScript:

<!-- language: lang-coffee -->

However, this is not perfect as it missed some elements such as escaping strings, etc.

That said, you make some very excellent points @ChaseFlorell and I find it hard to believe that this still has not been implemented after 12 years of PowerShell. I guess for the time being we're stuck with Coffee... speaking of which... it's about that time. ;)

6
  • 2
    The order of things to happen is still that Prettify needs to support it first and based on this open issue it looks like that is still in the works. You could help there to make a proper pull-request, adding docs and tests for that file in the attachtment. Once it is merged and part of an stable release of Prettify, SE can make a move to pull a newer release.
    – rene
    Commented Jan 19, 2018 at 7:57
  • Excellent suggestion @rene. I shall look into that. ;)
    – Chiramisu
    Commented Jan 19, 2018 at 8:08
  • 2
    ```shell also works okay, but I use ```powershell so it works correctly when they support it.
    – orad
    Commented Mar 8, 2019 at 6:52
  • @rene, that GitHub repo has been archived by Google. Where's the current source of this js? Commented May 10, 2022 at 4:20
  • @JakeEdwards it is now HighlightJS, found here and here is the MSE canonical
    – rene
    Commented May 10, 2022 at 16:06
  • 2
    @Chiramisu, for an updated feature request that accounts for the change from prettify.js to highlight.js, please see meta.stackoverflow.com/q/421016/45375
    – mklement0
    Commented Oct 23, 2022 at 12:53

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