jgm / skylighting

A Haskell syntax highlighting library with tokenizers derived from KDE syntax highlighting descriptions
195 stars 63 forks source link

Python highlighting missing modules, methods, arguments, and variables. #195

Open nickvigilante opened 3 months ago

nickvigilante commented 3 months ago

Related to https://github.com/jgm/skylighting/issues/147

Originally logged to Quarto as https://github.com/quarto-dev/quarto-cli/issues/10488

One of our users reported they were seeing some not very colorful examples of Python code, and I didn't think much of it until this moment. I tried creating a custom theme with a bunch of jarring colors, and I observed that a similar script in R is able to highlight much more than what Python is able to highlight, including the function names and parameters.

Steps to reproduce

  1. Clone nickvigilante/code-highlighting-issue
  2. quarto preview

Expected behavior

All code elements, including import tokens, variables, modules, methods, and arguments, should be highlighted.

Actual behavior

Some elements are missing highlighting.

jgm commented 3 months ago

Please give instructions for reproducing the issue without quarto. Perhaps a screen shot of what you're seeing, with an explanation of what you find wrong, would be helpful.

Pandoc uses highlighters built from KDE's highlighting definitions. If you try opening the file in the Kate editor, how does it look?

jgm commented 3 months ago

This is what the first sample in your index file looks like when rendered with pandoc using default highlighting style:

image

And with your ugly.theme:

image

Are there problems with this? If this is not what you're seeing in Quarto, the problem may be on the Quarto side, as pandoc with skylighting gives these results.

jgm commented 3 months ago

Function names and parameters aren't highlighted, but I don't think they ever were. Here's what it looks like in the Kate editor:

image
nickvigilante commented 3 months ago

Thanks for that. I'm gonna try to get Kate/Skylighting working on my Mac momentarily.

What seems odd (from viewing Quarto) is it appears as though R function names and parameters are identified and colored as such, but they aren't in Python. I'll try to come up with a more complete reproduction scenario for you not involving Quarto. Stay tuned.

jgm commented 3 months ago

it appears as though R function names and parameters are identified and colored as such, but they aren't in Python

That's entirely possible; it depends on how the syntax definitions for these languages were written. You can examine them in the subdirectory skylighting-core/xml.