aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/league/html-to-markdown/src
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2018-08-28 12:00:23 +0200
committerMario Vavti <mario@mariovavti.com>2018-08-28 12:00:23 +0200
commitc0c827d3ad2c8364d35fff5546ab40ea76bbbbd9 (patch)
tree34bb14bb6046ce98bd6ad759b9c57624b2be7d34 /vendor/league/html-to-markdown/src
parent6a2bbed73dfb34975c4525c34c03f20c6945dedc (diff)
downloadvolse-hubzilla-c0c827d3ad2c8364d35fff5546ab40ea76bbbbd9.tar.gz
volse-hubzilla-c0c827d3ad2c8364d35fff5546ab40ea76bbbbd9.tar.bz2
volse-hubzilla-c0c827d3ad2c8364d35fff5546ab40ea76bbbbd9.zip
update composer libs and add ramsey/uuid
Diffstat (limited to 'vendor/league/html-to-markdown/src')
-rw-r--r--vendor/league/html-to-markdown/src/Converter/CodeConverter.php2
-rw-r--r--vendor/league/html-to-markdown/src/Converter/HardBreakConverter.php14
-rw-r--r--vendor/league/html-to-markdown/src/Converter/LinkConverter.php2
-rw-r--r--vendor/league/html-to-markdown/src/Converter/ListItemConverter.php16
-rw-r--r--vendor/league/html-to-markdown/src/Converter/PreformattedConverter.php2
-rw-r--r--vendor/league/html-to-markdown/src/HtmlConverter.php19
6 files changed, 50 insertions, 5 deletions
diff --git a/vendor/league/html-to-markdown/src/Converter/CodeConverter.php b/vendor/league/html-to-markdown/src/Converter/CodeConverter.php
index c8ec2c005..e536362ee 100644
--- a/vendor/league/html-to-markdown/src/Converter/CodeConverter.php
+++ b/vendor/league/html-to-markdown/src/Converter/CodeConverter.php
@@ -43,7 +43,7 @@ class CodeConverter implements ConverterInterface
$lines = preg_split('/\r\n|\r|\n/', $code);
if (count($lines) > 1) {
// Multiple lines detected, adding three backticks and newlines
- $markdown .= '```' . $language . "\n" . $code . "\n" . '```';
+ $markdown .= '```' . $language . "\n" . $code . "\n" . '```' . "\n\n";
} else {
// One line of code, wrapping it on one backtick.
$markdown .= '`' . $language . $code . '`';
diff --git a/vendor/league/html-to-markdown/src/Converter/HardBreakConverter.php b/vendor/league/html-to-markdown/src/Converter/HardBreakConverter.php
index 37cd44e73..d079d9127 100644
--- a/vendor/league/html-to-markdown/src/Converter/HardBreakConverter.php
+++ b/vendor/league/html-to-markdown/src/Converter/HardBreakConverter.php
@@ -28,7 +28,19 @@ class HardBreakConverter implements ConverterInterface, ConfigurationAwareInterf
*/
public function convert(ElementInterface $element)
{
- return $this->config->getOption('hard_break') ? "\n" : " \n";
+ $return = $this->config->getOption('hard_break') ? "\n" : " \n";
+
+ $next = $element->getNext();
+ if ($next) {
+ $next_value = $next->getValue();
+ if ($next_value) {
+ if (in_array(substr($next_value, 0, 2), array('- ', '* ', '+ '))) {
+ $return .= '\\';
+ }
+ }
+ }
+
+ return $return;
}
/**
diff --git a/vendor/league/html-to-markdown/src/Converter/LinkConverter.php b/vendor/league/html-to-markdown/src/Converter/LinkConverter.php
index f0765f38b..74b49a778 100644
--- a/vendor/league/html-to-markdown/src/Converter/LinkConverter.php
+++ b/vendor/league/html-to-markdown/src/Converter/LinkConverter.php
@@ -15,7 +15,7 @@ class LinkConverter implements ConverterInterface
{
$href = $element->getAttribute('href');
$title = $element->getAttribute('title');
- $text = trim($element->getValue());
+ $text = trim($element->getValue(), "\t\n\r\0\x0B");
if ($title !== '') {
$markdown = '[' . $text . '](' . $href . ' "' . $title . '")';
diff --git a/vendor/league/html-to-markdown/src/Converter/ListItemConverter.php b/vendor/league/html-to-markdown/src/Converter/ListItemConverter.php
index f737b4e19..c56ab89cd 100644
--- a/vendor/league/html-to-markdown/src/Converter/ListItemConverter.php
+++ b/vendor/league/html-to-markdown/src/Converter/ListItemConverter.php
@@ -14,6 +14,11 @@ class ListItemConverter implements ConverterInterface, ConfigurationAwareInterfa
protected $config;
/**
+ * @var string
+ */
+ protected $listItemStyle;
+
+ /**
* @param Configuration $config
*/
public function setConfig(Configuration $config)
@@ -45,7 +50,16 @@ class ListItemConverter implements ConverterInterface, ConfigurationAwareInterfa
if ($list_type === 'ul') {
$list_item_style = $this->config->getOption('list_item_style', '-');
- return $prefix . $list_item_style . ' ' . $value . "\n";
+ $list_item_style_alternate = $this->config->getOption('list_item_style_alternate');
+ if (!isset($this->listItemStyle)) {
+ $this->listItemStyle = $list_item_style_alternate ? $list_item_style_alternate : $list_item_style;
+ }
+
+ if ($list_item_style_alternate && $level == 0 && $element->getSiblingPosition() === 1) {
+ $this->listItemStyle = $this->listItemStyle == $list_item_style ? $list_item_style_alternate : $list_item_style;
+ }
+
+ return $prefix . $this->listItemStyle . ' ' . $value . "\n";
}
if ($list_type === 'ol' && $start = $element->getParent()->getAttribute('start')) {
diff --git a/vendor/league/html-to-markdown/src/Converter/PreformattedConverter.php b/vendor/league/html-to-markdown/src/Converter/PreformattedConverter.php
index 0bb89e90f..3b77ba10b 100644
--- a/vendor/league/html-to-markdown/src/Converter/PreformattedConverter.php
+++ b/vendor/league/html-to-markdown/src/Converter/PreformattedConverter.php
@@ -53,7 +53,7 @@ class PreformattedConverter implements ConverterInterface
}
// Use three backticks
- return "```\n" . $pre_content . "```\n";
+ return "```\n" . $pre_content . "```\n\n";
}
/**
diff --git a/vendor/league/html-to-markdown/src/HtmlConverter.php b/vendor/league/html-to-markdown/src/HtmlConverter.php
index 8d8936ec5..155369f56 100644
--- a/vendor/league/html-to-markdown/src/HtmlConverter.php
+++ b/vendor/league/html-to-markdown/src/HtmlConverter.php
@@ -229,4 +229,23 @@ class HtmlConverter
return trim($markdown, "\n\r\0\x0B");
}
+
+ /**
+ * Pass a series of key-value pairs in an array; these will be passed
+ * through the config and set.
+ * The advantage of this is that it can allow for static use (IE in Laravel).
+ * An example being:
+ *
+ * HtmlConverter::setOptions(['strip_tags' => true])->convert('<h1>test</h1>');
+ */
+ public function setOptions(array $options)
+ {
+ $config = $this->getConfig();
+
+ foreach ($options as $key => $option) {
+ $config->setOption($key, $option);
+ }
+
+ return $this;
+ }
}