From 6cf3eb47fd3c6a1cd23a6b45a196ac91575eb02a Mon Sep 17 00:00:00 2001 From: Tan Le Date: Thu, 1 Jun 2023 23:21:39 +1000 Subject: [PATCH] Fix highlight of ellipsis in Python lexer (#1964) This fixes ellipsis being incorrectly picked up as start of prompt in doctest. --- lib/rouge/lexers/python.rb | 4 +--- spec/visual/samples/python | 11 +++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/rouge/lexers/python.rb b/lib/rouge/lexers/python.rb index eba39c3eee..b47b64aa76 100644 --- a/lib/rouge/lexers/python.rb +++ b/lib/rouge/lexers/python.rb @@ -90,8 +90,6 @@ def current_string rule %r/@#{dotted_identifier}/i, Name::Decorator - rule %r/(>>>|\.\.\.)\B/, Generic::Prompt - rule %r/(in|is|and|or|not)\b/, Operator::Word rule %r/(<<|>>|\/\/|\*\*)=?/, Operator rule %r/[-~+\/*%=<>&^|@]=?|!=/, Operator @@ -182,7 +180,7 @@ def current_string end state :generic_string do - rule %r/>>>|\.\.\./, Generic::Prompt, :doctest + rule %r/^\s*(>>>|\.\.\.)\B/, Generic::Prompt, :doctest rule %r/[^'"\\{]+?/, Str rule %r/{{/, Str diff --git a/spec/visual/samples/python b/spec/visual/samples/python index dc8ec18af8..b9fbf4e818 100644 --- a/spec/visual/samples/python +++ b/spec/visual/samples/python @@ -207,3 +207,14 @@ def factorial(n): OverflowError: n too large """ print("hello world") + +def do_nothing(): + if False: + return + print("a...a") + + with tracer.start_as_current_span('App Init'): + logger.info('OTEL Initialized...') + + app = FastAPI() + FastAPIInstrumentor.instrument_app(app)