diff --git a/lib/rouge/lexers/python.rb b/lib/rouge/lexers/python.rb index 8225a26364..72efe1f417 100644 --- a/lib/rouge/lexers/python.rb +++ b/lib/rouge/lexers/python.rb @@ -12,7 +12,7 @@ class Python < RegexLexer mimetypes 'text/x-python', 'application/x-python' def self.detect?(text) - return true if text.shebang?(/pythonw?(3|2(\.\d)?)?/) + return true if text.shebang?(/pythonw?(?:[23](?:\.\d+)?)?/) end def self.keywords diff --git a/spec/lexers/python_spec.rb b/spec/lexers/python_spec.rb index de0139754d..971bd16a26 100644 --- a/spec/lexers/python_spec.rb +++ b/spec/lexers/python_spec.rb @@ -23,9 +23,11 @@ it 'guesses by source' do assert_guess :source => '#!/usr/bin/env python' - assert_guess :source => '#!/usr/local/bin/python3' assert_guess :source => '#!/usr/bin/python2' assert_guess :source => '#!/usr/bin/python2.7' + assert_guess :source => '#!/usr/local/bin/python3' + assert_guess :source => '#!/usr/local/bin/python3.5' + assert_guess :source => '#!/usr/local/bin/python3.14' deny_guess :source => '#!/usr/bin/env python4' end end