https://github.com/sokil/php-diff
Highlight diffs provided by Sebastian Bergmann diff
https://github.com/sokil/php-diff
diff diff-highlight highlight php
Last synced: 12 months ago
JSON representation
Highlight diffs provided by Sebastian Bergmann diff
- Host: GitHub
- URL: https://github.com/sokil/php-diff
- Owner: sokil
- Created: 2016-05-13T12:38:10.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-07-04T19:52:48.000Z (over 6 years ago)
- Last Synced: 2024-11-21T12:48:54.656Z (over 1 year ago)
- Topics: diff, diff-highlight, highlight, php
- Language: PHP
- Homepage:
- Size: 24.4 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# php-diff
Highlight diffs provided by Sebastian Bergmann diff
[](https://travis-ci.org/sokil/php-diff)
[](https://coveralls.io/github/sokil/php-diff?branch=master)
[](https://packagist.org/packages/sokil/php-diff)
## Installation
```
composer.phar require sokil/php-diff
```
## Useage
```php
render(new Change(
implode(PHP_EOL, ['line1', 'line2', 'line3']),
implode(PHP_EOL, ['line1', 'line2changed', 'line3'])
));
```
## Format of diff output
Format of diff tags may be configured. By default renders only two tags: `` and ``. To
highlight output, use predefined format:
```php
Renderer::FORMAT_COLOUR
]);
```
This will produce following HTML:
```html
line1
line2
line2changed
line3
```
To fully customize style, use next syntax (this format has alias `Renderer::FORMAT_COLOUR`):
```php
[
'insert' => [
'tag' => 'ins',
'attributes' => 'style="background: #ddfade;"',
],
'delete' => [
'tag' => 'del',
'attributes' => 'style="background: #ffe7e7;"',
]
]
]);
// this is same to
$renderer = new Renderer([
'format' => Renderer::FORMAT_COLOUR
]);
```
Default format `Renderer::FORMAT_DEFAULT` has following notation:
```php
[
'tag' => 'ins',
],
'delete' => [
'tag' => 'del',
]
]);
// this is same to
$renderer = new Renderer([
'format' => Renderer::FORMAT_DEFAULT
]);
```