diff --git a/src/Processor/HtmlIdProcessor.php b/src/Processor/HtmlIdProcessor.php index 4fd0c0d1..02f056a6 100644 --- a/src/Processor/HtmlIdProcessor.php +++ b/src/Processor/HtmlIdProcessor.php @@ -62,21 +62,21 @@ public function __invoke(array &$data, Content $content): void private function setIdFromContent(\DOMElement $element): void { - if (!$id = $element->getAttribute('id')) { + if (!$element->getAttribute('id')) { $element->setAttribute('id', $this->slugify($element->textContent)); } } private function setIdFromHashedContent(\DOMElement $element): void { - if (!$id = $element->getAttribute('id')) { + if (!$element->getAttribute('id')) { $element->setAttribute('id', $this->hash($element->textContent)); } } private function setIdForImage(\DOMElement $element): void { - if (!$id = $element->getAttribute('id')) { + if (!$element->getAttribute('id')) { $name = $element->getAttribute('alt') ?: basename($element->getAttribute('src')); $element->setAttribute('id', $this->slugify($name)); } diff --git a/src/Service/NaiveHtmlCrawlerManager.php b/src/Service/NaiveHtmlCrawlerManager.php index 14548c06..30797f5c 100644 --- a/src/Service/NaiveHtmlCrawlerManager.php +++ b/src/Service/NaiveHtmlCrawlerManager.php @@ -40,16 +40,16 @@ public function save(Content $content, array &$data, string $property): void $key = "{$content->getType()}:{$content->getSlug()}"; if (isset($this->crawlers[$key][$property])) { - $data[$property] = $this->crawlers[$key][$property]->html(); + $data[$property] = $this->crawlers[$key][$property]->filterXPath('//body')->first()->html(); unset($this->crawlers[$key][$property]); } } public function saveAll(Content $content, array &$data): void { - foreach ($this->crawlers as $key => $crawlers) { + foreach ($this->crawlers as $crawlers) { foreach ($crawlers as $property => $crawler) { - $data[$property] = $crawler->html(); + $data[$property] = $crawler->filterXPath('//body')->first()->html(); } } diff --git a/src/Service/Parsedown.php b/src/Service/Parsedown.php index fbf023b2..fa0cd31a 100644 --- a/src/Service/Parsedown.php +++ b/src/Service/Parsedown.php @@ -63,13 +63,15 @@ protected function blockAdmonition($line, $block = null) return $block; } + + return null; } protected function blockAdmonitionContinue($line, $block = null) { // A blank newline has occurred, or text without indent: if (isset($block['interrupted']) || $line['indent'] < 4) { - return; + return null; } $previous = $block['$admonitionContentRef'] ?? "\n"; diff --git a/src/Service/SharedHtmlCrawlerManager.php b/src/Service/SharedHtmlCrawlerManager.php index b936d860..ce42db8f 100644 --- a/src/Service/SharedHtmlCrawlerManager.php +++ b/src/Service/SharedHtmlCrawlerManager.php @@ -54,7 +54,7 @@ public function saveAll(Content $content, array &$data): void } foreach ($this->crawlers[$key] as $property => $crawler) { - $data[$property] = $crawler->html(); + $data[$property] = $crawler->filterXPath('//body')->first()->html(); } unset($this->crawlers[$key]); diff --git a/tests/Unit/Processor/ResolveContentLinksProcessorTest.php b/tests/Unit/Processor/ResolveContentLinksProcessorTest.php index 2dbdfd7f..aec34fdd 100644 --- a/tests/Unit/Processor/ResolveContentLinksProcessorTest.php +++ b/tests/Unit/Processor/ResolveContentLinksProcessorTest.php @@ -70,7 +70,11 @@ public function testResolveLinks(): void Another content with anchor HTML, - $data['content'] + << + {$data['content']} + + HTML, ); } }