diff --git a/src/Implementation/Html5TagRewriter.php b/src/Implementation/Html5TagRewriter.php
index c42f2bf..f2829b9 100644
--- a/src/Implementation/Html5TagRewriter.php
+++ b/src/Implementation/Html5TagRewriter.php
@@ -27,11 +27,11 @@ public function register(RewriteHandler $handler): void
#[Override]
public function process(string $html5): string
{
- $document = HTMLDocument::createFromString($html5, LIBXML_NOERROR);
+ $document = HTMLDocument::createFromString($this->convertEsiSelfClosingTagsToEmptyElements($html5), LIBXML_NOERROR);
$this->applyHandlers($document, $document);
- return $this->cleanup($document->saveHtml());
+ return $this->convertEsiEmptyElementsToSelfClosingTags($document->saveHtml());
}
#[Override]
@@ -51,11 +51,11 @@ public function processBodyFragment(string $html5Fragment): string
$container = $document->body;
assert($container !== null);
- $container->innerHTML = $html5Fragment;
+ $container->innerHTML = $this->convertEsiSelfClosingTagsToEmptyElements($html5Fragment);
$this->applyHandlers($document, $container);
- return $this->cleanup($container->innerHTML);
+ return $this->convertEsiEmptyElementsToSelfClosingTags($container->innerHTML);
}
private function applyHandlers(Document $document, Node $context): void
@@ -75,8 +75,13 @@ private function applyHandlers(Document $document, Node $context): void
}
}
- private function cleanup(string $html): string
+ private function convertEsiSelfClosingTagsToEmptyElements(string $html): string
{
- return preg_replace('#(
test
+