aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/league/html-to-markdown/src/Converter/CommentConverter.php
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2019-11-08 23:39:04 +0100
committerMax Kostikov <max@kostikov.co>2019-11-08 23:39:04 +0100
commitec68ede79faffd5733c3eaa24df2e4fb3b54eeb9 (patch)
treec26098c1c0ebff705dc4ef4f324b8b1656c61b9a /vendor/league/html-to-markdown/src/Converter/CommentConverter.php
parent3706afbd01164c9f322c605d6ec242e6ca4770fa (diff)
parent478014f02a9241ec6d5b5e9672968897176302d2 (diff)
downloadvolse-hubzilla-ec68ede79faffd5733c3eaa24df2e4fb3b54eeb9.tar.gz
volse-hubzilla-ec68ede79faffd5733c3eaa24df2e4fb3b54eeb9.tar.bz2
volse-hubzilla-ec68ede79faffd5733c3eaa24df2e4fb3b54eeb9.zip
Merge branch 'dev' into 'dev'
Dev sync See merge request kostikov/core!4
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;
+ }
}