lib/rouge/lexers/python.rb in rouge-0.0.6 vs lib/rouge/lexers/python.rb in rouge-0.0.7
- old
+ new
@@ -1,12 +1,17 @@
module Rouge
module Lexers
class Python < RegexLexer
tag 'python'
aliases 'py'
- extensions 'py'
+ filenames '*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac'
+ mimetypes 'text/x-python', 'application/x-python'
+ def self.analyze_text(text)
+ return 1 if text.shebang?(/pythonw?(3|2(\.\d)?)?/)
+ end
+
keywords = %w(
assert break continue del elif else except exec
finally for global if lambda pass print raise
return try while yield as with
)
@@ -43,10 +48,11 @@
identifier = /[a-z_][a-z0-9_]*/i
dotted_identifier = /[a-z_.][a-z0-9_.]*/i
state :root do
rule /\n+/m, 'Text'
- rule /^(\s*)([rRuU]{,2}""".*?""")/m do
+ rule /^(:)(\s*)([ru]{,2}""".*?""")/mi do
+ group 'Punctuation'
group 'Text'
group 'Literal.String.Doc'
end
rule /[^\S\n]+/, 'Text'