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

JSDiff treats HTML content as a single line if there is no EOL at each line #388

Closed
srth12 opened this issue Nov 17, 2022 · 4 comments
Closed

Comments

@srth12
Copy link

srth12 commented Nov 17, 2022

I have entered HTML content as input (test, dent, den as example in the image), but it seems like treating it as a single line. Is there a way I can treat it as different lines? Since it treats it like a single line, all the content will be sent as diff instead of getting only the changeset. Any help will be appreciated.
image

image

@benatkin
Copy link

That's a CR at EOF, because if it isn't a line, there's no EOL

@srth12
Copy link
Author

srth12 commented Nov 19, 2022

@benatkin I understand that. Can’t this tool just take the diff and send only the changeset instead of sending the whole line with it? Or there is a way to do it that I am not aware of?

The tool can mention the line number and the column numbers instead of sending the whole line. Unless I can do this, this tool is not useful for my usecase😞.

@srth12 srth12 changed the title JSDiff treats HTML content as a single line if there is no carriage return at EOL JSDiff treats HTML content as a single line if there is no EOL at each line Nov 19, 2022
@srth12
Copy link
Author

srth12 commented Nov 19, 2022

A hackier way to solve this issue is by adding a newline char at EOL.

data = data.replaceAll(/<\/p>/g, '\n</p>')

@ExplodingCabbage
Copy link
Collaborator

Depending upon precisely what you need, you could potentially do it with diffChars or diffWords, but not with diffLines, and certainly not with createPatch et al because they return patches in unified diff format and unified diff format only supports deletions and insertions of entire lines.

@ExplodingCabbage ExplodingCabbage closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2024
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

3 participants