Skip to content
This repository was archived by the owner on Apr 19, 2022. It is now read-only.

Commit 61037a0

Browse files
committed
fix   bug
1 parent dd7da55 commit 61037a0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Artack/DOMQuery/DOMQuery.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ public static function createFromString($string, $baseUrl = null, $charset = nul
140140
$string = mb_convert_encoding($string, 'HTML-ENTITIES', $charset);
141141
}
142142

143+
$string = str_replace(' ', '[nbsp]', $string);
144+
143145
$current = libxml_use_internal_errors(true);
144146
$disableEntities = libxml_disable_entity_loader(true);
145147

@@ -442,7 +444,8 @@ public function getName()
442444
public function getHtml()
443445
{
444446
foreach($this->nodes as $node) {
445-
return trim($this->loadDOMDocument($node)->saveHtml($node));
447+
$content = $this->loadDOMDocument($node)->saveHtml($node);
448+
return trim(str_replace('[nbsp]', ' ', $content));
446449
}
447450

448451
return '';
@@ -462,7 +465,7 @@ public function getInnerHtml()
462465
$content .= $this->loadDOMDocument($childNode)->saveHtml($childNode);
463466
}
464467

465-
return trim($content);
468+
return trim(str_replace('[nbsp]',' ', $content));
466469
}
467470

468471
return '';

0 commit comments

Comments
 (0)