diff options
author | Mario <mario@mariovavti.com> | 2019-12-04 10:25:11 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-12-04 10:25:11 +0000 |
commit | bde429cff649237984903a252ba1a718e6d74f53 (patch) | |
tree | b2b2570159cfb37689e6ce3b96c3b1b988d676cc /vendor/league | |
parent | cc9f41df5f83bcab435d6fb941b5a8f5b1457037 (diff) | |
parent | 4c8d33d1eb2a804aa70a7bc677d6c73d0d94816b (diff) | |
download | volse-hubzilla-4.6.tar.gz volse-hubzilla-4.6.tar.bz2 volse-hubzilla-4.6.zip |
Merge branch '4.6RC'4.6
Diffstat (limited to 'vendor/league')
10 files changed, 106 insertions, 11 deletions
diff --git a/vendor/league/html-to-markdown/.github/FUNDING.yml b/vendor/league/html-to-markdown/.github/FUNDING.yml new file mode 100644 index 000000000..40a26fbff --- /dev/null +++ b/vendor/league/html-to-markdown/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: colinodell +patreon: colinodell diff --git a/vendor/league/html-to-markdown/.github/stale.yml b/vendor/league/html-to-markdown/.github/stale.yml new file mode 100644 index 000000000..bb7c5e94a --- /dev/null +++ b/vendor/league/html-to-markdown/.github/stale.yml @@ -0,0 +1,18 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 90 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 30 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - on hold + - security +# Label to use when marking an issue as stale +staleLabel: stale +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false diff --git a/vendor/league/html-to-markdown/CHANGELOG.md b/vendor/league/html-to-markdown/CHANGELOG.md index e1893be9a..ded540682 100644 --- a/vendor/league/html-to-markdown/CHANGELOG.md +++ b/vendor/league/html-to-markdown/CHANGELOG.md @@ -4,6 +4,22 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip ## [Unreleased][unreleased] +## [4.9.0] - 2019-11-02 +## Added + - Added new option to preserve comments (#177, #179) + +## [4.8.3] - 2019-10-31 +### Fixed + - Fixed whitespace preservation around `<code>` tags (#174, #178) + +## [4.8.2] - 2019-08-02 +### Fixed + - Fixed headers not being placed onto a new line in some cases (#172) + - Fixed handling of links containing spaces (#175) + +### Removed + - Removed support for HHVM + ## [4.8.1] - 2018-12-24 ### Added - Added support for PHP 7.3 @@ -243,7 +259,10 @@ not ideally set, so this releases fixes that. Moving forwards this should reduce ### Added - Initial release -[unreleased]: https://github.com/thephpleague/html-to-markdown/compare/4.8.1...master +[unreleased]: https://github.com/thephpleague/html-to-markdown/compare/4.9.0...master +[4.9.0]: https://github.com/thephpleague/html-to-markdown/compare/4.8.3...4.9.0 +[4.8.3]: https://github.com/thephpleague/html-to-markdown/compare/4.8.2...4.8.3 +[4.8.2]: https://github.com/thephpleague/html-to-markdown/compare/4.8.1...4.8.2 [4.8.1]: https://github.com/thephpleague/html-to-markdown/compare/4.8.0...4.8.1 [4.8.0]: https://github.com/thephpleague/html-to-markdown/compare/4.7.0...4.8.0 [4.7.0]: https://github.com/thephpleague/html-to-markdown/compare/4.6.2...4.7.0 diff --git a/vendor/league/html-to-markdown/README.md b/vendor/league/html-to-markdown/README.md index ab80541e6..c7ae2dcab 100644 --- a/vendor/league/html-to-markdown/README.md +++ b/vendor/league/html-to-markdown/README.md @@ -28,7 +28,7 @@ Typically you would convert HTML to Markdown if: 1. You have an existing HTML document that needs to be edited by people with good taste. 2. You want to store new content in HTML format but edit it as Markdown. -3. You want to convert HTML email to plain text email. +3. You want to convert HTML email to plain text email. 4. You know a guy who's been converting HTML to Markdown for years, and now he can speak Elvish. You'd quite like to be able to speak Elvish. 5. You just really like Markdown. @@ -95,6 +95,24 @@ $html = '<span>Turnips!</span><div>Monkeys!</div>'; $markdown = $converter->convert($html); // $markdown now contains "" ``` +By default, all comments are stripped from the content. To preserve them, use the `preserve_comments` option, like this: + +```php +$converter = new HtmlConverter(array('preserve_comments' => true)); + +$html = '<span>Turnips!</span><!-- Monkeys! -->'; +$markdown = $converter->convert($html); // $markdown now contains "Turnips!<!-- Monkeys! -->" +``` + +To preserve only specific comments, set `preserve_comments` with an array of strings, like this: + +```php +$converter = new HtmlConverter(array('preserve_comments' => array('Eggs!'))); + +$html = '<span>Turnips!</span><!-- Monkeys! --><!-- Eggs! -->'; +$markdown = $converter->convert($html); // $markdown now contains "Turnips!<!-- Eggs! -->" +``` + ### Style options By default bold tags are converted using the asterisk syntax, and italic tags are converted using the underlined syntax. Change these by using the `bold_style` and `italic_style` options. @@ -161,7 +179,7 @@ $markdown = $converter->convert($html); // $markdown now contains "### Header" a Headers of H3 priority and lower always use atx style. -- Links and images are referenced inline. Footnote references (where image src and anchor href attributes are listed in the footnotes) are not used. +- Links and images are referenced inline. Footnote references (where image src and anchor href attributes are listed in the footnotes) are not used. - Blockquotes aren't line wrapped – it makes the converted Markdown easier to edit. ### Dependencies @@ -193,4 +211,3 @@ Use one of these great libraries: - [Parsedown](https://github.com/erusev/parsedown) No guarantees about the Elvish, though. - diff --git a/vendor/league/html-to-markdown/composer.json b/vendor/league/html-to-markdown/composer.json index 53403916e..7990bcace 100644 --- a/vendor/league/html-to-markdown/composer.json +++ b/vendor/league/html-to-markdown/composer.json @@ -36,13 +36,13 @@ }, "require-dev": { "mikehaertl/php-shellcommand": "~1.1.0", - "phpunit/phpunit": "4.*", + "phpunit/phpunit": "^4.8|^5.7", "scrutinizer/ocular": "~1.1" }, "bin": ["bin/html-to-markdown"], "extra": { "branch-alias": { - "dev-master": "4.9-dev" + "dev-master": "4.10-dev" } } } 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; + } } diff --git a/vendor/league/html-to-markdown/src/Converter/HeaderConverter.php b/vendor/league/html-to-markdown/src/Converter/HeaderConverter.php index 05d4fe81e..353833263 100644 --- a/vendor/league/html-to-markdown/src/Converter/HeaderConverter.php +++ b/vendor/league/html-to-markdown/src/Converter/HeaderConverter.php @@ -35,7 +35,7 @@ class HeaderConverter implements ConverterInterface, ConfigurationAwareInterface $style = $this->config->getOption('header_style', self::STYLE_SETEXT); if (strlen($element->getValue()) === 0) { - return ''; + return "\n"; } if (($level === 1 || $level === 2) && !$element->isDescendantOf('blockquote') && $style === self::STYLE_SETEXT) { diff --git a/vendor/league/html-to-markdown/src/Converter/LinkConverter.php b/vendor/league/html-to-markdown/src/Converter/LinkConverter.php index c82b70e97..81c18b65f 100644 --- a/vendor/league/html-to-markdown/src/Converter/LinkConverter.php +++ b/vendor/league/html-to-markdown/src/Converter/LinkConverter.php @@ -24,6 +24,9 @@ class LinkConverter implements ConverterInterface } elseif ($href === 'mailto:' . $text && $this->isValidEmail($text)) { $markdown = '<' . $text . '>'; } else { + if (stristr($href, ' ')) { + $href = '<'.$href.'>'; + } $markdown = '[' . $text . '](' . $href . ')'; } diff --git a/vendor/league/html-to-markdown/src/Element.php b/vendor/league/html-to-markdown/src/Element.php index e1e9d1a09..80ae7a911 100644 --- a/vendor/league/html-to-markdown/src/Element.php +++ b/vendor/league/html-to-markdown/src/Element.php @@ -27,7 +27,6 @@ class Element implements ElementInterface switch ($this->getTagName()) { case 'blockquote': case 'body': - case 'code': case 'div': case 'h1': case 'h2': diff --git a/vendor/league/html-to-markdown/src/HtmlConverter.php b/vendor/league/html-to-markdown/src/HtmlConverter.php index 3381e1e1e..846131af6 100644 --- a/vendor/league/html-to-markdown/src/HtmlConverter.php +++ b/vendor/league/html-to-markdown/src/HtmlConverter.php @@ -40,6 +40,7 @@ class HtmlConverter implements HtmlConverterInterface 'remove_nodes' => '', // space-separated list of dom nodes that should be removed. example: 'meta style script' 'hard_break' => false, // Set to true to turn <br> into `\n` instead of ` \n` 'list_item_style' => '-', // Set the default character for each <li> in a <ul>. Can be '-', '*', or '+' + 'preserve_comments' => false, // Set to true to preserve comments, or set to an array of strings to preserve specific comments ); $this->environment = Environment::createDefaultEnvironment($defaults); @@ -229,13 +230,13 @@ class HtmlConverter implements HtmlConverterInterface 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) |