Skip to content
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

Improve the Rust lexer #2631

Merged
merged 5 commits into from Jan 28, 2024
Merged

Improve the Rust lexer #2631

merged 5 commits into from Jan 28, 2024

Conversation

alanhdu
Copy link
Contributor

@alanhdu alanhdu commented Jan 27, 2024

This changes the Rust lexer to handle ::, :, and -> better. Previously, all of these tokens would labeled as text, which leads to poor rendering on certain styles. For instance, using a monokai HTML style w/ inline CSS, I get

image

where the tokens are rendered using the default (black) text which is not really visible against the background.

This changes the lexer so that:

  • : and -> are considered punctuation
  • :: is considered an operator -- I am not entirely sure that's the correct thing to do, but it seems like a resaonable choice
  • I went through and used Text.Whitespace instead of plain Text a little more thoroughly.

pygments/lexers/rust.py Outdated Show resolved Hide resolved
@jeanas jeanas merged commit cf57066 into pygments:master Jan 28, 2024
13 checks passed
@jeanas
Copy link
Contributor

jeanas commented Jan 28, 2024

Thanks!

@alanhdu alanhdu deleted the alan/rust branch January 29, 2024 20:01
@Anteru Anteru added the A-lexing area: changes to individual lexers label Feb 17, 2024
@Anteru Anteru added this to the 2.18.0 milestone Feb 17, 2024
@Anteru Anteru added the changelog-update Items which need to get mentioned in the changelog label Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lexing area: changes to individual lexers changelog-update Items which need to get mentioned in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants