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

Add default diff support #732

Merged

Conversation

CosmicHorrorDev
Copy link
Contributor

This adds support for the default diff syntax. It looks like this is missing from pygments too, so I'll have to open a PR with them tomorrow

I didn't know what token type was appropriate for the separator, so I went with GenericStrong, but feel free to suggest something else

Demo

default.diff

1,2d0
< A
< A
4c2
< C
---
> F
5a4
> E

Generated with

old.txt

A
A
B
C
D

new.txt

B
F
D
E
$ diff old.txt new.txt > default.diff

Results

chroma --format="tokens" default.diff

Before

&Token{Text, "1,2d0\n< A\n< A\n4c2\n< C\n"}
&Token{GenericDeleted, "---\n"}
&Token{Text, "> F\n5a4\n> E\n"}

After

&Token{GenericSubheading, "1,2d0\n"}
&Token{GenericDeleted, "< A\n< A\n"}
&Token{GenericSubheading, "4c2\n"}
&Token{GenericDeleted, "< C\n"}
&Token{GenericStrong, "---\n"}
&Token{GenericInserted, "> F\n"}
&Token{GenericSubheading, "5a4\n"}
&Token{GenericInserted, "> E\n"}

Copy link
Owner

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

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

Nice, thanks!

@alecthomas alecthomas merged commit d5b3291 into alecthomas:master Jan 18, 2023
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.

None yet

2 participants