Skip to content

[elpi] matching parens of same color + nested quotations#2651

Merged
Anteru merged 5 commits into
pygments:masterfrom
FissoreD:master
Aug 9, 2024
Merged

[elpi] matching parens of same color + nested quotations#2651
Anteru merged 5 commits into
pygments:masterfrom
FissoreD:master

Conversation

@FissoreD
Copy link
Copy Markdown
Contributor

@FissoreD FissoreD commented Feb 20, 2024

Original (matching parens of different color)
image

Fixed
image

Original (nested quotations):
image

Fixed:
image

CC @gares

@Anteru
Copy link
Copy Markdown
Collaborator

Anteru commented Mar 26, 2024

Good catch. Would you mind adding an example for this? Previously apparently the first parentheses was matched as whitespace.

@Anteru Anteru self-assigned this Mar 26, 2024
@Anteru Anteru added the A-lexing area: changes to individual lexers label Mar 26, 2024
@Anteru Anteru added this to the 2.18.0 milestone Mar 26, 2024
@FissoreD FissoreD changed the title [elpi] matching parens of same color [elpi] matching parens of same color + nested quotations Mar 26, 2024
@gares
Copy link
Copy Markdown
Contributor

gares commented Mar 27, 2024

Please run CI

Comment thread pygments/lexers/elpi.py Outdated
Comment thread pygments/lexers/elpi.py Outdated
(r"\s", Text.Whitespace),
(r"(lp:)({})".format("{{"), bygroups(Number, Punctuation), 'elpi-quote-exit'),
(r"(lp:)((?=[A-Z_]){})".format(constant_re), bygroups(Number, Name.Variable)),
(r".", Text),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also .+, otherwise you get one match per character (see your output - you want multiple consecutive characters to match?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good idea! Nonetheless, .+ is overly aggressive, as I don't intend to capture all characters up to the next \n.
I can opt for a more nuanced approach, drawing inspiration from .+ but employing negative lookahead.

@gares
Copy link
Copy Markdown
Contributor

gares commented Apr 3, 2024

Please run ci

@Anteru Anteru modified the milestones: 2.18.0, 2.19.0 May 4, 2024
@gares
Copy link
Copy Markdown
Contributor

gares commented Jul 10, 2024

Looks good to me

@Anteru Anteru merged commit b578904 into pygments:master Aug 9, 2024
@gares
Copy link
Copy Markdown
Contributor

gares commented Aug 20, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-lexing area: changes to individual lexers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants