Repository navigation
Get syntax highlighting working on GitHub #4341
Description
Activity
🤘
What needs to be done for this?
@steveklabnik Support needs to be added to linguist, and GitHub needs to update pygments to something newer than this commit.
I do not know the process for getting GitHub to do the pygments upgrade, but I imagine mentioning it prominently in the linguest pull request would be a start.
Are you interested in updating linguist?
I am interested but I've never done it before, so I can't guarantee that I'll be successful. Let me see what I can do.
So it looks like it's actually https://github.com/tmm1/pygments.rb that needs updated. Linguist already has Rust, though I guess the
lexerwould need to be changed.AFAIU
pygments.rbjust talks to Python via a pipe, getting list of lexers at the start, so there's nothing to update there.Changing
lexertorustshould be enough. Maybe it's a good idea to also throw in a few samples for bayesian classifier, although I doubt that.rsextension is used in any other language.So I'm not clear at all on what needs to be done now to make this happen. Does anybody? I think we probably need to do the following:
- Update pygments again - the last patch was done very long ago
- ?
- Ask GitHub to upgrade pygments
OK, after asking on IRC this is my understanding.
- The released version of pygments 1.6 contains a very old definition of Rust
- GitHub is using 1.5 currently. @uvtc emailed GitHub to ask about this and they say they will hopefully upgrade to 1.6 soon
- Patrick recently updated pygments, presumably will be in 1.7
- Linguist already supports rust
- pygments.rb doesn't need explicit support
I think there is nothing left to do but wait for GitHub to upgrade pygments (or bug them to do so). At that point GitHub will support an ancient version of Rust. Then we continue waiting for them to upgrade to the next release, at which point we'll be like a year out of date again. Not a great situation, but as Rust stabilizes, presumably GitHub and Rust will, over the course of years, converge on the correct grammar.
Awesome. :)
@strcat mentioned that this needs to be updated to use the rust lexer (not 'text only'): https://github.com/github/linguist/blob/master/lib/linguist/languages.yml#L1098. Presumably this needs to be done after they upgrade pygments to 1.6, and there is some evidence that they've already done this since gists do use syntax highlighting when told to use 'rust' explicitly.
I submitted a pull request to linquist to turn on the Rust lexer.
Coming soon!
I just pushed support for Rust on github.com (e.g. https://github.com/mozilla/rust/blob/master/src/libsyntax/attr.rs ). Enjoy!
return match we_have_rust { let yes = yep::word(1,2,3); data("R U S T"); }
@tnm Awesome! Thanks for deploying that so fast.
❤️ ❤️ 💚 💖
This is beautiful. ❤️
- added a commit that references this issue
on May 22, 2025


Pygments has a lexer now.
Related: #1198