-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(PowerShell) Specific elements not being identified for highlighting #3418
Comments
Powershell is not included in the default build - so highlighting is going to be entirely random (whatever is auto-detected). Please load the JS module for powershell first (see docs, readme) and if you still see issues this can be reopened. |
Thanks for pointing out, @joshgoebel. I loaded powershell.min.js. However, these tree issues are still there.
Updated code<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 src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/languages/powershell.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: https://codepen.io/ayanmullick/pen/YzrPobY Could this be reopened? |
|
Updated code<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.3.1/build/styles/default.min.css">
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.3.1/build/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/languages/powershell.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> |
Doubtful, we use our own grammar language (see the docs) to describe grammars, and we [often] aren't interested in contextual highlighting because it's [quite often] an impossible (or very hard) problem to solve without a full parser (which is not what our engine is designed to do). I've tried to encourage several people to work on a plugin that would allow us to piggy back/integrate Code Mirror 6 grammars - which are much, much more fully featured. But no one has taken me up on it yet, and it would probably involve writing a CodeMirror 6 Lezer grammar from scratch as well. I have little interest in the Code Mirror 5 stuff (which is where most of the supported languages still are).
And probably readability in general... :-)
For our Base16 themes, yes. But base16 doesn't believe in highlighting operators it seems - so that's an uphill battle.
...for 1st party themes (if you have a good eye) you could open a SMALL PR [initially], but I'm not going to allow "please add operators to this theme" style issues... I'd close them as dups of #2500. This lack of support affects many themes and is a known problem. Few grammars currently define Or we could debate whether these are operators at all... but I tend to go into such discussions based on semantics - not the desired highlighting result... so we choose what's best semantically - even if the highlighting is poor. Those who want the VERY best highlighting should use a custom theme for whichever languages they plan to highlight most since there is no much variation among languages. What does Microsoft themselves call |
Thanks for the detailed explanation, @joshgoebel .
|
Then I'd say |
Operator highlighting is working fine with the |
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.
#
sign is commented even if there no space after#
**Are you using
highlight
orhighlightAuto
?highlight
...
Sample Code to Reproduce
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
The text was updated successfully, but these errors were encountered: