Sublime Forum

Rust Syntax Highlighting?

#1

Hi there,

I’ve been looking at why the “Print to Html” package isn’t highlighting rust code and I think it is because of pygments being too old, and I gather sublime carries its own python install in that zip file.

First, why I think that is what is going on…

  • The console has this message from Print to Html… Guessed lexer from text analysis: <pygments.lexers.MasonLexer>
  • I added a print to PrintToHtml.py “except pygments.util.ClassNotFound as e: print(e)” to get it to tell me… no lexer for filename ‘main.rs’ found
  • The latest version of pygments does have a rust lexer, which is 2.1.3.
  • In the console, import pygments, print pygments.version tells me it’s 1.5.

So my questions are…

Can I update pygments in sublime’s python, and/or does it have to be updated in a release of Sublime? And if I can’t update it, is it likely that a jump from 1.5 to 2.1.3 wouldn’t be likely to happen soon? If so is there any workaround I can use?

Thank you,

Nev

0 Likes

#2

I think you will find that the pygments module is included with the package (Print to HTML) and not with ST. So you should be able to update it yourself, either by overriding the package or by making a pull request to the package (https://github.com/grubernaut/sublimetext-print-to-html).

0 Likes

#3

Fantastic. Thank you so much. Took about 30 seconds, and now all working. :grin:

0 Likes

#4

Pull request for “Print to HTML”, includes how I did it in case anyone wants to do it while waiting for it to be accepted.

(I took the https:// off the url because it says new users can’t post links.)

0 Likes