lib/rouge/lexers/python.rb in rouge-4.0.1 vs lib/rouge/lexers/python.rb in rouge-4.1.0

- old
+ new

@@ -38,11 +38,11 @@ vars xrange zip ) end def self.builtins_pseudo - @builtins_pseudo ||= %w(self None Ellipsis NotImplemented False True) + @builtins_pseudo ||= %w(None Ellipsis NotImplemented False True) end def self.exceptions @exceptions ||= %w( ArithmeticError AssertionError AttributeError @@ -84,24 +84,26 @@ rule %r(#(.*)?\n?), Comment::Single rule %r/[\[\]{}:(),;.]/, Punctuation rule %r/\\\n/, Text rule %r/\\/, Text + rule %r/@#{dotted_identifier}/i, Name::Decorator + rule %r/(in|is|and|or|not)\b/, Operator::Word rule %r/(<<|>>|\/\/|\*\*)=?/, Operator rule %r/[-~+\/*%=<>&^|@]=?|!=/, Operator rule %r/(from)((?:\\\s|\s)+)(#{dotted_identifier})((?:\\\s|\s)+)(import)/ do groups Keyword::Namespace, Text, - Name::Namespace, + Name, Text, Keyword::Namespace end rule %r/(import)(\s+)(#{dotted_identifier})/ do - groups Keyword::Namespace, Text, Name::Namespace + groups Keyword::Namespace, Text, Name end rule %r/(def)((?:\s|\\\s)+)/ do groups Keyword, Text push :funcname @@ -110,18 +112,19 @@ rule %r/(class)((?:\s|\\\s)+)/ do groups Keyword, Text push :classname end + rule %r/([a-z_]\w*)[ \t]*(?=(\(.*\)))/m, Name::Function + rule %r/([A-Z_]\w*)[ \t]*(?=(\(.*\)))/m, Name::Class + # TODO: not in python 3 rule %r/`.*?`/, Str::Backtick rule %r/([rfbu]{0,2})('''|"""|['"])/i do |m| groups Str::Affix, Str current_string.register type: m[1].downcase, delim: m[2] push :generic_string end - - rule %r/@#{dotted_identifier}/i, Name::Decorator # using negative lookbehind so we don't match property names rule %r/(?<!\.)#{identifier}/ do |m| if self.class.keywords.include? m[0] token Keyword