{"id":32146057,"url":"https://github.com/simonbs/textdiffing","last_synced_at":"2026-02-19T07:01:34.362Z","repository":{"id":296973486,"uuid":"995151862","full_name":"simonbs/TextDiffing","owner":"simonbs","description":"🧬 TextDiffing helps you create an AttributedString / NSAttributedString to visualize differences between texts.","archived":false,"fork":false,"pushed_at":"2026-01-31T14:59:03.000Z","size":401,"stargazers_count":153,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-01T02:33:23.032Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonbs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"simonbs"}},"created_at":"2025-06-03T03:40:43.000Z","updated_at":"2026-01-31T14:58:41.000Z","dependencies_parsed_at":"2025-06-03T18:11:22.376Z","dependency_job_id":"a0f5f9ff-4ea9-43e9-ba43-84733bd81a43","html_url":"https://github.com/simonbs/TextDiffing","commit_stats":null,"previous_names":["simonbs/textdiffing"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/simonbs/TextDiffing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonbs%2FTextDiffing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonbs%2FTextDiffing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonbs%2FTextDiffing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonbs%2FTextDiffing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonbs","download_url":"https://codeload.github.com/simonbs/TextDiffing/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonbs%2FTextDiffing/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29605799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T06:47:36.664Z","status":"ssl_error","status_checked_at":"2026-02-19T06:45:47.551Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-21T08:01:39.670Z","updated_at":"2026-02-19T07:01:34.339Z","avatar_url":"https://github.com/simonbs.png","language":"Swift","funding_links":["https://github.com/sponsors/simonbs"],"categories":[],"sub_categories":[],"readme":"# 🧬 TextDiffing\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"screenshot.png\" width=\"405\"/\u003e\n\n\u003ch3\u003eTextDiffing helps you create an \u003ccode\u003eAttributedString\u003c/code\u003e / \u003ccode\u003eNSAttributedString\u003c/code\u003e to visualize differences between texts.\u003c/h3\u003e\n\n [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fsimonbs%2FTextDiffing%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/simonbs/TextDiffing)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fsimonbs%2FTextDiffing%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/simonbs/TextDiffing)\\\n[![Build](https://github.com/simonbs/TextDiffing/actions/workflows/build.yml/badge.svg)](https://github.com/simonbs/TextDiffing/actions/workflows/build.yml)\n[![SwiftLint](https://github.com/simonbs/TextDiffing/actions/workflows/swiftlint.yml/badge.svg)](https://github.com/simonbs/TextDiffing/actions/workflows/swiftlint.yml)\n[![Run Tests](https://github.com/simonbs/TextDiffing/actions/workflows/test.yml/badge.svg)](https://github.com/simonbs/TextDiffing/actions/workflows/test.yml)\n\u003c/div\u003e\n\n## ✨ Features\n\n- Compare two strings and generate [AttributedString](https://developer.apple.com/documentation/foundation/attributedstring) / [NSAttributedString](https://developer.apple.com/documentation/foundation/nsattributedstring) highlighting differences\n- Customize appearance of changes\n- Supports word- and character-level diffing\n- Lightweight and easy to integrate\n\n## 📦 Adding the Package\n\nTextDiffing is distributed using [Swift Package Manager](https://www.swift.org/documentation/package-manager/). Install TextDiffing in a project by adding it as a dependency in your Package.swift manifest or through “Package Dependencies” in project settings.\n\n```swift\nlet package = Package(\n    dependencies: [\n        .package(url: \"git@github.com:simonbs/textdiffing.git\", from: \"1.0.2\")\n    ]\n)\n```\n\n## 📖 Documentation\n\nThe documentation is \u003ca href=\"https://swiftpackageindex.com/simonbs/textdiffing/documentation\"\u003eavailable on Swift Package Index\u003c/a\u003e.\n\n## 🚀 Getting Started\n\nUse the TextDiffer to compare two strings.\n\n```swift\nlet result = TextDiffer.diff(text, and: otherText)\n```\n\nThe returned TextDiffResult has two properties:\n\n|Property|Description|\n|-|-|\n|`attributedString`|The formatted `AttributedString` representing the differences.|\n|`changeCount`|The number of changes (insertions or removals) between the texts.|\n\n```swift\nlet attributedString = result.attributedString\nlet changeCount = result.changeCount\n```\n\nThe `TextDiffer.diff(_:and:)` method also takes the following options.\n\n|Option|Description|\n|-|-|\n|`strikethroughRemovedText`|Adds a strikethrough to removed text.|\n|`tokenizeByCharacter`|Tokenizes the input by individual characters.|\n|`tokenizeByWord`|Tokenizes the input by words (default).|\n\nBy default, text is tokenized by word. You can combine multiple options to customize behavior.\n\n```swift\nlet result = TextDiffer.diff(text, and: otherText, options: [.tokenizeByCharacter, .strikethroughRemovedText])\n```\n\nYou can customize the appearance of inserted and removed text by providing your own TextDiffStyle. This lets you control the background color used for visual highlighting.\n\n```swift\nlet style = TextDiffStyle(\n    insertedBackground: UIColor.systemGreen.withAlphaComponent(0.3),\n    removedBackground: UIColor.systemRed.withAlphaComponent(0.3)\n)\nlet result = TextDiffer.diff(text, and: otherText, style: style)\n```\n\nYou may also use the extensions on NSAttributedString and AttributedString.\n\n```swift\nlet attributedString = AttributedString(diffing: text, and: otherText)\nlet attributedString = NSAttributedString(diffing: text, and: otherText)\n```\n\nThe initializers provided by the extensions also optionally take a style and options.\n\n```swift\nlet attributedString = AttributedString(diffing: text, and: otherText, style: style, options: options)\nlet attributedString = NSAttributedString(diffing: text, and: otherText, style: style, options: options)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonbs%2Ftextdiffing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonbs%2Ftextdiffing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonbs%2Ftextdiffing/lists"}