diff --git a/lib/Caxy/HtmlDiff/HtmlDiff.php b/lib/Caxy/HtmlDiff/HtmlDiff.php
index 4dbc85f..1a161b0 100644
--- a/lib/Caxy/HtmlDiff/HtmlDiff.php
+++ b/lib/Caxy/HtmlDiff/HtmlDiff.php
@@ -584,7 +584,7 @@ protected function checkCondition($word, $condition)
protected function wrapText(string $text, string $tagName, string $cssClass) : string
{
- if (trim($text) === '') {
+ if (!$this->config->isSpaceMatching() && trim($text) === '') {
return '';
}
diff --git a/lib/Caxy/HtmlDiff/HtmlDiffConfig.php b/lib/Caxy/HtmlDiff/HtmlDiffConfig.php
index 2f97a23..660c6fc 100644
--- a/lib/Caxy/HtmlDiff/HtmlDiffConfig.php
+++ b/lib/Caxy/HtmlDiff/HtmlDiffConfig.php
@@ -77,6 +77,11 @@ class HtmlDiffConfig
*/
protected $purifierCacheLocation = null;
+ /**
+ * @var bool
+ */
+ protected $spaceMatching = false;
+
/**
* @return HtmlDiffConfig
*/
@@ -441,6 +446,22 @@ public function getPurifierCacheLocation()
return $this->purifierCacheLocation;
}
+ /**
+ * @return bool
+ */
+ public function isSpaceMatching()
+ {
+ return $this->spaceMatching;
+ }
+
+ /**
+ * @param bool $keepNewLines
+ */
+ public function setSpaceMatching($spaceMatching)
+ {
+ $this->spaceMatching = $spaceMatching;
+ }
+
/**
* @param string $tag
*
diff --git a/tests/fixtures/HtmlDiff/simple-list.html b/tests/fixtures/HtmlDiff/simple-list.html
index 5f909fa..72c6357 100644
--- a/tests/fixtures/HtmlDiff/simple-list.html
+++ b/tests/fixtures/HtmlDiff/simple-list.html
@@ -1,26 +1,26 @@
- Hi there
-
-
+ Hi there
+