update composr libs

(cherry picked from commit 2df15f35d706d4608ff723ce6288391ca774f7ba)
This commit is contained in:
Mario 2019-11-08 09:46:23 +00:00
parent 9360148829
commit bcd0802ea4
28 changed files with 159 additions and 71 deletions

36
composer.lock generated
View File

@ -204,16 +204,16 @@
}, },
{ {
"name": "ezyang/htmlpurifier", "name": "ezyang/htmlpurifier",
"version": "v4.11.0", "version": "v4.12.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/ezyang/htmlpurifier.git", "url": "https://github.com/ezyang/htmlpurifier.git",
"reference": "83ab08bc1af7d808a9e0fbf024f1c24bfd73c0a7" "reference": "a617e55bc62a87eec73bd456d146d134ad716f03"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/83ab08bc1af7d808a9e0fbf024f1c24bfd73c0a7", "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/a617e55bc62a87eec73bd456d146d134ad716f03",
"reference": "83ab08bc1af7d808a9e0fbf024f1c24bfd73c0a7", "reference": "a617e55bc62a87eec73bd456d146d134ad716f03",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -247,20 +247,20 @@
"keywords": [ "keywords": [
"html" "html"
], ],
"time": "2019-07-14T18:58:38+00:00" "time": "2019-10-28T03:44:26+00:00"
}, },
{ {
"name": "league/html-to-markdown", "name": "league/html-to-markdown",
"version": "4.8.2", "version": "4.9.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/html-to-markdown.git", "url": "https://github.com/thephpleague/html-to-markdown.git",
"reference": "e747489191f8e9144a7270eb61f8b9516e99e413" "reference": "71319108e3db506250b8987721b13568fd9fa446"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/e747489191f8e9144a7270eb61f8b9516e99e413", "url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/71319108e3db506250b8987721b13568fd9fa446",
"reference": "e747489191f8e9144a7270eb61f8b9516e99e413", "reference": "71319108e3db506250b8987721b13568fd9fa446",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -270,7 +270,7 @@
}, },
"require-dev": { "require-dev": {
"mikehaertl/php-shellcommand": "~1.1.0", "mikehaertl/php-shellcommand": "~1.1.0",
"phpunit/phpunit": "4.*", "phpunit/phpunit": "^4.8|^5.7",
"scrutinizer/ocular": "~1.1" "scrutinizer/ocular": "~1.1"
}, },
"bin": [ "bin": [
@ -279,7 +279,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "4.9-dev" "dev-master": "4.10-dev"
} }
}, },
"autoload": { "autoload": {
@ -311,7 +311,7 @@
"html", "html",
"markdown" "markdown"
], ],
"time": "2019-08-02T11:57:39+00:00" "time": "2019-11-02T14:54:14+00:00"
}, },
{ {
"name": "lukasreschke/id3parser", "name": "lukasreschke/id3parser",
@ -485,16 +485,16 @@
}, },
{ {
"name": "psr/log", "name": "psr/log",
"version": "1.1.0", "version": "1.1.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/log.git", "url": "https://github.com/php-fig/log.git",
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801",
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -503,7 +503,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.0.x-dev" "dev-master": "1.1.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -528,7 +528,7 @@
"psr", "psr",
"psr-3" "psr-3"
], ],
"time": "2018-11-20T15:27:04+00:00" "time": "2019-11-01T11:05:21+00:00"
}, },
{ {
"name": "ramsey/uuid", "name": "ramsey/uuid",

View File

@ -380,6 +380,9 @@ return array(
'Psr\\Log\\LoggerInterface' => $vendorDir . '/psr/log/Psr/Log/LoggerInterface.php', 'Psr\\Log\\LoggerInterface' => $vendorDir . '/psr/log/Psr/Log/LoggerInterface.php',
'Psr\\Log\\LoggerTrait' => $vendorDir . '/psr/log/Psr/Log/LoggerTrait.php', 'Psr\\Log\\LoggerTrait' => $vendorDir . '/psr/log/Psr/Log/LoggerTrait.php',
'Psr\\Log\\NullLogger' => $vendorDir . '/psr/log/Psr/Log/NullLogger.php', 'Psr\\Log\\NullLogger' => $vendorDir . '/psr/log/Psr/Log/NullLogger.php',
'Psr\\Log\\Test\\DummyTest' => $vendorDir . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php',
'Psr\\Log\\Test\\LoggerInterfaceTest' => $vendorDir . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php',
'Psr\\Log\\Test\\TestLogger' => $vendorDir . '/psr/log/Psr/Log/Test/TestLogger.php',
'Ramsey\\Uuid\\BinaryUtils' => $vendorDir . '/ramsey/uuid/src/BinaryUtils.php', 'Ramsey\\Uuid\\BinaryUtils' => $vendorDir . '/ramsey/uuid/src/BinaryUtils.php',
'Ramsey\\Uuid\\Builder\\DefaultUuidBuilder' => $vendorDir . '/ramsey/uuid/src/Builder/DefaultUuidBuilder.php', 'Ramsey\\Uuid\\Builder\\DefaultUuidBuilder' => $vendorDir . '/ramsey/uuid/src/Builder/DefaultUuidBuilder.php',
'Ramsey\\Uuid\\Builder\\DegradedUuidBuilder' => $vendorDir . '/ramsey/uuid/src/Builder/DegradedUuidBuilder.php', 'Ramsey\\Uuid\\Builder\\DegradedUuidBuilder' => $vendorDir . '/ramsey/uuid/src/Builder/DegradedUuidBuilder.php',

View File

@ -548,6 +548,9 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Psr\\Log\\LoggerInterface' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerInterface.php', 'Psr\\Log\\LoggerInterface' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerInterface.php',
'Psr\\Log\\LoggerTrait' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerTrait.php', 'Psr\\Log\\LoggerTrait' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerTrait.php',
'Psr\\Log\\NullLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/NullLogger.php', 'Psr\\Log\\NullLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/NullLogger.php',
'Psr\\Log\\Test\\DummyTest' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php',
'Psr\\Log\\Test\\LoggerInterfaceTest' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php',
'Psr\\Log\\Test\\TestLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/TestLogger.php',
'Ramsey\\Uuid\\BinaryUtils' => __DIR__ . '/..' . '/ramsey/uuid/src/BinaryUtils.php', 'Ramsey\\Uuid\\BinaryUtils' => __DIR__ . '/..' . '/ramsey/uuid/src/BinaryUtils.php',
'Ramsey\\Uuid\\Builder\\DefaultUuidBuilder' => __DIR__ . '/..' . '/ramsey/uuid/src/Builder/DefaultUuidBuilder.php', 'Ramsey\\Uuid\\Builder\\DefaultUuidBuilder' => __DIR__ . '/..' . '/ramsey/uuid/src/Builder/DefaultUuidBuilder.php',
'Ramsey\\Uuid\\Builder\\DegradedUuidBuilder' => __DIR__ . '/..' . '/ramsey/uuid/src/Builder/DegradedUuidBuilder.php', 'Ramsey\\Uuid\\Builder\\DegradedUuidBuilder' => __DIR__ . '/..' . '/ramsey/uuid/src/Builder/DegradedUuidBuilder.php',

View File

@ -205,17 +205,17 @@
}, },
{ {
"name": "ezyang/htmlpurifier", "name": "ezyang/htmlpurifier",
"version": "v4.11.0", "version": "v4.12.0",
"version_normalized": "4.11.0.0", "version_normalized": "4.12.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/ezyang/htmlpurifier.git", "url": "https://github.com/ezyang/htmlpurifier.git",
"reference": "83ab08bc1af7d808a9e0fbf024f1c24bfd73c0a7" "reference": "a617e55bc62a87eec73bd456d146d134ad716f03"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/83ab08bc1af7d808a9e0fbf024f1c24bfd73c0a7", "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/a617e55bc62a87eec73bd456d146d134ad716f03",
"reference": "83ab08bc1af7d808a9e0fbf024f1c24bfd73c0a7", "reference": "a617e55bc62a87eec73bd456d146d134ad716f03",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -224,7 +224,7 @@
"require-dev": { "require-dev": {
"simpletest/simpletest": "dev-master#72de02a7b80c6bb8864ef9bf66d41d2f58f826bd" "simpletest/simpletest": "dev-master#72de02a7b80c6bb8864ef9bf66d41d2f58f826bd"
}, },
"time": "2019-07-14T18:58:38+00:00", "time": "2019-10-28T03:44:26+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {
@ -254,17 +254,17 @@
}, },
{ {
"name": "league/html-to-markdown", "name": "league/html-to-markdown",
"version": "4.8.2", "version": "4.9.0",
"version_normalized": "4.8.2.0", "version_normalized": "4.9.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/html-to-markdown.git", "url": "https://github.com/thephpleague/html-to-markdown.git",
"reference": "e747489191f8e9144a7270eb61f8b9516e99e413" "reference": "71319108e3db506250b8987721b13568fd9fa446"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/e747489191f8e9144a7270eb61f8b9516e99e413", "url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/71319108e3db506250b8987721b13568fd9fa446",
"reference": "e747489191f8e9144a7270eb61f8b9516e99e413", "reference": "71319108e3db506250b8987721b13568fd9fa446",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -274,17 +274,17 @@
}, },
"require-dev": { "require-dev": {
"mikehaertl/php-shellcommand": "~1.1.0", "mikehaertl/php-shellcommand": "~1.1.0",
"phpunit/phpunit": "4.*", "phpunit/phpunit": "^4.8|^5.7",
"scrutinizer/ocular": "~1.1" "scrutinizer/ocular": "~1.1"
}, },
"time": "2019-08-02T11:57:39+00:00", "time": "2019-11-02T14:54:14+00:00",
"bin": [ "bin": [
"bin/html-to-markdown" "bin/html-to-markdown"
], ],
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "4.9-dev" "dev-master": "4.10-dev"
} }
}, },
"installation-source": "dist", "installation-source": "dist",
@ -498,27 +498,27 @@
}, },
{ {
"name": "psr/log", "name": "psr/log",
"version": "1.1.0", "version": "1.1.2",
"version_normalized": "1.1.0.0", "version_normalized": "1.1.2.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/log.git", "url": "https://github.com/php-fig/log.git",
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801",
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.0" "php": ">=5.3.0"
}, },
"time": "2018-11-20T15:27:04+00:00", "time": "2019-11-01T11:05:21+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.0.x-dev" "dev-master": "1.1.x-dev"
} }
}, },
"installation-source": "dist", "installation-source": "dist",

