aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/league/html-to-markdown/src/Converter/PreformattedConverter.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-06-05 08:47:24 +0000
committerMario <mario@mariovavti.com>2021-06-05 08:47:24 +0000
commitfd8a5ff4c49fc1361f9928ea4d33e6d24d43a3a5 (patch)
tree7560147f31a273fb8f0e05476f99f1deea0e12de /vendor/league/html-to-markdown/src/Converter/PreformattedConverter.php
parent4db384da34595adef68be6226e8b331b4d7b7f31 (diff)
downloadvolse-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/PreformattedConverter.php')
-rw-r--r--vendor/league/html-to-markdown/src/Converter/PreformattedConverter.php36
1 files changed, 17 insertions, 19 deletions
diff --git a/vendor/league/html-to-markdown/src/Converter/PreformattedConverter.php b/vendor/league/html-to-markdown/src/Converter/PreformattedConverter.php
index 321c898b1..7d8ccc132 100644
--- a/vendor/league/html-to-markdown/src/Converter/PreformattedConverter.php
+++ b/vendor/league/html-to-markdown/src/Converter/PreformattedConverter.php
@@ -1,20 +1,17 @@
<?php
+declare(strict_types=1);
+
namespace League\HTMLToMarkdown\Converter;
use League\HTMLToMarkdown\ElementInterface;
class PreformattedConverter implements ConverterInterface
{
- /**
- * @param ElementInterface $element
- *
- * @return string
- */
- public function convert(ElementInterface $element)
+ public function convert(ElementInterface $element): string
{
- $pre_content = html_entity_decode($element->getChildrenAsString());
- $pre_content = str_replace(array('<pre>', '</pre>'), '', $pre_content);
+ $preContent = \html_entity_decode($element->getChildrenAsString());
+ $preContent = \str_replace(['<pre>', '</pre>'], '', $preContent);
/*
* Checking for the code tag.
@@ -23,36 +20,37 @@ class PreformattedConverter implements ConverterInterface
* there's no more information to convert.
*/
- $firstBacktick = strpos(trim($pre_content), '`');
- $lastBacktick = strrpos(trim($pre_content), '`');
- if ($firstBacktick === 0 && $lastBacktick === strlen(trim($pre_content)) - 1) {
- return $pre_content . "\n\n";
+ $firstBacktick = \strpos(\trim($preContent), '`');
+ $lastBacktick = \strrpos(\trim($preContent), '`');
+ if ($firstBacktick === 0 && $lastBacktick === \strlen(\trim($preContent)) - 1) {
+ return $preContent . "\n\n";
}
// If the execution reaches this point it means it's just a pre tag, with no code tag nested
// Empty lines are a special case
- if ($pre_content === '') {
+ if ($preContent === '') {
return "```\n```\n\n";
}
// Normalizing new lines
- $pre_content = preg_replace('/\r\n|\r|\n/', "\n", $pre_content);
+ $preContent = \preg_replace('/\r\n|\r|\n/', "\n", $preContent);
+ \assert(\is_string($preContent));
// Ensure there's a newline at the end
- if (strrpos($pre_content, "\n") !== strlen($pre_content) - strlen("\n")) {
- $pre_content .= "\n";
+ if (\strrpos($preContent, "\n") !== \strlen($preContent) - \strlen("\n")) {
+ $preContent .= "\n";
}
// Use three backticks
- return "```\n" . $pre_content . "```\n\n";
+ return "```\n" . $preContent . "```\n\n";
}
/**
* @return string[]
*/
- public function getSupportedTags()
+ public function getSupportedTags(): array
{
- return array('pre');
+ return ['pre'];
}
}