question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(PowerShell) Specific elements not being identified for highlighting

See original GitHub issue

Describe 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.

image

  1. The entire line after a # sign is commented even if there no space after #
  2. The Noun part of the cmdlet isn’t highlighted
  3. The parameter name isn’t highlighted
  4. 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: image

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:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
joshgoebelcommented, Dec 3, 2021

-Like is a comparison operator

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.

1reaction
Ayanmullickcommented, Dec 4, 2021

Operator highlighting is working fine with the atom-one-dark-reasonable theme. 😄

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found