Skip to content

Diff parsing misinterprets file names for standard diff command #557

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

Open
jrk opened this issue Apr 7, 2025 · 1 comment
Open

Diff parsing misinterprets file names for standard diff command #557

jrk opened this issue Apr 7, 2025 · 1 comment

Comments

@jrk
Copy link

jrk commented Apr 7, 2025

If I want to diff plain files, independent of git, the natural thing to do is something like:

diff -u file1.js file2.js | diff2html -i stdin

This generally works, but it does not parse the filenames correctly. diff by default renders the filename header like this:

--- file1.js	2025-04-06 13:33:10
+++ file2.js	2025-04-07 09:10:40

The parser swallows the timestamps as part of the filename, too, which (1) is distracting clutter and (2) breaks syntax highlighting since it can't interpret the file type from the suffix anymore.

getFilename in diff-parser.js should be able to strip off these suffixes. I think they're always rendered with a \t character between the filename and the time, so it should be pretty straightforward.

@jrk
Copy link
Author

jrk commented Apr 7, 2025

I was actually reading the generated installed JS and didn't notice the comment in the TS source that the regex at the end is already intended to strip off these dates.

So update on the above issue: I'm not immediately sure why, but this doesn't work at least with /usr/bin/diff on macOS, which outputs a header exactly as shown in the issue.

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

No branches or pull requests

1 participant