update composer libs and add ramsey/uuid

This commit is contained in:
Mario Vavti
2018-08-28 12:00:23 +02:00
parent 6a2bbed73d
commit c0c827d3ad
96 changed files with 6279 additions and 1244 deletions

View File

@@ -4,6 +4,16 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
## [Unreleased][unreleased]
## [4.7.0] - 2018-05-19
### Added
- Added `setOptions()` function for chainable calling (#149)
- Added new `list_item_style_alternate` option for converting every-other list with a different character (#155)
### Fixed
- Fixed insufficient newlines after code blocks (#144, #148)
- Fixed trailing spaces not being preserved in link anchors (#157)
- Fixed list-like lines not being escaped inside of lists items (#159)
## [4.6.2]
### Fixed
- Fixed issue with emphasized spaces (#146)
@@ -207,7 +217,8 @@ 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.6.2...master
[unreleased]: https://github.com/thephpleague/html-to-markdown/compare/4.7.0...master
[4.7.0]: https://github.com/thephpleague/html-to-markdown/compare/4.6.2...4.7.0
[4.6.2]: https://github.com/thephpleague/html-to-markdown/compare/4.6.1...4.6.2
[4.6.1]: https://github.com/thephpleague/html-to-markdown/compare/4.6.0...4.6.1
[4.6.0]: https://github.com/thephpleague/html-to-markdown/compare/4.5.0...4.6.0

View File

@@ -42,7 +42,7 @@
"bin": ["bin/html-to-markdown"],
"extra": {
"branch-alias": {
"dev-master": "4.7-dev"
"dev-master": "4.8-dev"
}
}
}

View File

@@ -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 . '`';

View File

@@ -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;
}
/**

View File

@@ -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 . '")';

View File

@@ -13,6 +13,11 @@ class ListItemConverter implements ConverterInterface, ConfigurationAwareInterfa
*/
protected $config;
/**
* @var string
*/
protected $listItemStyle;
/**
* @param 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')) {

View File

@@ -53,7 +53,7 @@ class PreformattedConverter implements ConverterInterface
}
// Use three backticks
return "```\n" . $pre_content . "```\n";
return "```\n" . $pre_content . "```\n\n";
}
/**

View File

@@ -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;
}
}