Skip to content

Commit

Permalink
Python: Support conversion specifiers in format strings (#1801)
Browse files Browse the repository at this point in the history
  • Loading branch information
chvp committed May 1, 2022
1 parent e814e5e commit e76cde4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rouge/lexers/python.rb
Expand Up @@ -218,9 +218,11 @@ def current_string
end

state :generic_interpol do
rule %r/[^{}]+/ do |m|
rule %r/[^{}!:]+/ do |m|
recurse m[0]
end
rule %r/![asr]/, Str::Interpol
rule %r/:/, Str::Interpol
rule %r/{/, Str::Interpol, :generic_interpol
rule %r/}/, Str::Interpol, :pop!
end
Expand Down
1 change: 1 addition & 0 deletions spec/visual/samples/python
Expand Up @@ -150,6 +150,7 @@ x @= y
f'{hello} world {int(x) + 1}'
f'{{ {4*10} }}'
f'result: {value:{width}.{precision}}'
f'{value!r}

# Unicode identifiers
α = 10
Expand Down

0 comments on commit e76cde4

Please sign in to comment.