{"id":16817146,"url":"https://github.com/ssddanbrown/htmldiff","last_synced_at":"2025-11-06T03:30:27.178Z","repository":{"id":57058658,"uuid":"316830259","full_name":"ssddanbrown/HtmlDiff","owner":"ssddanbrown","description":"MIGRATED TO CODEBERG -- A HTML diff generator with display HTML output. ","archived":true,"fork":false,"pushed_at":"2024-03-29T16:57:44.000Z","size":98,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-10T20:32:48.839Z","etag":null,"topics":["html-diff","php"],"latest_commit_sha":null,"homepage":"https://codeberg.org/danb/HtmlDiff","language":"PHP","has_issues":true,"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/ssddanbrown.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"license.md","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},"funding":{"github":["ssddanbrown"]}},"created_at":"2020-11-28T22:06:52.000Z","updated_at":"2024-07-26T21:53:07.000Z","dependencies_parsed_at":"2024-06-19T00:04:13.786Z","dependency_job_id":null,"html_url":"https://github.com/ssddanbrown/HtmlDiff","commit_stats":{"total_commits":27,"total_committers":1,"mean_commits":27.0,"dds":0.0,"last_synced_commit":"92da405f8138066834b71ac7bedebbda6327761b"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssddanbrown%2FHtmlDiff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssddanbrown%2FHtmlDiff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssddanbrown%2FHtmlDiff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssddanbrown%2FHtmlDiff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ssddanbrown","download_url":"https://codeload.github.com/ssddanbrown/HtmlDiff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239479539,"owners_count":19645759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["html-diff","php"],"created_at":"2024-10-13T10:46:20.115Z","updated_at":"2025-11-06T03:30:27.140Z","avatar_url":"https://github.com/ssddanbrown.png","language":"PHP","readme":"# PHP HtmlDiff\n\n[![Build Status](https://github.com/ssddanbrown/htmldiff/workflows/phpunit/badge.svg)](https://github.com/ssddanbrown/htmldiff/actions)\n[![Latest Stable Version](https://poser.pugx.org/ssddanbrown/htmldiff/v)](https://packagist.org/packages/ssddanbrown/htmldiff)\n[![Total Downloads](https://poser.pugx.org/ssddanbrown/htmldiff/downloads)](https://packagist.org/packages/ssddanbrown/htmldiff)\n\n\nThis library will compare two provided HTML string inputs and output HTML, tagged with the differences between the two.\n\nThis is a PHP port of the [c# implementation found here](https://github.com/Rohland/htmldiff.net) which is a port of the [ruby implementation found here](https://github.com/myobie/htmldiff). Major credit to [@Rohland](https://github.com/Rohland) and [@myobie](https://github.com/myobie) for their original work which I have just simply translated to PHP.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require ssddanbrown/htmldiff\n```\n\n## Usage\n\nThe library provides a direct static function to quickly create a HTML diff:\n\n```php\n$diff = Ssddanbrown\\HtmlDiff\\Diff::excecute('\u003cp\u003eHello there!\u003c/p\u003e', '\u003cp\u003eHi there!\u003c/p\u003e');\n// $diff = '\u003cp\u003e\u003cdel class=\"diffmod\"\u003eHello\u003c/del\u003e\u003cins class=\"diffmod\"\u003eHi\u003c/ins\u003e there!\u003c/p\u003e';\n```\n\nAlternatively, You can instead create an instance of the `Diff` class to configure a few options first:\n\n```php\nuse Ssddanbrown\\HtmlDiff\\Diff;\n\n$diff = new Diff('\u003cp\u003eHello there!\u003c/p\u003e', '\u003cp\u003eHi there!\u003c/p\u003e');\n$diff-\u003erepeatingWordsAccuracy = 1;\n$diff-\u003eignoreWhitespaceDifferences = false;\n$diff-\u003eorphanMatchThreshold = 0.2;\n\n$output = $diff-\u003ebuild();\n```\n\n## Options\n\n#### $diff-\u003erepeatingWordsAccuracy\n\nNumber, Defaults to `1`. Valid values are from 0 to 1.\n\nDefines how to compare repeating words. This value allows to exclude some words from comparison that eventually reduces the total time of the diff algorithm. 0 means that all words are excluded so the diff will not find any matching words at all. 1 (default value) means that all words participate in comparison so this is the most accurate case. 0.5 means that any word that occurs more than 50% times may be excluded from comparison. This doesn't mean that such words will definitely be excluded but only gives a permission to exclude them if necessary.\n\n#### $diff-\u003eignoreWhitespaceDifferences\n\nBoolean value. Defaults to `true`.\n\nIf set to true all whitespace characters, including `\u0026nbsp;`, are treated as being equal.\n\n#### $diff-\u003eorphanMatchThreshold\n\nNumber, Defaults to `0`. Valid values are from 0 to 1.\n\nIf some match is too small and located far from its neighbors then it is considered as orphan and removed. This property defines relative size of the match to be considered as orphan, from 0 to 1. 1 means that all matches will be considered as orphans. 0 (default) means that no match will be considered as orphan. 0.2 means that if match length is less than 20% of distance between its neighbors it is considered as orphan.\n\n#### $diff-\u003eaddBlockExpression($expression)\n\nAdd a regular expression that will be used to 'group' text together so that it's treated as a single block. \n\nThe `$expression` passed to the method must be a valid PHP regex pattern string.\n\n## Development\n\nThis package is built to very closely follow the code and structure of the [c#](https://github.com/Rohland/htmldiff.net) library that it was originally ported from. It will remain closely aligned for this original release but may deviate in the future. \n\n[Psalm](https://psalm.dev/) is included for static analysis. It can be run like so:\n\n```bash\n./vendor/bin/psalm\n```\n\n[PHPUnit](https://phpunit.de/) is used for testing. It can be run like so:\n\n```bash\n./vendor/bin/phpunit\n```\n\n## License\n\nThis project, and the projects that this library has been ported from, is licensed under the MIT License. See the [license file](https://github.com/ssddanbrown/htmldiff/blob/master/license.md) for more info.\n\n","funding_links":["https://github.com/sponsors/ssddanbrown"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssddanbrown%2Fhtmldiff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssddanbrown%2Fhtmldiff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssddanbrown%2Fhtmldiff/lists"}