Skip to content

Conversation

Cykyrios
Copy link

@Cykyrios Cykyrios commented May 14, 2025

I don't know if you're still accepting language PRs for v1, but I needed up-to-date GDSCript syntax highlighting, so I made the changes so it is compatible with Godot 4.x (this also removes some Godot 3.x-specific keywords).

Apart from the string and operators regex which I mostly reused as is, I overhauled the entire lexer taking inspiration from Godot's own pygments implementation for its official documentation. The following GDScript features are now available:

  • Builtin types, builtin objects (all 1003 of them at the time of writing), builtin functions.
  • Specific colors for control-flow keywords vs standard keywords, function definition vs function call, documentation vs standard comments.
  • Annotations (@export and the like).
  • NOTE, TODO, DANGER and other notes in comments and doc comments.
  • nodepaths, string names, placeholders in strings (Godot itself doesn't color them, this is a bonus feature).
  • $ and % shorthands for nodepaths are highlighted as variable tokens.
  • Binary and hexadecimal numbers are their own tokens, in case some themes want to color them differently.
  • INF, NAN, PI and TAU are builtin-number tokens aliased as keyword, null is included in builtin-pseudo along with true and false, which are aliased as boolean.
  • Signals are highlighted properly when declared.
  • Properties/class members are also highlighted.

From my testing, the only thing that does not highlight the way Godot does is class names, where Prism is not able to know they are classes, the rest should work fine.

For reference, here are comparison screenshots with the code in the example html file, in both Godot (using passivestar's theme with the CommitMonoNerd font (bold)) and an appropriately-themed Docusaurus page.

image
image

Edit: Closes #3752.

Copy link

netlify bot commented May 14, 2025

Deploy Preview for dev-prismjs-com ready!

Name Link
🔨 Latest commit ed76be5
🔍 Latest deploy log https://app.netlify.com/projects/dev-prismjs-com/deploys/68376de327fd6d0008e4b796
😎 Deploy Preview https://deploy-preview-3935--dev-prismjs-com.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

github-actions bot commented May 14, 2025

No JS Changes

Generated by 🚫 dangerJS against ed76be5

@Cykyrios
Copy link
Author

I updated with added string escapes and the corresponding tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant