Improve the Rust lexer by alanhdu · Pull Request #2631 · pygments/pygments

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.