(PowerShell) Specific elements not being identified for highlighting
See original GitHub issueDescribe the issue
Syntax highlighting isn’t working for some elements of PowerShell. I think the PowerShell language grammar to identify certain elements needs to be updated.
- The entire line after a
#
sign is commented even if there no space after#
- The Noun part of the cmdlet isn’t highlighted
- The parameter name isn’t highlighted
- PowerShell parameter arguments don’t need to be in quotes unless there is a space in between
**Are you using highlight
or highlightAuto
? highlight
…
Sample Code to Reproduce
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.3.1/build/styles/atom-one-dark.min.css">
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.3.1/build/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
<pre><code class="pwsh">
#Locate SQL image
Get-AzVMImagePublisher -Location 'southcentralus'|? PublisherName -Like *sql*
Get-AzVMImageOffer -Location southcentralus -PublisherName MicrosoftSQLServer
</code></pre>
CodePen link to reproduce issue: https://codepen.io/ayanmullick/pen/YzrPobY
Expected behavior
Screenshot:
Library: This screenshot is from PowerShell ISE. One could export the theme XML from Tools
-Options
-Manage themes
-Export
One gets similar highlighting experience on Discord too.
Additional context : NA
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Selenium webdriver & powershell to highlight text from one ...
Save this question. Show activity on this post. So I need to highlight text from an element (textarea), copy that highlighted and then...
Read more >Select-String - PowerShell - Microsoft Learn
Select-String can be used to display all text that doesn't match the specified pattern. You can also specify that Select-String should expect a...
Read more >How can I get notepad++ highlighting working for powershell ...
I'm brand new to powershell anyways, not going to be doing any heavy lifting. I believe I found the answer im looking for...
Read more >A proper PowerShell syntax highlighter - mythofechelon
These reports contain some code which naturally need to be read differently (or not at all, depending on the audience) so, to make...
Read more >Use VSCode Syntax Highlighting for better PowerShell
VSCode text editor with some PowerShell variables and almost no syntax highlighting. Material Theme's Darker High Contrast theme.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Then I’d say
operator
is correct and we just need to wait for themes to catch up - and those who truly care right now need to tweak their own CSS to better support operators. I’d also say base16 themes may not be best-suited to grammars that use “keyword like” operators, like Powershell.Operator highlighting is working fine with the
atom-one-dark-reasonable
theme. 😄