From b52c4e043fb5918a6b5c040c33d7fdae06a1fce6 Mon Sep 17 00:00:00 2001 From: zoidbergwill Date: Tue, 26 Nov 2019 19:12:30 +0100 Subject: [PATCH 1/2] WIP Starlark support Inspired by https://github.com/pygments/pygments/pull/1259/files --- lib/rouge/lexers/python.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rouge/lexers/python.rb b/lib/rouge/lexers/python.rb index 584f1c5e6d..8ad81e6d46 100644 --- a/lib/rouge/lexers/python.rb +++ b/lib/rouge/lexers/python.rb @@ -8,7 +8,7 @@ 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) From 7f79509bd52e61b958e15bb252597bea7e5ded3b Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Thu, 9 Jan 2020 04:44:56 +0900 Subject: [PATCH 2/2] Add assertions for new file globs --- lib/rouge/lexers/python.rb | 3 ++- spec/lexers/python_spec.rb | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rouge/lexers/python.rb b/lib/rouge/lexers/python.rb index 8ad81e6d46..4a7442d488 100644 --- a/lib/rouge/lexers/python.rb +++ b/lib/rouge/lexers/python.rb @@ -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', '*.bzl', 'BUCK', 'BUILD', 'BUILD.bazel', 'WORKSPACE' + filenames '*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac', + '*.bzl', 'BUCK', 'BUILD', 'BUILD.bazel', 'WORKSPACE' mimetypes 'text/x-python', 'application/x-python' def self.detect?(text) diff --git a/spec/lexers/python_spec.rb b/spec/lexers/python_spec.rb index 971bd16a26..4f79903f36 100644 --- a/spec/lexers/python_spec.rb +++ b/spec/lexers/python_spec.rb @@ -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