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 diff syntax definition #450

Merged
merged 2 commits into from
Sep 15, 2015
Merged

Add diff syntax definition #450

merged 2 commits into from
Sep 15, 2015

Conversation

uranusjr
Copy link
Contributor

Largely based on git’s definition for inserted and deleted, but expanded to support

  1. All coord styles including diff -c and diff -u.
  2. The >/< syntax.
  3. The ! syntax in context diff.

Example page included.

For the ! syntax I aliased important to diff.

@TimothyGu
Copy link
Contributor

In general, +1, although I would appreciate it if you can make Git depend on diff instead of still being stand-alone.

@uranusjr
Copy link
Contributor Author

uranusjr commented Jan 9, 2015

I don’t own the Git syntax though. Would be happy to help if @lgiraudel thinks this is a good idea.


// Match inserted and deleted lines. Support both +/- and >/< styles.
'deleted': /^[-\<](?![-\<]).+$/m,
'inserted': /^[\+\>](?![\+\>]).+$/m,
Copy link
Member

Choose a reason for hiding this comment

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

Why escape the angle brackets? Also + doesn’t need escaping inside a character class.
Also, what’s the negative lookahead trying to prevent? What happens if the line starts with e.g. ++ or >>?

@LeaVerou
Copy link
Member

Overall looks nice, see a few minor comments.
Thanks for adding examples too!
Please fix the merge conflicts?

Re:git, once I merge this, feel free to submit a PR to make it dependent on diff. It makes sense. Just because you don’t own it doesn’t mean you can’t suggest changes to it!

@Golmote Golmote mentioned this pull request Sep 14, 2015
@uranusjr
Copy link
Contributor Author

Thanks @LeaVerou, amended. Sorry for the changes taking so long, I totally forgot about this. :(

@Golmote
Copy link
Contributor

Golmote commented Sep 15, 2015

(You should not have included the autohotkey changes in this PR)
Thanks, I'm merging.

Golmote added a commit that referenced this pull request Sep 15, 2015
Add diff syntax definition
@Golmote Golmote merged commit ef41c74 into PrismJS:gh-pages Sep 15, 2015
@Golmote
Copy link
Contributor

Golmote commented Sep 15, 2015

@uranusjr Is it intended that those two lines in unified diff are matched as "coord"?

--- qcli.yml    2014-12-16 11:43:41.000000000 +0800
+++ /Users/uranusjr/Desktop/qcli.yml    2014-12-31 11:28:08.000000000 +0800

EDIT: The separator --- in normal diff is also matched as coord.

@uranusjr
Copy link
Contributor Author

@Golmote Yes that is what I intended, since they sort of act as separators between diff chunks, like the *** lines in context diff. That’s just my opinion though; I wouldn’t mind if you want it be done differently.

@Golmote
Copy link
Contributor

Golmote commented Sep 15, 2015

I'm telling because of #401 and #769. I just modified the git component to match those lines as "inserted" and "deleted".
I'll try to think of a way to distinguish between those lines containing file names and the lines containing coords.

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.

4 participants