View File

@ -9,6 +9,12 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
. Internal change . Internal change
========================== ==========================
4.12.0, released 2019-10-27
! PHP 7.4 is supported, thank you Witold Wasiczko, Mateuz Turcza and
Edi Modrić
- PHPDocs for HTMLModule::addElement() and Bool attr are fixed (thanks
Mateusz)
4.11.0, released 2019-07-14 4.11.0, released 2019-07-14
# SafeScripting now matches case-sensitively against its whitelist (previously it was # SafeScripting now matches case-sensitively against its whitelist (previously it was
case-insensitive.) Thanks Dimitri Gritsajuk <gritsajuk.dimitri@gmail.com> case-insensitive.) Thanks Dimitri Gritsajuk <gritsajuk.dimitri@gmail.com>

View File

@ -1 +1 @@
4.11.0 4.12.0

View File

@ -1,7 +1,2 @@
HTML Purifier 4.11.x is a maintenance release, collecting a year HTML Purifier 4.12.x is a maintenance release which makes
and a half of accumulated bug fixes. Most notable fixes are compatibility fixes for PHP 7.4.
compatibility with PHP 7.3, and case-sensitive matching for
the SafeScripting whitelist. There are a number small feature
enhancements, including an expanded supported color list,
initial and inherit support for {min-,max-,}{width,height}
and multidimensional array support for purifyArray.

