diff options
author | Chris Morgan <me@chrismorgan.info> | 2015-05-22 11:01:34 +1000 |
---|---|---|
committer | Chris Morgan <me@chrismorgan.info> | 2015-05-22 11:01:34 +1000 |
commit | f8f9e8a74bce9174093129e91fe2c27389811d0a (patch) | |
tree | 6b686788c1b3abd0b7484d35fcada1d0696a59eb | |
parent | 21dd706774a3cfbe9514ef8ac57c6656b48b5c0e (diff) | |
download | pygments-f8f9e8a74bce9174093129e91fe2c27389811d0a.tar.gz |
Support shebangs in the Rust lexer.
I had forgotten about this obscure feature of Rust.
-rw-r--r-- | pygments/lexers/rust.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pygments/lexers/rust.py b/pygments/lexers/rust.py index df218e5d..2b6ff707 100644 --- a/pygments/lexers/rust.py +++ b/pygments/lexers/rust.py @@ -29,6 +29,12 @@ class RustLexer(RegexLexer): tokens = { 'root': [ + # rust allows a file to start with a shebang, but if the first line + # starts with #![ then it’s not a shebang but a crate attribute. + (r'#![^[\r\n].*$', Comment.Preproc), + default('base'), + ], + 'base': [ # Whitespace and Comments (r'\n', Whitespace), (r'\s+', Whitespace), |