Skip to content

Fix HTML diff highlighting bug for lines containing '\n' #126

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

Merged
merged 1 commit into from
May 28, 2025

Conversation

P-SiZK
Copy link
Contributor

@P-SiZK P-SiZK commented May 28, 2025

Overview

This pull request fixes a bug in HTML diff output where, if a line contains '\n' and there are differences in parts of the line other than '\n', the '\n' is incorrectly treated as a newline character and causes unintended line breaks.

Details

  • In the implementation of Diffy::HtmlFormatter, when comparing lines containing '\n', if there are differences outside of the '\n' part, '\n' was interpreted as an actual newline in the HTML output, resulting in the line being split.
  • This issue only occurs with the :html format and does not affect other formats such as :html_simple.
  • With this fix, the '\n' part is displayed as-is in a single line, and only the differing parts are correctly highlighted.
  • Additional tests have been added to cover this case.

This is my first time submitting a pull request to this project.
I would appreciate your review, and if there is anything else I should do or if you have any feedback, please let me know.

@ErCargo
Copy link

ErCargo commented May 28, 2025 via email

@samg
Copy link
Owner

samg commented May 28, 2025

Nice job @P-SiZK! Thanks for the contribution.

@samg samg merged commit e4f30e1 into samg:main May 28, 2025
@P-SiZK
Copy link
Contributor Author

P-SiZK commented Jun 9, 2025

Hi @samg,

Appreciate you merging this! I'm looking forward to updating my Gemfile with the fix. Any idea when the next version might be released?

Thanks,

@samg
Copy link
Owner

samg commented Jun 9, 2025

I just pushed version 3.4.3 which includes this fix. Thanks for the contribution!

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.

3 participants