Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: Support conversion specifiers in format strings #1801

Merged
merged 1 commit into from
May 1, 2022

Conversation

chvp
Copy link
Contributor

@chvp chvp commented Feb 5, 2022

Fixes #1800. Format string syntax can be found here: https://docs.python.org/3/library/string.html#format-string-syntax

Technically only [asr] is allowed after !. If wanted, I could make the entire ![asr] punctuation (or something else entirely), but parsing the specifier as a generic Python expression (so in practice, an identifier) seems fine to me.

@tancnle
Copy link
Collaborator

tancnle commented Feb 20, 2022

@chvp Thank you for your contribution ❤️ TIL about conversion in format string syntax.

Technically only [asr] is allowed after !

It will be great to constrain the rule as you said. Would it be possible to do that in this PR? FYI, Pygments has support for conversion specifiers that we could port over to Rouge. WDYT?

@chvp
Copy link
Contributor Author

chvp commented Feb 21, 2022

I updated it so it is constrained to [asr]. I also carried over the same categories as in pygments.

@chvp
Copy link
Contributor Author

chvp commented Apr 30, 2022

@tancnle Is anything blocking this from being merged?

@tancnle
Copy link
Collaborator

tancnle commented May 1, 2022

@chvp Sorry for the delay. I think this is a good change.

We would have to look into extending this support for the standard string in the future.

Screen Shot 2022-05-01 at 8 31 46 pm

@tancnle tancnle merged commit e76cde4 into rouge-ruby:master May 1, 2022
@chvp chvp deleted the python-format-conversion branch May 2, 2022 07:23
razetime pushed a commit to razetime/rouge that referenced this pull request Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python: exclamation mark in f-string marked as error
2 participants