Skip to content

Commit 082c6d0

Browse files
committed
Merge pull request #8 from caxy/feature-insert_space_in_replace
Add option to insert a space between del and ins tags
2 parents a2da731 + 260164c commit 082c6d0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lib/Caxy/HtmlDiff/HtmlDiff.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class HtmlDiff
2020
private $specialCaseTags;
2121
private $specialCaseChars;
2222
private $groupDiffs;
23+
private $insertSpaceInReplace = false;
2324

2425
public function __construct($oldText, $newText, $encoding = 'UTF-8', $specialCaseTags = null, $groupDiffs = null)
2526
{
@@ -39,6 +40,25 @@ public function __construct($oldText, $newText, $encoding = 'UTF-8', $specialCas
3940
$this->setSpecialCaseTags($specialCaseTags);
4041
$this->setSpecialCaseChars(static::$defaultSpecialCaseChars);
4142
}
43+
44+
/**
45+
* @param boolean $boolean
46+
* @return HtmlDiff
47+
*/
48+
public function setInsertSpaceInReplace($boolean)
49+
{
50+
$this->insertSpaceInReplace = $boolean;
51+
52+
return $this;
53+
}
54+
55+
/**
56+
* @return boolean
57+
*/
58+
public function getInsertSpaceInReplace()
59+
{
60+
return $this->insertSpaceInReplace;
61+
}
4262

4363
public function setSpecialCaseChars(array $chars)
4464
{
@@ -334,6 +354,9 @@ private function performOperation($operation)
334354
private function processReplaceOperation($operation)
335355
{
336356
$this->processDeleteOperation( $operation, "diffmod" );
357+
if ($this->insertSpaceInReplace) {
358+
$this->content .= ' ';
359+
}
337360
$this->processInsertOperation( $operation, "diffmod" );
338361
}
339362

0 commit comments

Comments
 (0)