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

YOLO Refactor: Version 1.0.0 #12

Merged
merged 28 commits into from
Mar 10, 2025
Merged

Conversation

johnnyshields
Copy link
Collaborator

@johnnyshields johnnyshields commented Mar 10, 2025

I've refactored the gem into core components:

  • Tokenizer: Turns the old/new input strings into array of tokens to be diffed (similar to an LLM tokenizer). Special logic is added to treat the contents of HTML tags, URLs, and email addresses as single tokens.
  • DiffBuilder: Does a diff of the old vs. new tokenized arrays.
  • Formatter: Renders the output into HTML.

In the process, I realized that the DiffBuilder component is doing exactly what the very well-maintained diff-lcs gem already does much, much better, so I swapped out the guts for that gem. This magically fixed an issue where "foo bar baz" vs. "foo qux baz" would be grouped as ["foo", [" bar"/" qux"], " baz"] (leading whitespace in diff) rather than ["foo ", ["bar "/"qux "], "baz"] (trailing whitespace in diff), so yay for that!

Despite the size of this refactor, the core interface HTMLDiff.diff has not changed, and all previous specs pass + I added tons of new ones.

YOLO!!!

@johnnyshields johnnyshields changed the title [WIP] Refactor lib into class-specific files [WIP] YOLO Refactor: Version 2.0.0 Mar 10, 2025
@johnnyshields johnnyshields changed the title [WIP] YOLO Refactor: Version 2.0.0 [WIP] YOLO Refactor: Version 1.0.0 Mar 10, 2025
@johnnyshields johnnyshields changed the title [WIP] YOLO Refactor: Version 1.0.0 YOLO Refactor: Version 1.0.0 Mar 10, 2025
@johnnyshields johnnyshields merged commit 96e5b3d into myobie:master Mar 10, 2025
24 checks passed
@johnnyshields johnnyshields deleted the class-refactor branch March 10, 2025 18:26
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.

1 participant