From 36bee86e4a6a5a201be9d23a8e2bc1766f066fad Mon Sep 17 00:00:00 2001 From: ajnisbet Date: Tue, 10 Dec 2019 16:13:58 -0800 Subject: [PATCH 1/2] Remove . as a operator in Python lexer Fixes #1374 --- lib/rouge/lexers/python.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/rouge/lexers/python.rb b/lib/rouge/lexers/python.rb index 584f1c5e6d..fd43230a82 100644 --- a/lib/rouge/lexers/python.rb +++ b/lib/rouge/lexers/python.rb @@ -83,7 +83,6 @@ def self.exceptions rule %r/(in|is|and|or|not)\b/, Operator::Word rule %r/(<<|>>|\/\/|\*\*)=?/, Operator rule %r/[-~+\/*%=<>&^|@]=?|!=/, Operator - rule %r/\.(?![0-9])/, Operator # so it doesn't match float literals rule %r/(from)((?:\\\s|\s)+)(#{dotted_identifier})((?:\\\s|\s)+)(import)/ do groups Keyword::Namespace, From a2d870a8730e190f71dd84a5f143f19a3e3ae805 Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Fri, 13 Dec 2019 11:29:33 +0900 Subject: [PATCH 2/2] Recognise . as punctuation rather than operator --- lib/rouge/lexers/python.rb | 2 +- spec/visual/samples/python | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/rouge/lexers/python.rb b/lib/rouge/lexers/python.rb index fd43230a82..42e64470ab 100644 --- a/lib/rouge/lexers/python.rb +++ b/lib/rouge/lexers/python.rb @@ -76,7 +76,7 @@ def self.exceptions rule %r/[^\S\n]+/, Text rule %r(#(.*)?\n?), Comment::Single - rule %r/[\[\]{}:(),;]/, Punctuation + rule %r/[\[\]{}:(),;.]/, Punctuation rule %r/\\\n/, Text rule %r/\\/, Text diff --git a/spec/visual/samples/python b/spec/visual/samples/python index cbea36c3a1..218a05c87e 100644 --- a/spec/visual/samples/python +++ b/spec/visual/samples/python @@ -142,3 +142,5 @@ float_literals = [ # PEP 465 a = b @ c x @= y + +floats = (19.0, 19.)