Skip to content

Commit

Permalink
Add Starlark support to Python lexer (#1369)
Browse files Browse the repository at this point in the history
Starlark is a dialect of Python that is used to configure the Bazel
build system. This adds file extensions to the Python lexer that are
used for files written in Starlark.
  • Loading branch information
zoidyzoidzoid authored and pyrmont committed Jan 12, 2020
1 parent 39ec4a4 commit 108737b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rouge/lexers/python.rb
Expand Up @@ -8,7 +8,8 @@ class Python < RegexLexer
desc "The Python programming language (python.org)"
tag 'python'
aliases 'py'
filenames '*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac'
filenames '*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac',
'*.bzl', 'BUCK', 'BUILD', 'BUILD.bazel', 'WORKSPACE'
mimetypes 'text/x-python', 'application/x-python'

def self.detect?(text)
Expand Down
5 changes: 5 additions & 0 deletions spec/lexers/python_spec.rb
Expand Up @@ -14,6 +14,11 @@
assert_guess :filename => 'SConstruct'
assert_guess :filename => 'SConscript'
assert_guess :filename => 'foo.tac'
assert_guess :filename => 'foo.bzl'
assert_guess :filename => 'BUCK'
assert_guess :filename => 'BUILD'
assert_guess :filename => 'BUILD.bazel'
assert_guess :filename => 'WORKSPACE'
end

it 'guesses by mimetype' do
Expand Down

0 comments on commit 108737b

Please sign in to comment.