Skip to content

Commit

Permalink
Fix highlight of ellipsis in Python lexer (#1964)
Browse files Browse the repository at this point in the history
This fixes ellipsis being incorrectly picked up as start of prompt in
doctest.
  • Loading branch information
tancnle committed Jun 1, 2023
1 parent e7f6fb1 commit 6cf3eb4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/rouge/lexers/python.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions spec/visual/samples/python
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 6cf3eb4

Please sign in to comment.