aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/league/html-to-markdown/src/Converter/CommentConverter.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-11-08 09:46:23 +0000
committerMario <mario@mariovavti.com>2019-11-08 10:47:28 +0100
commitbcd0802ea4a23971b5d53892c7de4e9e1822309f (patch)
treed63be67b6c55f2f17496e8b4fc1796cb88b7960e /vendor/league/html-to-markdown/src/Converter/CommentConverter.php
parent9360148829bb32351d40b2b552ea40ea3878b3b5 (diff)
downloadvolse-hubzilla-bcd0802ea4a23971b5d53892c7de4e9e1822309f.tar.gz
volse-hubzilla-bcd0802ea4a23971b5d53892c7de4e9e1822309f.tar.bz2
volse-hubzilla-bcd0802ea4a23971b5d53892c7de4e9e1822309f.zip
update composr libs
(cherry picked from commit 2df15f35d706d4608ff723ce6288391ca774f7ba)
Diffstat (limited to 'vendor/league/html-to-markdown/src/Converter/CommentConverter.php')
-rw-r--r--vendor/league/html-to-markdown/src/Converter/CommentConverter.php38
1 files changed, 37 insertions, 1 deletions
diff --git a/vendor/league/html-to-markdown/src/Converter/CommentConverter.php b/vendor/league/html-to-markdown/src/Converter/CommentConverter.php
index 55038b254..959381d1b 100644
--- a/vendor/league/html-to-markdown/src/Converter/CommentConverter.php
+++ b/vendor/league/html-to-markdown/src/Converter/CommentConverter.php
@@ -2,17 +2,35 @@
namespace League\HTMLToMarkdown\Converter;
+use League\HTMLToMarkdown\Configuration;
+use League\HTMLToMarkdown\ConfigurationAwareInterface;
use League\HTMLToMarkdown\ElementInterface;
-class CommentConverter implements ConverterInterface
+class CommentConverter implements ConverterInterface, ConfigurationAwareInterface
{
/**
+ * @var Configuration
+ */
+ protected $config;
+
+ /**
+ * @param Configuration $config
+ */
+ public function setConfig(Configuration $config)
+ {
+ $this->config = $config;
+ }
+
+ /**
* @param ElementInterface $element
*
* @return string
*/
public function convert(ElementInterface $element)
{
+ if ($this->shouldPreserve($element)) {
+ return '<!--' . $element->getValue() . '-->';
+ }
return '';
}
@@ -23,4 +41,22 @@ class CommentConverter implements ConverterInterface
{
return array('#comment');
}
+
+ /**
+ * @param ElementInterface $element
+ *
+ * @return bool
+ */
+ private function shouldPreserve(ElementInterface $element)
+ {
+ $preserve = $this->config->getOption('preserve_comments');
+ if ($preserve === true) {
+ return true;
+ }
+ if (is_array($preserve)) {
+ $value = trim($element->getValue());
+ return in_array($value, $preserve);
+ }
+ return false;
+ }
}