diff options
author | Mario <mario@mariovavti.com> | 2021-06-05 08:47:24 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-06-05 08:47:24 +0000 |
commit | fd8a5ff4c49fc1361f9928ea4d33e6d24d43a3a5 (patch) | |
tree | 7560147f31a273fb8f0e05476f99f1deea0e12de /vendor/league/html-to-markdown/src/Converter/TextConverter.php | |
parent | 4db384da34595adef68be6226e8b331b4d7b7f31 (diff) | |
download | volse-hubzilla-fd8a5ff4c49fc1361f9928ea4d33e6d24d43a3a5.tar.gz volse-hubzilla-fd8a5ff4c49fc1361f9928ea4d33e6d24d43a3a5.tar.bz2 volse-hubzilla-fd8a5ff4c49fc1361f9928ea4d33e6d24d43a3a5.zip |
composer update league/html-to-markdown
Diffstat (limited to 'vendor/league/html-to-markdown/src/Converter/TextConverter.php')
-rw-r--r-- | vendor/league/html-to-markdown/src/Converter/TextConverter.php | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/vendor/league/html-to-markdown/src/Converter/TextConverter.php b/vendor/league/html-to-markdown/src/Converter/TextConverter.php index 6236a1e9d..465dd4883 100644 --- a/vendor/league/html-to-markdown/src/Converter/TextConverter.php +++ b/vendor/league/html-to-markdown/src/Converter/TextConverter.php @@ -1,48 +1,48 @@ <?php +declare(strict_types=1); + namespace League\HTMLToMarkdown\Converter; use League\HTMLToMarkdown\ElementInterface; class TextConverter implements ConverterInterface { - /** - * @param ElementInterface $element - * - * @return string - */ - public function convert(ElementInterface $element) + public function convert(ElementInterface $element): string { $markdown = $element->getValue(); // Remove leftover \n at the beginning of the line - $markdown = ltrim($markdown, "\n"); + $markdown = \ltrim($markdown, "\n"); // Replace sequences of invisible characters with spaces - $markdown = preg_replace('~\s+~u', ' ', $markdown); + $markdown = \preg_replace('~\s+~u', ' ', $markdown); + \assert(\is_string($markdown)); // Escape the following characters: '*', '_', '[', ']' and '\' - if ($element->getParent() && $element->getParent()->getTagName() !== 'div') { - $markdown = preg_replace('~([*_\\[\\]\\\\])~u', '\\\\$1', $markdown); + if (($parent = $element->getParent()) && $parent->getTagName() !== 'div') { + $markdown = \preg_replace('~([*_\\[\\]\\\\])~u', '\\\\$1', $markdown); + \assert(\is_string($markdown)); } - $markdown = preg_replace('~^#~u', '\\\\#', $markdown); + $markdown = \preg_replace('~^#~u', '\\\\#', $markdown); + \assert(\is_string($markdown)); if ($markdown === ' ') { $next = $element->getNext(); - if (!$next || $next->isBlock()) { + if (! $next || $next->isBlock()) { $markdown = ''; } } - return htmlspecialchars($markdown, ENT_NOQUOTES, 'UTF-8'); + return \htmlspecialchars($markdown, ENT_NOQUOTES, 'UTF-8'); } /** * @return string[] */ - public function getSupportedTags() + public function getSupportedTags(): array { - return array('#text'); + return ['#text']; } } |