View File

@ -7,7 +7,7 @@
* primary concern and you are using an opcode cache. PLEASE DO NOT EDIT THIS * primary concern and you are using an opcode cache. PLEASE DO NOT EDIT THIS
* FILE, changes will be overwritten the next time the script is run. * FILE, changes will be overwritten the next time the script is run.
* *
* @version 4.11.0 * @version 4.12.0
* *
* @warning * @warning
* You must *not* include any other HTML Purifier files before this file, * You must *not* include any other HTML Purifier files before this file,

View File

@ -19,7 +19,7 @@
*/ */
/* /*
HTML Purifier 4.11.0 - Standards Compliant HTML Filtering HTML Purifier 4.12.0 - Standards Compliant HTML Filtering
Copyright (C) 2006-2008 Edward Z. Yang Copyright (C) 2006-2008 Edward Z. Yang
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
@ -58,12 +58,12 @@ class HTMLPurifier
* Version of HTML Purifier. * Version of HTML Purifier.
* @type string * @type string
*/ */
public $version = '4.11.0'; public $version = '4.12.0';
/** /**
* Constant with version of HTML Purifier. * Constant with version of HTML Purifier.
*/ */
const VERSION = '4.11.0'; const VERSION = '4.12.0';
/** /**
* Global configuration object. * Global configuration object.

View File

@ -7,7 +7,7 @@ class HTMLPurifier_AttrDef_HTML_Bool extends HTMLPurifier_AttrDef
{ {
/** /**
* @type bool * @type string
*/ */
protected $name; protected $name;
@ -17,7 +17,7 @@ class HTMLPurifier_AttrDef_HTML_Bool extends HTMLPurifier_AttrDef
public $minimized = true; public $minimized = true;
/** /**
* @param bool $name * @param bool|string $name
*/ */
public function __construct($name = false) public function __construct($name = false)
{ {

View File

@ -45,7 +45,7 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef
protected function _compileRegex() protected function _compileRegex()
{ {
$raw = str_replace(' ', '', $this->dtd_regex); $raw = str_replace(' ', '', $this->dtd_regex);
if ($raw{0} != '(') { if ($raw[0] != '(') {
$raw = "($raw)"; $raw = "($raw)";
} }
$el = '[#a-zA-Z0-9_.-]+'; $el = '[#a-zA-Z0-9_.-]+';

View File

@ -21,7 +21,7 @@ class HTMLPurifier_Config
* HTML Purifier's version * HTML Purifier's version
* @type string * @type string
*/ */
public $version = '4.11.0'; public $version = '4.12.0';
/** /**
* Whether or not to automatically finalize * Whether or not to automatically finalize

View File

@ -159,7 +159,7 @@ class HTMLPurifier_Encoder
$len = strlen($str); $len = strlen($str);
for ($i = 0; $i < $len; $i++) { for ($i = 0; $i < $len; $i++) {
$in = ord($str{$i}); $in = ord($str[$i]);
$char .= $str[$i]; // append byte to char $char .= $str[$i]; // append byte to char
if (0 == $mState) { if (0 == $mState) {
// When mState is zero we expect either a US-ASCII character // When mState is zero we expect either a US-ASCII character

View File

@ -132,9 +132,9 @@ class HTMLPurifier_HTMLModule
* @param string $element Name of element to add * @param string $element Name of element to add
* @param string|bool $type What content set should element be registered to? * @param string|bool $type What content set should element be registered to?
* Set as false to skip this step. * Set as false to skip this step.
* @param string $contents Allowed children in form of: * @param string|HTMLPurifier_ChildDef $contents Allowed children in form of:
* "$content_model_type: $content_model" * "$content_model_type: $content_model"
* @param array $attr_includes What attribute collections to register to * @param array|string $attr_includes What attribute collections to register to
* element? * element?
* @param array $attr What unique attributes does the element define? * @param array $attr What unique attributes does the element define?
* @see HTMLPurifier_ElementDef:: for in-depth descriptions of these parameters. * @see HTMLPurifier_ElementDef:: for in-depth descriptions of these parameters.

View File

@ -74,7 +74,12 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
} }
set_error_handler(array($this, 'muteErrorHandler')); set_error_handler(array($this, 'muteErrorHandler'));
// loadHTML() fails on PHP 5.3 when second parameter is given
if ($options) {
$doc->loadHTML($html, $options); $doc->loadHTML($html, $options);
} else {
$doc->loadHTML($html);
}
restore_error_handler(); restore_error_handler();
$body = $doc->getElementsByTagName('html')->item(0)-> // <html> $body = $doc->getElementsByTagName('html')->item(0)-> // <html>

View File

@ -75,7 +75,7 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform
if (isset($attr['size'])) { if (isset($attr['size'])) {
// normalize large numbers // normalize large numbers
if ($attr['size'] !== '') { if ($attr['size'] !== '') {
if ($attr['size']{0} == '+' || $attr['size']{0} == '-') { if ($attr['size'][0] == '+' || $attr['size'][0] == '-') {
$size = (int)$attr['size']; $size = (int)$attr['size'];
if ($size < -2) { if ($size < -2) {
$attr['size'] = '-2'; $attr['size'] = '-2';

View File

@ -1 +1,2 @@
github: colinodell
patreon: colinodell patreon: colinodell

View File

@ -4,6 +4,14 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
## [Unreleased][unreleased] ## [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 ## [4.8.2] - 2019-08-02
### Fixed ### Fixed
- Fixed headers not being placed onto a new line in some cases (#172) - Fixed headers not being placed onto a new line in some cases (#172)
@ -251,7 +259,9 @@ not ideally set, so this releases fixes that. Moving forwards this should reduce
### Added ### Added
- Initial release - Initial release
[unreleased]: https://github.com/thephpleague/html-to-markdown/compare/4.8.2...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.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.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.8.0]: https://github.com/thephpleague/html-to-markdown/compare/4.7.0...4.8.0

View File

@ -95,6 +95,24 @@ $html = '<span>Turnips!</span><div>Monkeys!</div>';
$markdown = $converter->convert($html); // $markdown now contains "" $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 ### 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. 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.
@ -193,4 +211,3 @@ Use one of these great libraries:
- [Parsedown](https://github.com/erusev/parsedown) - [Parsedown](https://github.com/erusev/parsedown)
No guarantees about the Elvish, though. No guarantees about the Elvish, though.

View File

@ -36,13 +36,13 @@
}, },
"require-dev": { "require-dev": {
"mikehaertl/php-shellcommand": "~1.1.0", "mikehaertl/php-shellcommand": "~1.1.0",
"phpunit/phpunit": "4.*", "phpunit/phpunit": "^4.8|^5.7",
"scrutinizer/ocular": "~1.1" "scrutinizer/ocular": "~1.1"
}, },
"bin": ["bin/html-to-markdown"], "bin": ["bin/html-to-markdown"],
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "4.9-dev" "dev-master": "4.10-dev"
} }
} }
} }

View File

@ -2,10 +2,25 @@
namespace League\HTMLToMarkdown\Converter; namespace League\HTMLToMarkdown\Converter;
use League\HTMLToMarkdown\Configuration;
use League\HTMLToMarkdown\ConfigurationAwareInterface;
use League\HTMLToMarkdown\ElementInterface; 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 * @param ElementInterface $element
* *
@ -13,6 +28,9 @@ class CommentConverter implements ConverterInterface
*/ */
public function convert(ElementInterface $element) public function convert(ElementInterface $element)
{ {
if ($this->shouldPreserve($element)) {
return '<!--' . $element->getValue() . '-->';
}
return ''; return '';
} }
@ -23,4 +41,22 @@ class CommentConverter implements ConverterInterface
{ {
return array('#comment'); 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;
}
} }

View File

@ -27,7 +27,6 @@ class Element implements ElementInterface
switch ($this->getTagName()) { switch ($this->getTagName()) {
case 'blockquote': case 'blockquote':
case 'body': case 'body':
case 'code':
case 'div': case 'div':
case 'h1': case 'h1':
case 'h2': case 'h2':

View File

@ -40,6 +40,7 @@ class HtmlConverter implements HtmlConverterInterface
'remove_nodes' => '', // space-separated list of dom nodes that should be removed. example: 'meta style script' '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` '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 '+' '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); $this->environment = Environment::createDefaultEnvironment($defaults);

View File

@ -118,6 +118,8 @@ interface LoggerInterface
* @param array $context * @param array $context
* *
* @return void * @return void
*
* @throws \Psr\Log\InvalidArgumentException
*/ */
public function log($level, $message, array $context = array()); public function log($level, $message, array $context = array());
} }

View File

@ -135,6 +135,8 @@ trait LoggerTrait
* @param array $context * @param array $context
* *
* @return void * @return void
*
* @throws \Psr\Log\InvalidArgumentException
*/ */
abstract public function log($level, $message, array $context = array()); abstract public function log($level, $message, array $context = array());
} }

View File

@ -20,6 +20,8 @@ class NullLogger extends AbstractLogger
* @param array $context * @param array $context
* *
* @return void * @return void
*
* @throws \Psr\Log\InvalidArgumentException
*/ */
public function log($level, $message, array $context = array()) public function log($level, $message, array $context = array())
{ {

View File

@ -39,6 +39,12 @@ class Foo
$this->logger->info('Doing work'); $this->logger->info('Doing work');
} }
try {
$this->doSomethingElse();
} catch (Exception $exception) {
$this->logger->error('Oh no!', array('exception' => $exception));
}
// do something useful // do something useful
} }
} }

View File

@ -20,7 +20,7 @@
}, },
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.0.x-dev" "dev-master": "1.1.x-dev"
} }
} }
} }