aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/league/html-to-markdown/src/Converter
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2019-11-08 13:10:24 -0800
committerzotlabs <mike@macgirvin.com>2019-11-08 13:10:24 -0800
commit00dd52317adb0f7db339649e076df331975a8398 (patch)
treed9559c19aafb1fb0ead583aeab662b1f9a94d2a5 /vendor/league/html-to-markdown/src/Converter
parent17522b31e9d7f092ecf5565ec28be270af7fad7b (diff)
parent163b1ee9f82985755f8e74fd144780ae08ce4030 (diff)
downloadvolse-hubzilla-00dd52317adb0f7db339649e076df331975a8398.tar.gz
volse-hubzilla-00dd52317adb0f7db339649e076df331975a8398.tar.bz2
volse-hubzilla-00dd52317adb0f7db339649e076df331975a8398.zip
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
Diffstat (limited to 'vendor/league/html-to-markdown/src/Converter')
-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;
+ }
}