aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/league
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-02-11 09:21:19 +0000
committerMario <mario@mariovavti.com>2022-02-11 09:21:19 +0000
commit6d8aabab2347feabdd804b609dcd4513f09f78d4 (patch)
tree9bea1aba6caa85084ec664f498c445bb92d9457c /vendor/league
parente74359fcfe4d97efe72a811b45526a69edae3893 (diff)
downloadvolse-hubzilla-6d8aabab2347feabdd804b609dcd4513f09f78d4.tar.gz
volse-hubzilla-6d8aabab2347feabdd804b609dcd4513f09f78d4.tar.bz2
volse-hubzilla-6d8aabab2347feabdd804b609dcd4513f09f78d4.zip
composer libs minor version updates
Diffstat (limited to 'vendor/league')
-rw-r--r--vendor/league/html-to-markdown/CHANGELOG.md9
-rw-r--r--vendor/league/html-to-markdown/src/HtmlConverter.php32
2 files changed, 40 insertions, 1 deletions
diff --git a/vendor/league/html-to-markdown/CHANGELOG.md b/vendor/league/html-to-markdown/CHANGELOG.md
index 36fb1249e..03c3f6f5c 100644
--- a/vendor/league/html-to-markdown/CHANGELOG.md
+++ b/vendor/league/html-to-markdown/CHANGELOG.md
@@ -4,6 +4,12 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
## [Unreleased][unreleased]
+## [5.0.2] - 2021-11-06
+
+### Fixed
+
+ - Fixed missplaced comment nodes appearing at the start of the HTML input (#212)
+
## [5.0.1] - 2021-09-17
### Fixed
@@ -299,7 +305,8 @@ not ideally set, so this releases fixes that. Moving forwards this should reduce
### Added
- Initial release
-[unreleased]: https://github.com/thephpleague/html-to-markdown/compare/5.0.1...master
+[unreleased]: https://github.com/thephpleague/html-to-markdown/compare/5.0.2...master
+[5.0.2]: https://github.com/thephpleague/html-to-markdown/compare/5.0.1...5.0.2
[5.0.1]: https://github.com/thephpleague/html-to-markdown/compare/5.0.0...5.0.1
[5.0.0]: https://github.com/thephpleague/html-to-markdown/compare/4.10.0...5.0.0
[4.10.0]: https://github.com/thephpleague/html-to-markdown/compare/4.9.1...4.10.0
diff --git a/vendor/league/html-to-markdown/src/HtmlConverter.php b/vendor/league/html-to-markdown/src/HtmlConverter.php
index 7cd543b34..7162b256d 100644
--- a/vendor/league/html-to-markdown/src/HtmlConverter.php
+++ b/vendor/league/html-to-markdown/src/HtmlConverter.php
@@ -121,6 +121,8 @@ class HtmlConverter implements HtmlConverterInterface
$document->loadHTML('<?xml encoding="UTF-8">' . $html);
$document->encoding = 'UTF-8';
+ $this->replaceMisplacedComments($document);
+
if ($this->getConfig()->getOption('suppress_errors')) {
\libxml_clear_errors();
}
@@ -129,6 +131,36 @@ class HtmlConverter implements HtmlConverterInterface
}
/**
+ * Finds any comment nodes outside <html> element and moves them into <body>.
+ *
+ * @see https://github.com/thephpleague/html-to-markdown/issues/212
+ * @see https://3v4l.org/7bC33
+ */
+ private function replaceMisplacedComments(\DOMDocument $document): void
+ {
+ // Find ny comment nodes at the root of the document.
+ $misplacedComments = (new \DOMXPath($document))->query('/comment()');
+ if ($misplacedComments === false) {
+ return;
+ }
+
+ $body = $document->getElementsByTagName('body')->item(0);
+ if ($body === null) {
+ return;
+ }
+
+ // Loop over comment nodes in reverse so we put them inside <body> in
+ // their original order.
+ for ($index = $misplacedComments->length - 1; $index >= 0; $index--) {
+ if ($body->firstChild === null) {
+ $body->insertBefore($misplacedComments[$index]);
+ } else {
+ $body->insertBefore($misplacedComments[$index], $body->firstChild);
+ }
+ }
+ }
+
+ /**
* Convert Children
*
* Recursive function to drill into the DOM and convert each node into Markdown from the inside out.