summaryrefslogtreecommitdiff
path: root/vendor
diff options
context:
space:
mode:
Diffstat (limited to 'vendor')
-rw-r--r--vendor/composer/installed.json242
-rw-r--r--vendor/league/commonmark/.styleci.yml4
-rw-r--r--vendor/league/commonmark/CHANGELOG.md150
-rw-r--r--vendor/league/commonmark/LICENSE4
-rw-r--r--vendor/league/commonmark/README.md23
-rw-r--r--vendor/league/commonmark/UPGRADE.md111
-rw-r--r--vendor/league/commonmark/composer.json16
-rw-r--r--vendor/league/commonmark/src/Block/Element/AbstractBlock.php4
-rw-r--r--vendor/league/commonmark/src/Block/Element/BlockQuote.php4
-rw-r--r--vendor/league/commonmark/src/Block/Element/FencedCode.php6
-rw-r--r--vendor/league/commonmark/src/Block/Element/Heading.php2
-rw-r--r--vendor/league/commonmark/src/Block/Element/IndentedCode.php2
-rw-r--r--vendor/league/commonmark/src/Block/Element/InlineContainer.php6
-rw-r--r--vendor/league/commonmark/src/Block/Element/InlineContainerInterface.php8
-rw-r--r--vendor/league/commonmark/src/Block/Element/ListItem.php2
-rw-r--r--vendor/league/commonmark/src/Block/Element/Paragraph.php4
-rw-r--r--vendor/league/commonmark/src/Block/Parser/ATXHeadingParser.php8
-rw-r--r--vendor/league/commonmark/src/Block/Parser/BlockQuoteParser.php4
-rw-r--r--vendor/league/commonmark/src/Block/Parser/FencedCodeParser.php8
-rw-r--r--vendor/league/commonmark/src/Block/Parser/HtmlBlockParser.php4
-rw-r--r--vendor/league/commonmark/src/Block/Parser/ListParser.php20
-rw-r--r--vendor/league/commonmark/src/Block/Parser/SetExtHeadingParser.php2
-rw-r--r--vendor/league/commonmark/src/Block/Parser/ThematicBreakParser.php2
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/BlockQuoteRenderer.php3
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/FencedCodeRenderer.php7
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/HeadingRenderer.php3
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/IndentedCodeRenderer.php5
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/ListBlockRenderer.php3
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/ListItemRenderer.php3
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/ParagraphRenderer.php13
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/ThematicBreakRenderer.php3
-rw-r--r--vendor/league/commonmark/src/Cursor.php189
-rw-r--r--vendor/league/commonmark/src/CursorState.php141
-rw-r--r--vendor/league/commonmark/src/Delimiter/Delimiter.php12
-rw-r--r--vendor/league/commonmark/src/Delimiter/DelimiterStack.php25
-rw-r--r--vendor/league/commonmark/src/DocParser.php42
-rw-r--r--vendor/league/commonmark/src/ElementRendererInterface.php8
-rw-r--r--vendor/league/commonmark/src/Environment.php7
-rw-r--r--vendor/league/commonmark/src/Extension/CommonMarkCoreExtension.php20
-rw-r--r--vendor/league/commonmark/src/Extension/MiscExtension.php4
-rw-r--r--vendor/league/commonmark/src/HtmlElement.php4
-rw-r--r--vendor/league/commonmark/src/HtmlRenderer.php17
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/BacktickParser.php3
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/CloseBracketParser.php10
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/EmphasisParser.php12
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/EntityParser.php2
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/EscapableParser.php2
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/HtmlInlineParser.php2
-rw-r--r--vendor/league/commonmark/src/Inline/Processor/EmphasisProcessor.php8
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/CodeRenderer.php5
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/EmphasisRenderer.php3
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/ImageRenderer.php7
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/LinkRenderer.php7
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/NewlineRenderer.php4
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/StrongRenderer.php3
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/TextRenderer.php3
-rw-r--r--vendor/league/commonmark/src/InlineParserEngine.php7
-rw-r--r--vendor/league/commonmark/src/Node/Node.php15
-rw-r--r--vendor/league/commonmark/src/Reference/Reference.php2
-rw-r--r--vendor/league/commonmark/src/Reference/ReferenceMap.php6
-rw-r--r--vendor/league/commonmark/src/ReferenceParser.php4
-rw-r--r--vendor/league/commonmark/src/Util/ArrayCollection.php8
-rw-r--r--vendor/league/commonmark/src/Util/Html5Entities.php6
-rw-r--r--vendor/league/commonmark/src/Util/LinkParserHelper.php51
-rw-r--r--vendor/league/commonmark/src/Util/RegexHelper.php236
-rw-r--r--vendor/league/commonmark/src/Util/UrlEncoder.php51
-rw-r--r--vendor/league/commonmark/src/Util/Xml.php38
-rw-r--r--vendor/webuni/commonmark-table-extension/CHANGELOG.md8
-rw-r--r--vendor/webuni/commonmark-table-extension/composer.json14
-rw-r--r--vendor/webuni/commonmark-table-extension/src/TableParser.php12
70 files changed, 1029 insertions, 645 deletions
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index d8cc4fe3dc..1448ac4bc9 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -1049,113 +1049,99 @@
]
},
{
- "name": "league/commonmark",
- "version": "0.15.3",
- "version_normalized": "0.15.3.0",
+ "name": "symfony/polyfill-php72",
+ "version": "v1.6.0",
+ "version_normalized": "1.6.0.0",
"source": {
"type": "git",
- "url": "https://github.com/thephpleague/commonmark.git",
- "reference": "c8b43ee5821362216f8e9ac684f0f59de164edcc"
+ "url": "https://github.com/symfony/polyfill-php72.git",
+ "reference": "6de4f4884b97abbbed9f0a84a95ff2ff77254254"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/c8b43ee5821362216f8e9ac684f0f59de164edcc",
- "reference": "c8b43ee5821362216f8e9ac684f0f59de164edcc",
+ "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/6de4f4884b97abbbed9f0a84a95ff2ff77254254",
+ "reference": "6de4f4884b97abbbed9f0a84a95ff2ff77254254",
"shasum": ""
},
"require": {
- "ext-mbstring": "*",
- "php": ">=5.4.8"
- },
- "replace": {
- "colinodell/commonmark-php": "*"
- },
- "require-dev": {
- "cebe/markdown": "~1.0",
- "erusev/parsedown": "~1.0",
- "jgm/commonmark": "0.27",
- "michelf/php-markdown": "~1.4",
- "mikehaertl/php-shellcommand": "~1.2.0",
- "phpunit/phpunit": "~4.3|~5.0",
- "scrutinizer/ocular": "~1.1",
- "symfony/finder": "~2.3|~3.0"
- },
- "suggest": {
- "league/commonmark-extras": "Library of useful extensions including smart punctuation"
+ "php": ">=5.3.3"
},
- "time": "2016-12-19T00:11:43+00:00",
- "bin": [
- "bin/commonmark"
- ],
+ "time": "2017-10-11T12:05:26+00:00",
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "0.16-dev"
+ "dev-master": "1.6-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
- "League\\CommonMark\\": "src/"
- }
+ "Symfony\\Polyfill\\Php72\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
- "BSD-3-Clause"
+ "MIT"
],
"authors": [
{
- "name": "Colin O'Dell",
- "email": "colinodell@gmail.com",
- "homepage": "https://www.colinodell.com",
- "role": "Lead Developer"
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
}
],
- "description": "Markdown parser for PHP based on the CommonMark spec",
- "homepage": "https://github.com/thephpleague/commonmark",
+ "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions",
+ "homepage": "https://symfony.com",
"keywords": [
- "commonmark",
- "markdown",
- "parser"
+ "compatibility",
+ "polyfill",
+ "portable",
+ "shim"
]
},
{
- "name": "webuni/commonmark-table-extension",
- "version": "0.6.1",
- "version_normalized": "0.6.1.0",
+ "name": "symfony/http-foundation",
+ "version": "v3.3.6",
+ "version_normalized": "3.3.6.0",
"source": {
"type": "git",
- "url": "https://github.com/webuni/commonmark-table-extension.git",
- "reference": "ebbd69b63436283ec726658835b213ec634485e8"
+ "url": "https://github.com/symfony/http-foundation.git",
+ "reference": "49e8cd2d59a7aa9bfab19e46de680c76e500a031"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/webuni/commonmark-table-extension/zipball/ebbd69b63436283ec726658835b213ec634485e8",
- "reference": "ebbd69b63436283ec726658835b213ec634485e8",
+ "url": "https://api.github.com/repos/symfony/http-foundation/zipball/49e8cd2d59a7aa9bfab19e46de680c76e500a031",
+ "reference": "49e8cd2d59a7aa9bfab19e46de680c76e500a031",
"shasum": ""
},
"require": {
- "league/commonmark": "^0.14|^0.15",
- "php": "^5.5|^7.0"
+ "php": ">=5.5.9",
+ "symfony/polyfill-mbstring": "~1.1"
},
"require-dev": {
- "friendsofphp/php-cs-fixer": "^1.9",
- "phpunit/phpunit": "^4.3|^5.0",
- "sllh/php-cs-fixer-styleci-bridge": "^2.0",
- "symfony/var-dumper": "^2.7|^3.0"
+ "symfony/expression-language": "~2.8|~3.0"
},
- "time": "2017-01-11T14:52:17+00:00",
+ "time": "2017-07-21T11:04:46+00:00",
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "0.7-dev"
+ "dev-master": "3.3-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
- "Webuni\\CommonMark\\TableExtension\\": "src"
- }
+ "Symfony\\Component\\HttpFoundation\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -1163,117 +1149,124 @@
],
"authors": [
{
- "name": "Martin Hasoň",
- "email": "martin.hason@gmail.com",
- "role": "Lead Developer"
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
},
{
- "name": "Webuni s.r.o.",
- "homepage": "https://www.webuni.cz"
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
}
],
- "description": "The table extension for CommonMark PHP implementation",
- "homepage": "https://github.com/webuni/commonmark-table-extension",
- "keywords": [
- "commonmark",
- "markdown",
- "table"
- ]
+ "description": "Symfony HttpFoundation Component",
+ "homepage": "https://symfony.com"
},
{
- "name": "symfony/polyfill-php72",
- "version": "v1.6.0",
- "version_normalized": "1.6.0.0",
+ "name": "league/commonmark",
+ "version": "0.17.0",
+ "version_normalized": "0.17.0.0",
"source": {
"type": "git",
- "url": "https://github.com/symfony/polyfill-php72.git",
- "reference": "6de4f4884b97abbbed9f0a84a95ff2ff77254254"
+ "url": "https://github.com/thephpleague/commonmark.git",
+ "reference": "3b4c2224524776a584de663c7a04bc8eb2e1544d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/6de4f4884b97abbbed9f0a84a95ff2ff77254254",
- "reference": "6de4f4884b97abbbed9f0a84a95ff2ff77254254",
+ "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/3b4c2224524776a584de663c7a04bc8eb2e1544d",
+ "reference": "3b4c2224524776a584de663c7a04bc8eb2e1544d",
"shasum": ""
},
"require": {
- "php": ">=5.3.3"
+ "ext-mbstring": "*",
+ "php": ">=5.6.5"
},
- "time": "2017-10-11T12:05:26+00:00",
+ "replace": {
+ "colinodell/commonmark-php": "*"
+ },
+ "require-dev": {
+ "cebe/markdown": "~1.0",
+ "commonmark/commonmark.js": "0.28",
+ "erusev/parsedown": "~1.0",
+ "michelf/php-markdown": "~1.4",
+ "mikehaertl/php-shellcommand": "~1.2.0",
+ "phpunit/phpunit": "~5.7|~6.5",
+ "scrutinizer/ocular": "~1.1",
+ "symfony/finder": "~3.0|~4.0"
+ },
+ "suggest": {
+ "league/commonmark-extras": "Library of useful extensions including smart punctuation"
+ },
+ "time": "2017-12-30T22:08:48+00:00",
+ "bin": [
+ "bin/commonmark"
+ ],
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.6-dev"
+ "dev-master": "0.18-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
- "Symfony\\Polyfill\\Php72\\": ""
- },
- "files": [
- "bootstrap.php"
- ]
+ "League\\CommonMark\\": "src/"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
- "MIT"
+ "BSD-3-Clause"
],
"authors": [
{
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
+ "name": "Colin O'Dell",
+ "email": "colinodell@gmail.com",
+ "homepage": "https://www.colinodell.com",
+ "role": "Lead Developer"
}
],
- "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions",
- "homepage": "https://symfony.com",
+ "description": "Markdown parser for PHP based on the CommonMark spec",
+ "homepage": "https://github.com/thephpleague/commonmark",
"keywords": [
- "compatibility",
- "polyfill",
- "portable",
- "shim"
+ "commonmark",
+ "markdown",
+ "parser"
]
},
{
- "name": "symfony/http-foundation",
- "version": "v3.3.6",
- "version_normalized": "3.3.6.0",
+ "name": "webuni/commonmark-table-extension",
+ "version": "0.7.0",
+ "version_normalized": "0.7.0.0",
"source": {
"type": "git",
- "url": "https://github.com/symfony/http-foundation.git",
- "reference": "49e8cd2d59a7aa9bfab19e46de680c76e500a031"
+ "url": "https://github.com/webuni/commonmark-table-extension.git",
+ "reference": "6326245c1e198cc839ef4f6dc070cf99cffb1a84"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/http-foundation/zipball/49e8cd2d59a7aa9bfab19e46de680c76e500a031",
- "reference": "49e8cd2d59a7aa9bfab19e46de680c76e500a031",
+ "url": "https://api.github.com/repos/webuni/commonmark-table-extension/zipball/6326245c1e198cc839ef4f6dc070cf99cffb1a84",
+ "reference": "6326245c1e198cc839ef4f6dc070cf99cffb1a84",
"shasum": ""
},
"require": {
- "php": ">=5.5.9",
- "symfony/polyfill-mbstring": "~1.1"
+ "league/commonmark": "^0.16|^0.17",
+ "php": "^5.6|^7.0"
},
"require-dev": {
- "symfony/expression-language": "~2.8|~3.0"
+ "friendsofphp/php-cs-fixer": "^2.9",
+ "phpunit/phpunit": "^5.4|^6.0",
+ "symfony/var-dumper": "^3.0|^4.0"
},
- "time": "2017-07-21T11:04:46+00:00",
+ "time": "2018-01-09T11:11:46+00:00",
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.3-dev"
+ "dev-master": "0.7-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
- "Symfony\\Component\\HttpFoundation\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
+ "Webuni\\CommonMark\\TableExtension\\": "src"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -1281,15 +1274,20 @@
],
"authors": [
{
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
+ "name": "Martin Hasoň",
+ "email": "martin.hason@gmail.com"
},
{
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
+ "name": "Webuni s.r.o.",
+ "homepage": "https://www.webuni.cz"
}
],
- "description": "Symfony HttpFoundation Component",
- "homepage": "https://symfony.com"
+ "description": "The table extension for CommonMark PHP implementation",
+ "homepage": "https://github.com/webuni/commonmark-table-extension",
+ "keywords": [
+ "commonmark",
+ "markdown",
+ "table"
+ ]
}
]
diff --git a/vendor/league/commonmark/.styleci.yml b/vendor/league/commonmark/.styleci.yml
index bc9a4c815b..af9054cd43 100644
--- a/vendor/league/commonmark/.styleci.yml
+++ b/vendor/league/commonmark/.styleci.yml
@@ -2,8 +2,12 @@ preset: recommended
enabled:
- concat_with_spaces
+ - no_useless_else
- strict
disabled:
- concat_without_spaces
+ - no_trailing_comma_in_list_call
- phpdoc_summary
+ - post_increment
+ - self_accessor
diff --git a/vendor/league/commonmark/CHANGELOG.md b/vendor/league/commonmark/CHANGELOG.md
index fef960ef14..8f5264d5de 100644
--- a/vendor/league/commonmark/CHANGELOG.md
+++ b/vendor/league/commonmark/CHANGELOG.md
@@ -4,6 +4,148 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
## [Unreleased][unreleased]
+## [0.17.0] - 2017-12-30
+
+This release contains several breaking changes and a minimum PHP version bump - see <UPGRADE.md> for more details.
+
+### Added
+
+ - Added new `max_nesting_level` setting (#243)
+ - Added minor performance optimizations to `Cursor`
+
+### Changed
+
+ - Minimum PHP version is now 5.6.5.
+ - All full and partial regular expressions in `RegexHelper` are now defined as constants instead of being built on-the-fly.
+ - `Cursor::saveState()` now returns an `array` instead of a `CursorState` object.
+ - `Cursor::restoreState()` now accepts an `array` parameter instead of a `CursorState` object.
+ - Saving/restoring the Cursor state no longer tracks things that don't change (like the text content).
+ - `RegexHelper` is now `final`.
+ - References to `InlineContainer` changed to new `InlineContainerInterface` interface.
+ - `MiscExtension::addInlineParser()` and `MiscExtension::addBlockRenderer()` now return `$this` instead of nothing.
+
+### Fixed
+ - Fixed `Reference::normalizeReference()` not properly collapsing whitespace to a single space
+
+### Deprecated
+
+ - `RegexHelper::getInstance()` and all instance (non-static) methods have been deprecated.
+ - The `InlineContainer` interface has been deprecated. Use `InlineContainerInterface` instead.
+
+### Removed
+
+ - Removed support for PHP 5.4 and 5.5.
+ - Removed `CursorState` class
+ - Removed all previous deprecations:
+ - `Cursor::getFirstNonSpacePosition()`
+ - `Cursor::getFirstNonSpaceCharacter()`
+ - `Cursor::advanceWhileMatches()`
+ - `Cursor::advanceToFirstNonSpace()`
+ - `ElementRendererInterface::escape()`
+ - `HtmlRenderer::escape()`
+ - `RegexHelper::REGEX_UNICODE_WHITESPACE`
+ - `RegexHelper::getLinkDestinationRegex()`
+
+## [0.16.0] - 2017-10-30
+
+This release contains breaking changes, several performance improvements, and two deprecations:
+
+### Added
+
+ - Added new `Xml` utility class; moved HTML/XML escaping logic into there (see deprecations below)
+
+### Changed
+
+ - `Environment::getInlineParsersForCharacter()` now returns an empty array (instead of `null`) when no matching parsers are found
+ - Three utility classes are now marked `final`:
+ - `Html5Entities`
+ - `LinkParserHelper`
+ - `UrlEncoder`
+
+### Fixed
+
+ - Improved performance of several methods (for a 10% overall performance boost - #292)
+
+### Deprecated
+
+The following methods were deprecated and are scheduled for removal in 0.17.0 or 1.0.0 (whichever comes first). See <UPGRADE.md> for more information.
+
+ - `Cursor::advanceWhileMatches()` deprecated; use `Cursor::match()` instead.
+ - `HtmlRenderer::escape()` deprecated; use `Xml::escape()` instead.
+
+### Removed
+
+ - Removed `DelimiterStack::findFirstMatchingOpener()` which was previously deprecated in 0.15.0
+
+## [0.15.7] - 2017-10-26
+
+### Fixed
+
+ - Improved performance of `Cursor::advanceBy()` (for a 16% performance boost)
+
+## [0.15.6] - 2017-08-08
+
+### Fixed
+
+ - Fixed URI normalization not properly encoding/decoding special characters in certain cases (#287)
+
+## [0.15.5] - 2017-08-05
+
+This release bumps spec compliance to 0.28 without breaking changes to the API.
+
+### Added
+
+ - Project is now tested against PHP 7.2
+
+### Changed
+
+ - Bumped CommonMark spec target to 0.28
+ - Changed internal implementation of `LinkParserHelper::parseLinkDestination()` to allow nested parens
+ - Changed precedence of strong/emph when both nestings are possible (rule 14)
+ - Allow tabs before and after ATX closing header
+
+### Fixed
+
+ - Fixed HTML type 6 block regex matching against `<pre>` (it shouldn't) and not matching `<iframe>` (it should)
+ - Fixed reference parser incorrectly handling escaped `]` characters
+ - Fixed "multiple of 3" delimiter run calculations
+
+### Deprecated
+
+An unused constant and static method were deprecated and will be removed in a future release. See <UPGRADE.md> for more information.
+
+ - Deprecated `RegexHelper::REGEX_UNICODE_WHITESPACE` (no longer used)
+ - Deprecated `RegexHelper::getLinkDestinationRegex()` (no longer used)
+
+## [0.15.4] - 2017-05-09
+
+### Added
+
+ - Added new methods to `Cursor` (#280):
+ - `advanceToNextNonSpaceOrNewline()` - Identical replacement for the (now-deprecated) `advanceToFirstNonSpace()` method
+ - `advanceToNextNonSpaceOrTab()` - Similar replacement for `advanceToFirstNonSpace()` but with proper tab handling
+ - `getNextNonSpaceCharacter()` - Identical replacement for the (now-deprecated) `getFirstNonSpaceCharacter()` method
+ - `getNextNonSpacePosition()` - Identical replacement for the (now-deprecated) `getFirstNonSpacePosition()` method
+ - Added new method to `CursorState` (#280):
+ - `getNextNonSpaceCache()` - Identical replacement for the (now-deprecated) `getFirstNonSpaceCache()` method
+
+### Fixed
+
+ - Fixed duplicate characters in non-intended lines containing tabs (#279)
+
+### Deprecated
+
+**All deprecations listed here will be removed in a future 0.x release.** See [UPGRADE.md](UPGRADE.md) for instructions on preparing your code for the eventual removal of these methods.
+
+ - Deprecated `Cursor::advanceToFirstNonSpace()` (#280)
+ - Use `advanceToNextNonSpaceOrTab()` or `advanceToNextNonSpaceOrNewline()` instead, depending on your requirements
+ - Deprecated `Cursor::getFirstNonSpaceCharacter()` (#280)
+ - Use `Cursor::getNextNonSpaceCharacter()` instead
+ - Deprecated `Cursor::getFirstNonSpacePosition()` (#280)
+ - Use `Cursor::getNextNonSpacePosition()` instead
+ - Deprecated `CursorState::getFirstNonSpaceCache()` (#280)
+ - Use `CursorState::getNextNonSpaceCache()` instead
+
## [0.15.3] - 2016-12-18
### Fixed
@@ -467,7 +609,13 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
### Added
- Initial commit (compatible with jgm/stmd:spec.txt @ 0275f34)
-[unreleased]: https://github.com/thephpleague/commonmark/compare/0.15.3...HEAD
+[unreleased]: https://github.com/thephpleague/commonmark/compare/0.17.0...HEAD
+[0.17.0]: https://github.com/thephpleague/commonmark/compare/0.16.0...0.17.0
+[0.16.0]: https://github.com/thephpleague/commonmark/compare/0.15.7...0.16.0
+[0.15.7]: https://github.com/thephpleague/commonmark/compare/0.15.6...0.15.7
+[0.15.6]: https://github.com/thephpleague/commonmark/compare/0.15.5...0.15.6
+[0.15.5]: https://github.com/thephpleague/commonmark/compare/0.15.4...0.15.5
+[0.15.4]: https://github.com/thephpleague/commonmark/compare/0.15.3...0.15.4
[0.15.3]: https://github.com/thephpleague/commonmark/compare/0.15.2...0.15.3
[0.15.2]: https://github.com/thephpleague/commonmark/compare/0.15.1...0.15.2
[0.15.1]: https://github.com/thephpleague/commonmark/compare/0.15.0...0.15.1
diff --git a/vendor/league/commonmark/LICENSE b/vendor/league/commonmark/LICENSE
index a5c2c0934b..163baf09be 100644
--- a/vendor/league/commonmark/LICENSE
+++ b/vendor/league/commonmark/LICENSE
@@ -1,6 +1,6 @@
-Copyright (c) 2014-2016, Colin O'Dell
+Copyright (c) 2014-2018, Colin O'Dell
-Based on commonmark.js: Copyright (c) 2014-2016, John MacFarlane
+Based on commonmark.js: Copyright (c) 2014-2018, John MacFarlane
All rights reserved.
diff --git a/vendor/league/commonmark/README.md b/vendor/league/commonmark/README.md
index d4c89fccd9..ed2a68c7cb 100644
--- a/vendor/league/commonmark/README.md
+++ b/vendor/league/commonmark/README.md
@@ -8,9 +8,10 @@
[![Build Status](https://img.shields.io/travis/thephpleague/commonmark/master.svg?style=flat-square)](https://travis-ci.org/thephpleague/commonmark)
[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/thephpleague/commonmark.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/commonmark/code-structure)
[![Quality Score](https://img.shields.io/scrutinizer/g/thephpleague/commonmark.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/commonmark)
+[![SensioLabs Insight](https://img.shields.io/sensiolabs/i/9bf971c0-458f-4a19-9898-127728dbd65d.svg?style=flat-square)](https://insight.sensiolabs.com/projects/9bf971c0-458f-4a19-9898-127728dbd65d)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/126/badge)](https://bestpractices.coreinfrastructure.org/projects/126)
-**league/commonmark** is a Markdown parser for PHP which supports the full [CommonMark] spec. It is based on the [CommonMark JS reference implementation][commonmark.js] by [John MacFarlane] \([@jgm]\).
+**league/commonmark** is a PHP-based Markdown parser created by [Colin O'Dell][@colinodell] which supports the full [CommonMark] spec. It is based on the [CommonMark JS reference implementation][commonmark.js] by [John MacFarlane] \([@jgm]\).
## Goals
@@ -114,6 +115,7 @@ Custom parsers/renderers can be bundled into extensions which extend CommonMark.
- [CommonMark Table Extension](https://github.com/webuni/commonmark-table-extension) - Adds the ability to create tables in CommonMark documents.
- [CommonMark Attributes Extension](https://github.com/webuni/commonmark-attributes-extension) - Adds a syntax to define attributes on the various HTML elements.
- [Alt Three Emoji](https://github.com/AltThree/Emoji) An emoji parser for CommonMark.
+ - [uafrica/commonmark-ext](https://github.com/uafrica/commonmark-ext) - Adds strikethrough support.
If you build your own, feel free to submit a PR to add it to this list!
@@ -136,8 +138,12 @@ The following table shows which versions of league/commonmark are compatible wit
</thead>
<tbody>
<tr>
- <td><strong>0.15.3</strong><br>0.15.2</td>
- <td><strong><a href="http://spec.commonmark.org/0.27/">0.27</a></strong></td>
+ <td><strong>0.16.0</strong><br>0.15.7<br>0.15.6<br>0.15.5</td>
+ <td><strong><a href="http://spec.commonmark.org/0.28/">0.28</a></strong></td>
+ </tr>
+ <tr>
+ <td>0.15.4<br>0.15.3<br>0.15.2</td>
+ <td><a href="http://spec.commonmark.org/0.27/">0.27</a></td>
</tr>
<tr>
<td>0.15.1<br>0.15.0</td>
@@ -214,11 +220,11 @@ $ ./tests/benchmark/benchmark.php
## Versioning
-[SemVer](http://semver.org/) will be followed closely. 0.x.0 versions will introduce breaking changes to the codebase, so be careful which version constraints you use. **It's highly recommended that you use [Composer's caret operator](https://getcomposer.org/doc/articles/versions.md#caret) to ensure compatibility**; for example: `^0.15`. This is equivalent to `>=0.15.0 <0.16.0`.
+[SemVer](http://semver.org/) will be followed closely. 0.x.0 versions will introduce breaking changes to the codebase, so be careful which version constraints you use. **It's highly recommended that you use [Composer's caret operator](https://getcomposer.org/doc/articles/versions.md#caret) to ensure compatibility**; for example: `^0.16`. This is equivalent to `>=0.16.0 <0.17.0`.
0.x.y releases should not introduce breaking changes to the codebase; however, they might change the resulting AST or HTML output of parsed Markdown (due to bug fixes, minor spec changes, etc.) As a result, you might get slightly different HTML, but any custom code built onto this library will still function correctly.
-If you're only using the `CommonMarkConverter` class to convert Markdown (no other class references, custom parsers, etc.), then it should be safe to use a broader constraint like `~0.15`, `>0.15`, etc. I personally promise to never break this specific class in any future 0.x release.
+If you're only using the `CommonMarkConverter` class to convert Markdown (no other class references, custom parsers, etc.), then it should be safe to use a broader constraint like `~0.16`, `>0.16`, etc. I personally promise to never break this specific class in any future 0.x release.
## Stability
@@ -258,6 +264,10 @@ Also a huge thank you to [JetBrains](https://www.jetbrains.com/) for supporting
**league/commonmark** is licensed under the BSD-3 license. See the `LICENSE` file for more details.
+## Governance
+
+This project is primarily maintained by [Colin O'Dell][@colinodell]. Members of the [PHP League][php-league] Leadership Team may occassionally assist with some of these duties.
+
[CommonMark]: http://commonmark.org/
[CommonMark spec]: http://spec.commonmark.org/
[commonmark.js]: https://github.com/jgm/commonmark.js
@@ -267,7 +277,8 @@ Also a huge thank you to [JetBrains](https://www.jetbrains.com/) for supporting
[docs-example-twitter]: https://commonmark.thephpleague.com/customization/inline-parsing#example-1---twitter-handles
[docs-example-smilies]: https://commonmark.thephpleague.com/customization/inline-parsing#example-2---emoticons
[All Contributors]: https://github.com/thephpleague/commonmark/contributors
-[@colinodell]: https://github.com/colinodell
+[@colinodell]: https://www.twitter.com/colinodell
[@jgm]: https://github.com/jgm
[jgm/stmd]: https://github.com/jgm/stmd
[Composer]: https://getcomposer.org/
+[PHP League]: https://thephpleague.com
diff --git a/vendor/league/commonmark/UPGRADE.md b/vendor/league/commonmark/UPGRADE.md
index 213aee1669..15bace7226 100644
--- a/vendor/league/commonmark/UPGRADE.md
+++ b/vendor/league/commonmark/UPGRADE.md
@@ -1,5 +1,114 @@
# Upgrade Instructions
+## 0.17.0
+
+## Minimum PHP version
+
+The minimum PHP version has been increased to 5.6.5. Users on PHP 5.4 and 5.5 can still use previous versions of this library but will not receive future improvements or bug fixes.
+
+## Removal of deprecated features
+
+Pretty much everything marked as `@deprecated` in 0.16.0 has been removed.
+
+## `RegexHelper`
+
+We're now taking advantage of PHP 5.6's constant expression feature. This removes the need for `RegexHelper` to be a singleton where complex regular expressions are built and referenced using instance methods. **All regexes are now available as class constants.**
+
+For example, instead of doing this:
+
+```php
+preg_match('/' . RegexHelper::getInstance()->getPartialRegex(RegexHelper::OPENTAG) . '/', $html);
+```
+
+You can now do this:
+
+```php
+preg_match('/' . RegexHelper::PARTIAL_OPENTAG . '/', $html);
+```
+
+(Basically, remove that function call and prefix the constant name with `PARTIAL_`).
+
+Other instance functions like `getLinkTitleRegex()` which returned a regular expression have also been deprecated in favor of pre-defined constants like `PARTIAL_LINK_TITLE`.
+
+The now-deprecated functionality still exists in 0.17.0 **but will be removed in the next major release.**
+
+To summarize:
+
+ - All `REGEX_` constants are fully-formed regexes. Most are unchanged.
+ - All `PARTIAL_` constants need to be wrapped with a `/` on each side before use.
+ - All instance methods are deprecated - use a constant instead.
+
+`RegexHelper` is also `final` now - it only contains constants and static methods and was never intended to be extended.
+
+## Cursor state
+
+`Cursor::saveState()` and `Cursor::restoreState()` provide the ability to rollback the state of a `Cursor`. For example:
+
+```php
+$oldState = $cursor->saveState();
+
+// Made-up example of trying to parse something using calls
+$cursor->advanceToNextNonSpaceOrTab();
+$cursor->match('/foo(bar)?/');
+$cursor->advanceToNextNonSpaceOrTab();
+
+if ($someConditionThatWeDidntExpect) {
+ // Roll back and abort
+ $cursor->restoreState($oldState);
+ return;
+}
+```
+
+This useful feature encapsulated the internal, `private` state of the `Cursor` inside of a `CursorState` object with public methods. **This was a design mistake** as it meant that any changes to the interal structure of a `Cursor` meant causing BC-breaks on the `CursorState`.
+
+`CursorState` was also never intended for any other usage besides saving/restoring.
+
+For those reasons, we've removed the `CursorState` class entirely and now store the state using an array. **Do not depend on the contents or structure of the array for any reason as it may change in any release without warning!** If you really need to reference information about the prior state of the cursor, either `clone` it or grab the info you need before manipulating it.
+
+## `InlineContainer` interface
+
+The `InlineContainer` interface was renamed to `InlineContainerInterface`. The old one still exists as a deprecated interface and will be removed in the next major release.
+
+## 0.16.0
+
+You may continue using the deprecated items listed below in version 0.16.x. **However, these deprecations will be removed in a future major release** (0.17.0+ or 1.0.0, whichever comes first) so consider updating your code now to prepare for that release.
+
+## `Cursor` and `CursorState` methods
+
+Basically, all methods in these two classes which contain `First` in their name have been deprecated. The original names were misleading as they always operated on the "first" non-space **after the current position**, which is not always the **first occurrence in the string**. You should instead use the `Next` versions instead:
+
+ - Deprecated `Cursor::advanceWhileMatches()`
+ - Use `Cursor::match()` instead.
+ - Deprecated `CursorState::getFirstNonSpaceCache()`
+ - Use `CursorState::getNextNonSpaceCache()` instead (identical behavior)
+ - Deprecated `Cursor::getFirstNonSpaceCharacter()`
+ - Use `Cursor::getNextNonSpaceCharacter()` instead (identical behavior)
+ - Deprecated `Cursor::getFirstNonSpacePosition()`
+ - Use `Cursor::getNextNonSpacePosition()` instead (identical behavior)
+ - Deprecated `Cursor::advanceToFirstNonSpace()`
+ - You'll probably want to use `advanceToNextNonSpaceOrTab()` if you're using this to parse blocks, but beware that it does not behave identically to the original method.
+ - If you need the exact functionality as the original, use `advanceToNextNonSpaceOrNewline()` instead. We're currently using this internally for parsing links and references.
+
+The reason we now have two alternatives to the `advancedToFirstNonSpace()` function is because we accidentally assumed that a single approach would work in two different use cases. As you can see in [issue #279](https://github.com/thephpleague/commonmark/issues/279), this assumption was false. We have therefore split the two different parsing strategies into two different methods. Both will behave similarly for strings that only contain spaces, but they differ when newlines or tabs are involved.
+
+More details about this change can be found here: https://github.com/thephpleague/commonmark/issues/280
+
+### `RegexHelper`
+
+`RegexHelper::REGEX_UNICODE_WHITESPACE` and `RegexHelper::getLinkDestinationRegex()` were no longer needed as of the 0.15.5 release and have therefore been deprecated and marked for removal.
+
+### `HtmlRenderer::escape()`
+
+`HtmlRenderer::escape()` was an instance method making it unusable as a general utility method. Its logic has been moved into a new static Xml::escape() method so use that instead - it takes the same exact methods and implements the same behavior.
+
+### Final Utility Classes
+
+The following utility classes were never meant to be extended and have therefore been marked `final`:
+
+ - `Html5Entities`
+ - `LinkParserHelper`
+ - `UrlEncoder`
+
## 0.15.0
### `CursorState` constructor
@@ -13,7 +122,7 @@ You should use `DelimiterStack::findMatchingOpener()` instead.
The method signature is almost identical, except for the inclusion of a by-reference boolean `$oddMatch`.
-The deprecated `findFirstMatchingOpener()` method may be removed as early as 0.16.0 or 1.0.0.
+The deprecated `findFirstMatchingOpener()` method was removed in the 0.16.0 release.
## 0.14.0
diff --git a/vendor/league/commonmark/composer.json b/vendor/league/commonmark/composer.json
index 3415533987..915c9f6546 100644
--- a/vendor/league/commonmark/composer.json
+++ b/vendor/league/commonmark/composer.json
@@ -17,17 +17,17 @@
"colinodell/commonmark-php": "*"
},
"require": {
- "php": ">=5.4.8",
+ "php": ">=5.6.5",
"ext-mbstring": "*"
},
"require-dev": {
"cebe/markdown": "~1.0",
"erusev/parsedown": "~1.0",
- "jgm/CommonMark": "0.27",
+ "commonmark/commonmark.js": "0.28",
"michelf/php-markdown": "~1.4",
"mikehaertl/php-shellcommand": "~1.2.0",
- "phpunit/phpunit": "~4.3|~5.0",
- "symfony/finder": "~2.3|~3.0",
+ "phpunit/phpunit": "~5.7|~6.5",
+ "symfony/finder": "~3.0|~4.0",
"scrutinizer/ocular": "~1.1"
},
"suggest": {
@@ -37,10 +37,10 @@
{
"type": "package",
"package": {
- "name": "jgm/CommonMark",
- "version": "0.27",
+ "name": "commonmark/commonmark.js",
+ "version": "0.28",
"dist": {
- "url": "https://github.com/jgm/commonmark.js/archive/0.27.0.zip",
+ "url": "https://github.com/commonmark/commonmark.js/archive/0.28.0.zip",
"type": "zip"
}
}
@@ -60,7 +60,7 @@
"bin": ["bin/commonmark"],
"extra": {
"branch-alias": {
- "dev-master": "0.16-dev"
+ "dev-master": "0.18-dev"
}
}
}
diff --git a/vendor/league/commonmark/src/Block/Element/AbstractBlock.php b/vendor/league/commonmark/src/Block/Element/AbstractBlock.php
index 5738f8097e..cf764f5c33 100644
--- a/vendor/league/commonmark/src/Block/Element/AbstractBlock.php
+++ b/vendor/league/commonmark/src/Block/Element/AbstractBlock.php
@@ -135,7 +135,7 @@ abstract class AbstractBlock extends Node
{
// create paragraph container for line
$context->addBlock(new Paragraph());
- $cursor->advanceToFirstNonSpace();
+ $cursor->advanceToNextNonSpaceOrTab();
$context->getTip()->addLine($cursor->getRemainder());
}
@@ -247,7 +247,7 @@ abstract class AbstractBlock extends Node
public function finalize(ContextInterface $context, $endLineNumber)
{
if (!$this->open) {
- return; // TODO: Throw AlreadyClosedException?
+ return;
}
$this->open = false;
diff --git a/vendor/league/commonmark/src/Block/Element/BlockQuote.php b/vendor/league/commonmark/src/Block/Element/BlockQuote.php
index c212653ac3..1d39dfe6e8 100644
--- a/vendor/league/commonmark/src/Block/Element/BlockQuote.php
+++ b/vendor/league/commonmark/src/Block/Element/BlockQuote.php
@@ -52,8 +52,8 @@ class BlockQuote extends AbstractBlock
public function matchesNextLine(Cursor $cursor)
{
- if (!$cursor->isIndented() && $cursor->getFirstNonSpaceCharacter() === '>') {
- $cursor->advanceToFirstNonSpace();
+ if (!$cursor->isIndented() && $cursor->getNextNonSpaceCharacter() === '>') {
+ $cursor->advanceToNextNonSpaceOrTab();
$cursor->advance();
$cursor->advanceBySpaceOrTab();
diff --git a/vendor/league/commonmark/src/Block/Element/FencedCode.php b/vendor/league/commonmark/src/Block/Element/FencedCode.php
index deb2f32446..a52bee81ab 100644
--- a/vendor/league/commonmark/src/Block/Element/FencedCode.php
+++ b/vendor/league/commonmark/src/Block/Element/FencedCode.php
@@ -173,7 +173,7 @@ class FencedCode extends AbstractBlock
}
// Skip optional spaces of fence offset
- $cursor->advanceWhileMatches(' ', $this->offset);
+ $cursor->match('/^ {0,' . $this->offset . '}/');
return true;
}
@@ -202,8 +202,8 @@ class FencedCode extends AbstractBlock
$container = $context->getContainer();
// check for closing code fence
- if ($cursor->getIndent() <= 3 && $cursor->getFirstNonSpaceCharacter() === $container->getChar()) {
- $match = RegexHelper::matchAll('/^(?:`{3,}|~{3,})(?= *$)/', $cursor->getLine(), $cursor->getFirstNonSpacePosition());
+ if ($cursor->getIndent() <= 3 && $cursor->getNextNonSpaceCharacter() === $container->getChar()) {
+ $match = RegexHelper::matchAll('/^(?:`{3,}|~{3,})(?= *$)/', $cursor->getLine(), $cursor->getNextNonSpacePosition());
if (strlen($match[0]) >= $container->getLength()) {
// don't add closing fence to container; instead, close it:
$this->setLength(-1); // -1 means we've passed closer
diff --git a/vendor/league/commonmark/src/Block/Element/Heading.php b/vendor/league/commonmark/src/Block/Element/Heading.php
index 94302edc46..c70c4e31f7 100644
--- a/vendor/league/commonmark/src/Block/Element/Heading.php
+++ b/vendor/league/commonmark/src/Block/Element/Heading.php
@@ -17,7 +17,7 @@ namespace League\CommonMark\Block\Element;
use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
-class Heading extends AbstractBlock implements InlineContainer
+class Heading extends AbstractBlock implements InlineContainerInterface
{
/**
* @var int
diff --git a/vendor/league/commonmark/src/Block/Element/IndentedCode.php b/vendor/league/commonmark/src/Block/Element/IndentedCode.php
index bf913a799a..23d996addf 100644
--- a/vendor/league/commonmark/src/Block/Element/IndentedCode.php
+++ b/vendor/league/commonmark/src/Block/Element/IndentedCode.php
@@ -56,7 +56,7 @@ class IndentedCode extends AbstractBlock
if ($cursor->isIndented()) {
$cursor->advanceBy(Cursor::INDENT_LEVEL, true);
} elseif ($cursor->isBlank()) {
- $cursor->advanceToFirstNonSpace();
+ $cursor->advanceToNextNonSpaceOrTab();
} else {
return false;
}
diff --git a/vendor/league/commonmark/src/Block/Element/InlineContainer.php b/vendor/league/commonmark/src/Block/Element/InlineContainer.php
index fe0d984f7a..2b863d4924 100644
--- a/vendor/league/commonmark/src/Block/Element/InlineContainer.php
+++ b/vendor/league/commonmark/src/Block/Element/InlineContainer.php
@@ -2,7 +2,9 @@
namespace League\CommonMark\Block\Element;
-interface InlineContainer
+/**
+ * @deprecated Use InlineContainerInterface instead
+ */
+interface InlineContainer extends InlineContainerInterface
{
- public function getStringContent();
}
diff --git a/vendor/league/commonmark/src/Block/Element/InlineContainerInterface.php b/vendor/league/commonmark/src/Block/Element/InlineContainerInterface.php
new file mode 100644
index 0000000000..cd58782115
--- /dev/null
+++ b/vendor/league/commonmark/src/Block/Element/InlineContainerInterface.php
@@ -0,0 +1,8 @@
+<?php
+
+namespace League\CommonMark\Block\Element;
+
+interface InlineContainerInterface
+{
+ public function getStringContent();
+}
diff --git a/vendor/league/commonmark/src/Block/Element/ListItem.php b/vendor/league/commonmark/src/Block/Element/ListItem.php
index 902e832857..2da2c7d81e 100644
--- a/vendor/league/commonmark/src/Block/Element/ListItem.php
+++ b/vendor/league/commonmark/src/Block/Element/ListItem.php
@@ -69,7 +69,7 @@ class ListItem extends AbstractBlock
return false;
}
- $cursor->advanceToFirstNonSpace();
+ $cursor->advanceToNextNonSpaceOrTab();
} elseif ($cursor->getIndent() >= $this->listData->markerOffset + $this->listData->padding) {
$cursor->advanceBy($this->listData->markerOffset + $this->listData->padding, true);
} else {
diff --git a/vendor/league/commonmark/src/Block/Element/Paragraph.php b/vendor/league/commonmark/src/Block/Element/Paragraph.php
index f5c9fb745c..c5b84c9a66 100644
--- a/vendor/league/commonmark/src/Block/Element/Paragraph.php
+++ b/vendor/league/commonmark/src/Block/Element/Paragraph.php
@@ -17,7 +17,7 @@ namespace League\CommonMark\Block\Element;
use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
-class Paragraph extends AbstractBlock implements InlineContainer
+class Paragraph extends AbstractBlock implements InlineContainerInterface
{
/**
* Returns true if this block can contain the given block as a child node
@@ -107,7 +107,7 @@ class Paragraph extends AbstractBlock implements InlineContainer
*/
public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
{
- $cursor->advanceToFirstNonSpace();
+ $cursor->advanceToNextNonSpaceOrTab();
$context->getTip()->addLine($cursor->getRemainder());
}
}
diff --git a/vendor/league/commonmark/src/Block/Parser/ATXHeadingParser.php b/vendor/league/commonmark/src/Block/Parser/ATXHeadingParser.php
index f456e32176..4e26804d0e 100644
--- a/vendor/league/commonmark/src/Block/Parser/ATXHeadingParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/ATXHeadingParser.php
@@ -33,19 +33,19 @@ class ATXHeadingParser extends AbstractBlockParser
return false;
}
- $match = RegexHelper::matchAll('/^#{1,6}(?:[ \t]+|$)/', $cursor->getLine(), $cursor->getFirstNonSpacePosition());
+ $match = RegexHelper::matchAll('/^#{1,6}(?:[ \t]+|$)/', $cursor->getLine(), $cursor->getNextNonSpacePosition());
if (!$match) {
return false;
}
- $cursor->advanceToFirstNonSpace();
+ $cursor->advanceToNextNonSpaceOrTab();
$cursor->advanceBy(strlen($match[0]));
$level = strlen(trim($match[0]));
$str = $cursor->getRemainder();
- $str = preg_replace('/^ *#+ *$/', '', $str);
- $str = preg_replace('/ +#+ *$/', '', $str);
+ $str = preg_replace('/^[ \t]*#+[ \t]*$/', '', $str);
+ $str = preg_replace('/[ \t]+#+[ \t]*$/', '', $str);
$context->addBlock(new Heading($level, $str));
$context->setBlocksParsed(true);
diff --git a/vendor/league/commonmark/src/Block/Parser/BlockQuoteParser.php b/vendor/league/commonmark/src/Block/Parser/BlockQuoteParser.php
index c7615af315..62342246ab 100644
--- a/vendor/league/commonmark/src/Block/Parser/BlockQuoteParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/BlockQuoteParser.php
@@ -32,11 +32,11 @@ class BlockQuoteParser extends AbstractBlockParser
return false;
}
- if ($cursor->getFirstNonSpaceCharacter() !== '>') {
+ if ($cursor->getNextNonSpaceCharacter() !== '>') {
return false;
}
- $cursor->advanceToFirstNonSpace();
+ $cursor->advanceToNextNonSpaceOrTab();
$cursor->advance();
$cursor->advanceBySpaceOrTab();
diff --git a/vendor/league/commonmark/src/Block/Parser/FencedCodeParser.php b/vendor/league/commonmark/src/Block/Parser/FencedCodeParser.php
index d87681b171..d27abb2b8a 100644
--- a/vendor/league/commonmark/src/Block/Parser/FencedCodeParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/FencedCodeParser.php
@@ -32,16 +32,14 @@ class FencedCodeParser extends AbstractBlockParser
return false;
}
- $previousState = $cursor->saveState();
- $indent = $cursor->advanceToFirstNonSpace();
- $fence = $cursor->match('/^`{3,}(?!.*`)|^~{3,}(?!.*~)/');
+ $indent = $cursor->getIndent();
+ $fence = $cursor->match('/^[ \t]*(?:`{3,}(?!.*`)|^~{3,}(?!.*~))/');
if (is_null($fence)) {
- $cursor->restoreState($previousState);
-
return false;
}
// fenced code block
+ $fence = ltrim($fence, " \t");
$fenceLength = strlen($fence);
$context->addBlock(new FencedCode($fenceLength, $fence[0], $indent));
diff --git a/vendor/league/commonmark/src/Block/Parser/HtmlBlockParser.php b/vendor/league/commonmark/src/Block/Parser/HtmlBlockParser.php
index 3eab228a84..4ac9b50c91 100644
--- a/vendor/league/commonmark/src/Block/Parser/HtmlBlockParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/HtmlBlockParser.php
@@ -34,13 +34,13 @@ class HtmlBlockParser extends AbstractBlockParser
return false;
}
- if ($cursor->getFirstNonSpaceCharacter() !== '<') {
+ if ($cursor->getNextNonSpaceCharacter() !== '<') {
return false;
}
$savedState = $cursor->saveState();
- $cursor->advanceToFirstNonSpace();
+ $cursor->advanceToNextNonSpaceOrTab();
$line = $cursor->getRemainder();
for ($blockType = 1; $blockType <= 7; $blockType++) {
diff --git a/vendor/league/commonmark/src/Block/Parser/ListParser.php b/vendor/league/commonmark/src/Block/Parser/ListParser.php
index 5255e678af..131699837a 100644
--- a/vendor/league/commonmark/src/Block/Parser/ListParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/ListParser.php
@@ -37,27 +37,27 @@ class ListParser extends AbstractBlockParser
}
$tmpCursor = clone $cursor;
- $tmpCursor->advanceToFirstNonSpace();
+ $tmpCursor->advanceToNextNonSpaceOrTab();
$rest = $tmpCursor->getRemainder();
$data = new ListData();
$data->markerOffset = $cursor->getIndent();
- if ($matches = RegexHelper::matchAll('/^[*+-]/', $rest)) {
+ if (preg_match('/^[*+-]/', $rest) === 1) {
$data->type = ListBlock::TYPE_UNORDERED;
$data->delimiter = null;
- $data->bulletChar = $matches[0][0];
+ $data->bulletChar = $rest[0];
+ $markerLength = 1;
} elseif (($matches = RegexHelper::matchAll('/^(\d{1,9})([.)])/', $rest)) && (!($context->getContainer() instanceof Paragraph) || $matches[1] === '1')) {
$data->type = ListBlock::TYPE_ORDERED;
- $data->start = intval($matches[1]);
+ $data->start = (int) $matches[1];
$data->delimiter = $matches[2];
$data->bulletChar = null;
+ $markerLength = strlen($matches[0]);
} else {
return false;
}
- $markerLength = strlen($matches[0]);
-
// Make sure we have spaces after
$nextChar = $tmpCursor->peek($markerLength);
if (!($nextChar === null || $nextChar === "\t" || $nextChar === ' ')) {
@@ -65,18 +65,18 @@ class ListParser extends AbstractBlockParser
}
// If it interrupts paragraph, make sure first line isn't blank
- if ($context->getContainer() instanceof Paragraph && !RegexHelper::matchAt(RegexHelper::REGEX_NON_SPACE, $rest, $markerLength)) {
+ $container = $context->getContainer();
+ if ($container instanceof Paragraph && !RegexHelper::matchAt(RegexHelper::REGEX_NON_SPACE, $rest, $markerLength)) {
return false;
}
// We've got a match! Advance offset and calculate padding
- $cursor->advanceToFirstNonSpace(); // to start of marker
+ $cursor->advanceToNextNonSpaceOrTab(); // to start of marker
$cursor->advanceBy($markerLength, true); // to end of marker
$data->padding = $this->calculateListMarkerPadding($cursor, $markerLength);
// add the list if needed
- $container = $context->getContainer();
- if (!$container || !($context->getContainer() instanceof ListBlock) || !$data->equals($container->getListData())) {
+ if (!$container || !($container instanceof ListBlock) || !$data->equals($container->getListData())) {
$context->addBlock(new ListBlock($data));
}
diff --git a/vendor/league/commonmark/src/Block/Parser/SetExtHeadingParser.php b/vendor/league/commonmark/src/Block/Parser/SetExtHeadingParser.php
index 23de37063c..56ad1fd765 100644
--- a/vendor/league/commonmark/src/Block/Parser/SetExtHeadingParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/SetExtHeadingParser.php
@@ -38,7 +38,7 @@ class SetExtHeadingParser extends AbstractBlockParser
return false;
}
- $match = RegexHelper::matchAll('/^(?:=+|-+)[ \t]*$/', $cursor->getLine(), $cursor->getFirstNonSpacePosition());
+ $match = RegexHelper::matchAll('/^(?:=+|-+)[ \t]*$/', $cursor->getLine(), $cursor->getNextNonSpacePosition());
if ($match === null) {
return false;
}
diff --git a/vendor/league/commonmark/src/Block/Parser/ThematicBreakParser.php b/vendor/league/commonmark/src/Block/Parser/ThematicBreakParser.php
index 6b81e5304c..09ad7dcdf0 100644
--- a/vendor/league/commonmark/src/Block/Parser/ThematicBreakParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/ThematicBreakParser.php
@@ -33,7 +33,7 @@ class ThematicBreakParser extends AbstractBlockParser
return false;
}
- $match = RegexHelper::matchAt(RegexHelper::getInstance()->getThematicBreakRegex(), $cursor->getLine(), $cursor->getFirstNonSpacePosition());
+ $match = RegexHelper::matchAt(RegexHelper::REGEX_THEMATIC_BREAK, $cursor->getLine(), $cursor->getNextNonSpacePosition());
if ($match === null) {
return false;
}
diff --git a/vendor/league/commonmark/src/Block/Renderer/BlockQuoteRenderer.php b/vendor/league/commonmark/src/Block/Renderer/BlockQuoteRenderer.php
index e2dbf5f26e..e35285c889 100644
--- a/vendor/league/commonmark/src/Block/Renderer/BlockQuoteRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/BlockQuoteRenderer.php
@@ -18,6 +18,7 @@ use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\Block\Element\BlockQuote;
use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
+use League\CommonMark\Util\Xml;
class BlockQuoteRenderer implements BlockRendererInterface
{
@@ -36,7 +37,7 @@ class BlockQuoteRenderer implements BlockRendererInterface
$attrs = [];
foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = $htmlRenderer->escape($value, true);
+ $attrs[$key] = Xml::escape($value, true);
}
$filling = $htmlRenderer->renderBlocks($block->children());
diff --git a/vendor/league/commonmark/src/Block/Renderer/FencedCodeRenderer.php b/vendor/league/commonmark/src/Block/Renderer/FencedCodeRenderer.php
index 6dee2774be..c018bebce8 100644
--- a/vendor/league/commonmark/src/Block/Renderer/FencedCodeRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/FencedCodeRenderer.php
@@ -18,6 +18,7 @@ use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\Block\Element\FencedCode;
use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
+use League\CommonMark\Util\Xml;
class FencedCodeRenderer implements BlockRendererInterface
{
@@ -36,19 +37,19 @@ class FencedCodeRenderer implements BlockRendererInterface
$attrs = [];
foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = $htmlRenderer->escape($value, true);
+ $attrs[$key] = Xml::escape($value, true);
}
$infoWords = $block->getInfoWords();
if (count($infoWords) !== 0 && strlen($infoWords[0]) !== 0) {
$attrs['class'] = isset($attrs['class']) ? $attrs['class'] . ' ' : '';
- $attrs['class'] .= 'language-' . $htmlRenderer->escape($infoWords[0], true);
+ $attrs['class'] .= 'language-' . Xml::escape($infoWords[0], true);
}
return new HtmlElement(
'pre',
[],
- new HtmlElement('code', $attrs, $htmlRenderer->escape($block->getStringContent()))
+ new HtmlElement('code', $attrs, Xml::escape($block->getStringContent()))
);
}
}
diff --git a/vendor/league/commonmark/src/Block/Renderer/HeadingRenderer.php b/vendor/league/commonmark/src/Block/Renderer/HeadingRenderer.php
index 4f666898ec..0a09c290a5 100644
--- a/vendor/league/commonmark/src/Block/Renderer/HeadingRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/HeadingRenderer.php
@@ -18,6 +18,7 @@ use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\Block\Element\Heading;
use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
+use League\CommonMark\Util\Xml;
class HeadingRenderer implements BlockRendererInterface
{
@@ -38,7 +39,7 @@ class HeadingRenderer implements BlockRendererInterface
$attrs = [];
foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = $htmlRenderer->escape($value, true);
+ $attrs[$key] = Xml::escape($value, true);
}
return new HtmlElement($tag, $attrs, $htmlRenderer->renderInlines($block->children()));
diff --git a/vendor/league/commonmark/src/Block/Renderer/IndentedCodeRenderer.php b/vendor/league/commonmark/src/Block/Renderer/IndentedCodeRenderer.php
index b065fd122c..b514625b12 100644
--- a/vendor/league/commonmark/src/Block/Renderer/IndentedCodeRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/IndentedCodeRenderer.php
@@ -18,6 +18,7 @@ use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\Block\Element\IndentedCode;
use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
+use League\CommonMark\Util\Xml;
class IndentedCodeRenderer implements BlockRendererInterface
{
@@ -36,13 +37,13 @@ class IndentedCodeRenderer implements BlockRendererInterface
$attrs = [];
foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = $htmlRenderer->escape($value, true);
+ $attrs[$key] = Xml::escape($value, true);
}
return new HtmlElement(
'pre',
[],
- new HtmlElement('code', $attrs, $htmlRenderer->escape($block->getStringContent()))
+ new HtmlElement('code', $attrs, Xml::escape($block->getStringContent()))
);
}
}
diff --git a/vendor/league/commonmark/src/Block/Renderer/ListBlockRenderer.php b/vendor/league/commonmark/src/Block/Renderer/ListBlockRenderer.php
index 9d4e3681fb..f8dac9d07d 100644
--- a/vendor/league/commonmark/src/Block/Renderer/ListBlockRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/ListBlockRenderer.php
@@ -18,6 +18,7 @@ use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\Block\Element\ListBlock;
use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
+use League\CommonMark\Util\Xml;
class ListBlockRenderer implements BlockRendererInterface
{
@@ -40,7 +41,7 @@ class ListBlockRenderer implements BlockRendererInterface
$attrs = [];
foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = $htmlRenderer->escape($value, true);
+ $attrs[$key] = Xml::escape($value, true);
}
if ($listData->start !== null && $listData->start !== 1) {
diff --git a/vendor/league/commonmark/src/Block/Renderer/ListItemRenderer.php b/vendor/league/commonmark/src/Block/Renderer/ListItemRenderer.php
index e8c340e7e4..6f7c21b175 100644
--- a/vendor/league/commonmark/src/Block/Renderer/ListItemRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/ListItemRenderer.php
@@ -18,6 +18,7 @@ use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\Block\Element\ListItem;
use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
+use League\CommonMark\Util\Xml;
class ListItemRenderer implements BlockRendererInterface
{
@@ -44,7 +45,7 @@ class ListItemRenderer implements BlockRendererInterface
$attrs = [];
foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = $htmlRenderer->escape($value, true);
+ $attrs[$key] = Xml::escape($value, true);
}
$li = new HtmlElement('li', $attrs, $contents);
diff --git a/vendor/league/commonmark/src/Block/Renderer/ParagraphRenderer.php b/vendor/league/commonmark/src/Block/Renderer/ParagraphRenderer.php
index a221f29121..b6d2fa1dcb 100644
--- a/vendor/league/commonmark/src/Block/Renderer/ParagraphRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/ParagraphRenderer.php
@@ -18,6 +18,7 @@ use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\Block\Element\Paragraph;
use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
+use League\CommonMark\Util\Xml;
class ParagraphRenderer implements BlockRendererInterface
{
@@ -36,13 +37,13 @@ class ParagraphRenderer implements BlockRendererInterface
if ($inTightList) {
return $htmlRenderer->renderInlines($block->children());
- } else {
- $attrs = [];
- foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = $htmlRenderer->escape($value, true);
- }
+ }
- return new HtmlElement('p', $attrs, $htmlRenderer->renderInlines($block->children()));
+ $attrs = [];
+ foreach ($block->getData('attributes', []) as $key => $value) {
+ $attrs[$key] = Xml::escape($value, true);
}
+
+ return new HtmlElement('p', $attrs, $htmlRenderer->renderInlines($block->children()));
}
}
diff --git a/vendor/league/commonmark/src/Block/Renderer/ThematicBreakRenderer.php b/vendor/league/commonmark/src/Block/Renderer/ThematicBreakRenderer.php
index c92e5de074..d83da36fa3 100644
--- a/vendor/league/commonmark/src/Block/Renderer/ThematicBreakRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/ThematicBreakRenderer.php
@@ -18,6 +18,7 @@ use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\Block\Element\ThematicBreak;
use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
+use League\CommonMark\Util\Xml;
class ThematicBreakRenderer implements BlockRendererInterface
{
@@ -36,7 +37,7 @@ class ThematicBreakRenderer implements BlockRendererInterface
$attrs = [];
foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = $htmlRenderer->escape($value, true);
+ $attrs[$key] = Xml::escape($value, true);
}
return new HtmlElement('hr', $attrs, '', true);
diff --git a/vendor/league/commonmark/src/Cursor.php b/vendor/league/commonmark/src/Cursor.php
index e4252e6c6f..7de36dfab3 100644
--- a/vendor/league/commonmark/src/Cursor.php
+++ b/vendor/league/commonmark/src/Cursor.php
@@ -51,7 +51,7 @@ class Cursor
/**
* @var int|null
*/
- private $firstNonSpaceCache;
+ private $nextNonSpaceCache;
/**
* @var bool
@@ -59,23 +59,41 @@ class Cursor
private $partiallyConsumedTab = false;
/**
+ * @var string
+ */
+ private $encoding;
+
+ /**
+ * @var bool
+ */
+ private $lineContainsTabs;
+
+ /**
+ * @var bool
+ */
+ private $isMultibyte;
+
+ /**
* @param string $line
*/
public function __construct($line)
{
$this->line = $line;
- $this->length = mb_strlen($line, 'utf-8');
+ $this->encoding = mb_detect_encoding($line, 'ASCII,UTF-8', true) ?: 'ISO-8859-1';
+ $this->length = mb_strlen($line, $this->encoding);
+ $this->isMultibyte = $this->length !== strlen($line);
+ $this->lineContainsTabs = preg_match('/\t/', $line) > 0;
}
/**
- * Returns the position of the next non-space character
+ * Returns the position of the next character which is not a space (or tab)
*
* @return int
*/
- public function getFirstNonSpacePosition()
+ public function getNextNonSpacePosition()
{
- if ($this->firstNonSpaceCache !== null) {
- return $this->firstNonSpaceCache;
+ if ($this->nextNonSpaceCache !== null) {
+ return $this->nextNonSpaceCache;
}
$i = $this->currentPosition;
@@ -96,17 +114,17 @@ class Cursor
$nextNonSpace = ($c === null) ? $this->length : $i;
$this->indent = $cols - $this->column;
- return $this->firstNonSpaceCache = $nextNonSpace;
+ return $this->nextNonSpaceCache = $nextNonSpace;
}
/**
- * Returns the next character which isn't a space
+ * Returns the next character which isn't a space (or tab)
*
* @return string
*/
- public function getFirstNonSpaceCharacter()
+ public function getNextNonSpaceCharacter()
{
- return $this->getCharacter($this->getFirstNonSpacePosition());
+ return $this->getCharacter($this->getNextNonSpacePosition());
}
/**
@@ -116,7 +134,7 @@ class Cursor
*/
public function getIndent()
{
- $this->getFirstNonSpacePosition();
+ $this->getNextNonSpacePosition();
return $this->indent;
}
@@ -128,7 +146,9 @@ class Cursor
*/
public function isIndented()
{
- return $this->getIndent() >= self::INDENT_LEVEL;
+ $this->getNextNonSpacePosition();
+
+ return $this->indent >= self::INDENT_LEVEL;
}
/**
@@ -147,7 +167,7 @@ class Cursor
return;
}
- return mb_substr($this->line, $index, 1, 'utf-8');
+ return mb_substr($this->line, $index, 1, $this->encoding);
}
/**
@@ -169,7 +189,7 @@ class Cursor
*/
public function isBlank()
{
- return $this->getFirstNonSpacePosition() === $this->length;
+ return $this->getNextNonSpacePosition() === $this->length;
}
/**
@@ -183,14 +203,32 @@ class Cursor
/**
* Move the cursor forwards
*
- * @param int $characters Number of characters to advance by
+ * @param int $characters Number of characters to advance by
+ * @param bool $advanceByColumns Whether to advance by columns instead of spaces
*/
public function advanceBy($characters, $advanceByColumns = false)
{
+ if ($characters === 0) {
+ $this->previousPosition = $this->currentPosition;
+
+ return;
+ }
+
$this->previousPosition = $this->currentPosition;
- $this->firstNonSpaceCache = null;
+ $this->nextNonSpaceCache = null;
+
+ $nextFewChars = mb_substr($this->line, $this->currentPosition, $characters, $this->encoding);
+
+ // Optimization to avoid tab handling logic if we have no tabs
+ if (!$this->lineContainsTabs || preg_match('/\t/', $nextFewChars) === 0) {
+ $length = min($characters, $this->length - $this->currentPosition);
+ $this->partiallyConsumedTab = false;
+ $this->currentPosition += $length;
+ $this->column += $length;
+
+ return;
+ }
- $nextFewChars = mb_substr($this->line, $this->currentPosition, $characters, 'utf-8');
if ($characters === 1 && !empty($nextFewChars)) {
$asArray = [$nextFewChars];
} else {
@@ -200,11 +238,18 @@ class Cursor
foreach ($asArray as $relPos => $c) {
if ($c === "\t") {
$charsToTab = 4 - ($this->column % 4);
- $this->partiallyConsumedTab = $advanceByColumns && $charsToTab > $characters;
- $charsToAdvance = $charsToTab > $characters ? $characters : $charsToTab;
- $this->column += $charsToAdvance;
- $this->currentPosition += $this->partiallyConsumedTab ? 0 : 1;
- $characters -= $charsToAdvance;
+ if ($advanceByColumns) {
+ $this->partiallyConsumedTab = $charsToTab > $characters;
+ $charsToAdvance = $charsToTab > $characters ? $characters : $charsToTab;
+ $this->column += $charsToAdvance;
+ $this->currentPosition += $this->partiallyConsumedTab ? 0 : 1;
+ $characters -= $charsToAdvance;
+ } else {
+ $this->partiallyConsumedTab = false;
+ $this->column += $charsToTab;
+ $this->currentPosition++;
+ $characters--;
+ }
} else {
$this->partiallyConsumedTab = false;
$this->currentPosition++;
@@ -237,43 +282,27 @@ class Cursor
}
/**
- * Advances the cursor while the given character is matched
- *
- * @param string $character Character to match
- * @param int|null $maximumCharactersToAdvance Maximum number of characters to advance before giving up
+ * Parse zero or more space/tab characters
*
- * @return int Number of positions moved (0 if unsuccessful)
+ * @return int Number of positions moved
*/
- public function advanceWhileMatches($character, $maximumCharactersToAdvance = null)
+ public function advanceToNextNonSpaceOrTab()
{
- // Calculate how far to advance
- $start = $this->currentPosition;
- $newIndex = $start;
- if ($maximumCharactersToAdvance === null) {
- $maximumCharactersToAdvance = $this->length;
- }
-
- $max = min($start + $maximumCharactersToAdvance, $this->length);
-
- while ($newIndex < $max && $this->getCharacter($newIndex) === $character) {
- ++$newIndex;
- }
-
- if ($newIndex <= $start) {
- return 0;
- }
-
- $this->advanceBy($newIndex - $start);
+ $newPosition = $this->getNextNonSpacePosition();
+ $this->advanceBy($newPosition - $this->currentPosition);
+ $this->partiallyConsumedTab = false;
return $this->currentPosition - $this->previousPosition;
}
/**
- * Parse zero or more space characters, including at most one newline
+ * Parse zero or more space characters, including at most one newline.
+ *
+ * Tab characters are not parsed with this function.
*
* @return int Number of positions moved
*/
- public function advanceToFirstNonSpace()
+ public function advanceToNextNonSpaceOrNewline()
{
$matches = [];
preg_match('/^ *(?:\n *)?/', $this->getRemainder(), $matches, PREG_OFFSET_CAPTURE);
@@ -299,7 +328,7 @@ class Cursor
public function advanceToEnd()
{
$this->previousPosition = $this->currentPosition;
- $this->firstNonSpaceCache = null;
+ $this->nextNonSpaceCache = null;
$this->currentPosition = $this->length;
@@ -311,7 +340,7 @@ class Cursor
*/
public function getRemainder()
{
- if ($this->isAtEnd()) {
+ if ($this->currentPosition >= $this->length) {
return '';
}
@@ -323,7 +352,7 @@ class Cursor
$prefix = str_repeat(' ', $charsToTab);
}
- return $prefix . mb_substr($this->line, $position, null, 'utf-8');
+ return $prefix . mb_substr($this->line, $position, null, $this->encoding);
}
/**
@@ -355,51 +384,65 @@ class Cursor
{
$subject = $this->getRemainder();
- $matches = [];
if (!preg_match($regex, $subject, $matches, PREG_OFFSET_CAPTURE)) {
return;
}
- // PREG_OFFSET_CAPTURE always returns the byte offset, not the char offset, which is annoying
- $offset = mb_strlen(mb_strcut($subject, 0, $matches[0][1], 'utf-8'), 'utf-8');
+ // $matches[0][0] contains the matched text
+ // $matches[0][1] contains the index of that match
+
+ if ($this->isMultibyte) {
+ // PREG_OFFSET_CAPTURE always returns the byte offset, not the char offset, which is annoying
+ $offset = mb_strlen(mb_strcut($subject, 0, $matches[0][1], $this->encoding), $this->encoding);
+ } else {
+ $offset = $matches[0][1];
+ }
// [0][0] contains the matched text
// [0][1] contains the index of that match
- $this->advanceBy($offset + mb_strlen($matches[0][0], 'utf-8'));
+ $this->advanceBy($offset + mb_strlen($matches[0][0], $this->encoding));
return $matches[0][0];
}
/**
- * @return CursorState
+ * Encapsulates the current state of this cursor in case you need to rollback later.
+ *
+ * WARNING: Do not parse or use the return value for ANYTHING except for
+ * passing it back into restoreState(), as the number of values and their
+ * contents may change in any future release without warning.
+ *
+ * @return array
*/
public function saveState()
{
- return new CursorState(
- $this->line,
- $this->length,
+ return [
$this->currentPosition,
$this->previousPosition,
- $this->firstNonSpaceCache,
+ $this->nextNonSpaceCache,
$this->indent,
$this->column,
- $this->partiallyConsumedTab
- );
+ $this->partiallyConsumedTab,
+ ];
}
/**
- * @param CursorState $state
+ * Restore the cursor to a previous state.
+ *
+ * Pass in the value previously obtained by calling saveState().
+ *
+ * @param array $state
*/
- public function restoreState(CursorState $state)
+ public function restoreState($state)
{
- $this->line = $state->getLine();
- $this->length = $state->getLength();
- $this->currentPosition = $state->getCurrentPosition();
- $this->previousPosition = $state->getPreviousPosition();
- $this->firstNonSpaceCache = $state->getFirstNonSpaceCache();
- $this->column = $state->getColumn();
- $this->indent = $state->getIndent();
- $this->partiallyConsumedTab = $state->getPartiallyConsumedTab();
+ list(
+ $this->currentPosition,
+ $this->previousPosition,
+ $this->nextNonSpaceCache,
+ $this->indent,
+ $this->column,
+ $this->partiallyConsumedTab,
+ ) = $state;
}
/**
@@ -415,7 +458,7 @@ class Cursor
*/
public function getPreviousText()
{
- return mb_substr($this->line, $this->previousPosition, $this->currentPosition - $this->previousPosition, 'utf-8');
+ return mb_substr($this->line, $this->previousPosition, $this->currentPosition - $this->previousPosition, $this->encoding);
}
/**
diff --git a/vendor/league/commonmark/src/CursorState.php b/vendor/league/commonmark/src/CursorState.php
deleted file mode 100644
index a70091e4b4..0000000000
--- a/vendor/league/commonmark/src/CursorState.php
+++ /dev/null
@@ -1,141 +0,0 @@
-<?php
-
-/*
- * This file is part of the league/commonmark package.
- *
- * (c) Colin O'Dell <colinodell@gmail.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace League\CommonMark;
-
-class CursorState
-{
- /**
- * @var string
- */
- private $line;
-
- /**
- * @var int
- */
- private $length;
-
- /**
- * @var int
- */
- private $currentPosition;
-
- /**
- * @var int
- */
- private $previousPosition;
-
- /**
- * @var int|null
- */
- private $firstNonSpaceCache;
-
- /**
- * @var int
- */
- private $indent;
-
- /**
- * @var int
- */
- private $column;
-
- /**
- * @var bool
- */
- private $partiallyConsumedTab;
-
- /**
- * @param string $line
- * @param int $length
- * @param int $currentPosition
- * @param int $previousPosition
- * @param int|null $firstNonSpaceCache
- * @param int $indent
- * @param int $column
- * @param bool $partiallyConsumedTab
- */
- public function __construct($line, $length, $currentPosition, $previousPosition, $firstNonSpaceCache, $indent, $column, $partiallyConsumedTab)
- {
- $this->line = $line;
- $this->length = $length;
- $this->currentPosition = $currentPosition;
- $this->previousPosition = $previousPosition;
- $this->firstNonSpaceCache = $firstNonSpaceCache;
- $this->indent = $indent;
- $this->column = $column;
- $this->partiallyConsumedTab = $partiallyConsumedTab;
- }
-
- /**
- * @return int
- */
- public function getCurrentPosition()
- {
- return $this->currentPosition;
- }
-
- /**
- * @return int
- */
- public function getLength()
- {
- return $this->length;
- }
-
- /**
- * @return string
- */
- public function getLine()
- {
- return $this->line;
- }
-
- /**
- * @return int
- */
- public function getPreviousPosition()
- {
- return $this->previousPosition;
- }
-
- /**
- * @return int|null
- */
- public function getFirstNonSpaceCache()
- {
- return $this->firstNonSpaceCache;
- }
-
- /**
- * @return int
- */
- public function getIndent()
- {
- return $this->indent;
- }
-
- /**
- * @return int
- */
- public function getColumn()
- {
- return $this->column;
- }
-
- /**
- * @return bool
- */
- public function getPartiallyConsumedTab()
- {
- return $this->partiallyConsumedTab;
- }
-}
diff --git a/vendor/league/commonmark/src/Delimiter/Delimiter.php b/vendor/league/commonmark/src/Delimiter/Delimiter.php
index 66ce8296ea..b58a9d2657 100644
--- a/vendor/league/commonmark/src/Delimiter/Delimiter.php
+++ b/vendor/league/commonmark/src/Delimiter/Delimiter.php
@@ -24,6 +24,9 @@ class Delimiter
/** @var int */
protected $numDelims;
+ /** @var int */
+ protected $origDelims;
+
/** @var Node */
protected $inlineNode;
@@ -57,6 +60,7 @@ class Delimiter
{
$this->char = $char;
$this->numDelims = $numDelims;
+ $this->origDelims = $numDelims;
$this->inlineNode = $node;
$this->canOpen = $canOpen;
$this->canClose = $canClose;
@@ -205,6 +209,14 @@ class Delimiter
}
/**
+ * @return int
+ */
+ public function getOrigDelims()
+ {
+ return $this->origDelims;
+ }
+
+ /**
* @return Node
*/
public function getInlineNode()
diff --git a/vendor/league/commonmark/src/Delimiter/DelimiterStack.php b/vendor/league/commonmark/src/Delimiter/DelimiterStack.php
index 9a49d146dd..c7e06ede10 100644
--- a/vendor/league/commonmark/src/Delimiter/DelimiterStack.php
+++ b/vendor/league/commonmark/src/Delimiter/DelimiterStack.php
@@ -175,7 +175,7 @@ class DelimiterStack
$opener = $closer->getPrevious();
while ($opener !== null && $opener !== $stackBottom && $opener !== $openersBottom[$closerChar]) {
- $oddMatch = ($closer->canOpen() || $opener->canClose()) && ($opener->getNumDelims() + $closer->getNumDelims()) % 3 === 0;
+ $oddMatch = ($closer->canOpen() || $opener->canClose()) && ($opener->getOrigDelims() + $closer->getOrigDelims()) % 3 === 0;
if ($opener->getChar() === $closerChar && $opener->canOpen() && !$oddMatch) {
return $opener;
}
@@ -183,27 +183,4 @@ class DelimiterStack
$opener = $opener->getPrevious();
}
}
-
- /**
- * @param Delimiter $closer
- * @param array $openersBottom
- * @param Delimiter|null $stackBottom
- *
- * @return Delimiter|null
- *
- * @deprecated Use findMatchingOpener() instead. This method will be removed in the next major release.
- */
- protected function findFirstMatchingOpener(Delimiter $closer, $openersBottom, Delimiter $stackBottom = null)
- {
- $closerChar = $closer->getChar();
- $opener = $closer->getPrevious();
-
- while ($opener !== null && $opener !== $stackBottom && $opener !== $openersBottom[$closerChar]) {
- if ($opener->getChar() === $closerChar && $opener->canOpen()) {
- return $opener;
- }
-
- $opener = $opener->getPrevious();
- }
- }
}
diff --git a/vendor/league/commonmark/src/DocParser.php b/vendor/league/commonmark/src/DocParser.php
index 7aa9cab0a2..d0e0c3d7ed 100644
--- a/vendor/league/commonmark/src/DocParser.php
+++ b/vendor/league/commonmark/src/DocParser.php
@@ -16,7 +16,7 @@ namespace League\CommonMark;
use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\Block\Element\Document;
-use League\CommonMark\Block\Element\InlineContainer;
+use League\CommonMark\Block\Element\InlineContainerInterface;
use League\CommonMark\Block\Element\Paragraph;
use League\CommonMark\Node\NodeWalker;
@@ -33,12 +33,18 @@ class DocParser
private $inlineParserEngine;
/**
+ * @var int|float
+ */
+ private $maxNestingLevel;
+
+ /**
* @param Environment $environment
*/
public function __construct(Environment $environment)
{
$this->environment = $environment;
$this->inlineParserEngine = new InlineParserEngine($environment);
+ $this->maxNestingLevel = $environment->getConfig('max_nesting_level', INF);
}
/**
@@ -83,8 +89,8 @@ class DocParser
$this->incorporateLine($context);
}
- while ($context->getTip()) {
- $context->getTip()->finalize($context, count($lines));
+ while ($tip = $context->getTip()) {
+ $tip->finalize($context, count($lines));
}
$this->processInlines($context, $context->getDocument()->walker());
@@ -128,7 +134,7 @@ class DocParser
} elseif (!$cursor->isBlank()) {
// Create paragraph container for line
$context->addBlock(new Paragraph());
- $cursor->advanceToFirstNonSpace();
+ $cursor->advanceToNextNonSpaceOrTab();
$context->getTip()->addLine($cursor->getRemainder());
}
}
@@ -142,13 +148,13 @@ class DocParser
private function processInlines(ContextInterface $context, NodeWalker $walker)
{
- while (($event = $walker->next()) !== null) {
+ while ($event = $walker->next()) {
if (!$event->isEntering()) {
continue;
}
$node = $event->getNode();
- if ($node instanceof InlineContainer) {
+ if ($node instanceof InlineContainerInterface) {
$this->inlineParserEngine->parse($node, $context->getDocument()->getReferenceMap());
}
}
@@ -162,20 +168,22 @@ class DocParser
*/
private function resetContainer(ContextInterface $context, Cursor $cursor)
{
- $context->setContainer($context->getDocument());
+ $container = $context->getDocument();
- while ($context->getContainer()->hasChildren()) {
- $lastChild = $context->getContainer()->lastChild();
+ while ($container->hasChildren()) {
+ $lastChild = $container->lastChild();
if (!$lastChild->isOpen()) {
break;
}
- $context->setContainer($lastChild);
- if (!$context->getContainer()->matchesNextLine($cursor)) {
- $context->setContainer($context->getContainer()->parent()); // back up to the last matching block
+ $container = $lastChild;
+ if (!$container->matchesNextLine($cursor)) {
+ $container = $container->parent(); // back up to the last matching block
break;
}
}
+
+ $context->setContainer($container);
}
/**
@@ -195,8 +203,9 @@ class DocParser
}
}
- if (!$parsed || $context->getContainer()->acceptsLines()) {
+ if (!$parsed || $context->getContainer()->acceptsLines() || $context->getTip()->getDepth() >= $this->maxNestingLevel) {
$context->setBlocksParsed(true);
+ break;
}
}
}
@@ -219,15 +228,16 @@ class DocParser
* @param ContextInterface $context
* @param Cursor $cursor
*/
- private function setAndPropagateLastLineBlank(ContextInterface $context, $cursor)
+ private function setAndPropagateLastLineBlank(ContextInterface $context, Cursor $cursor)
{
- if ($cursor->isBlank() && $lastChild = $context->getContainer()->lastChild()) {
+ $container = $context->getContainer();
+
+ if ($cursor->isBlank() && $lastChild = $container->lastChild()) {
if ($lastChild instanceof AbstractBlock) {
$lastChild->setLastLineBlank(true);
}
}
- $container = $context->getContainer();
$lastLineBlank = $container->shouldLastLineBeBlank($cursor, $context->getLineNumber());
// Propagate lastLineBlank up through parents:
diff --git a/vendor/league/commonmark/src/ElementRendererInterface.php b/vendor/league/commonmark/src/ElementRendererInterface.php
index 9101a44d78..54e577acbd 100644
--- a/vendor/league/commonmark/src/ElementRendererInterface.php
+++ b/vendor/league/commonmark/src/ElementRendererInterface.php
@@ -31,14 +31,6 @@ interface ElementRendererInterface
public function getOption($option, $default = null);
/**
- * @param string $string
- * @param bool $preserveEntities
- *
- * @return string
- */
- public function escape($string, $preserveEntities = false);
-
- /**
* @param AbstractInline[] $inlines
*
* @return string
diff --git a/vendor/league/commonmark/src/Environment.php b/vendor/league/commonmark/src/Environment.php
index 442e1ca299..c5ca1a1355 100644
--- a/vendor/league/commonmark/src/Environment.php
+++ b/vendor/league/commonmark/src/Environment.php
@@ -243,14 +243,14 @@ class Environment
/**
* @param string $character
*
- * @return InlineParserInterface[]|null
+ * @return InlineParserInterface[]
*/
public function getInlineParsersForCharacter($character)
{
$this->initializeExtensions();
if (!isset($this->inlineParsersByCharacter[$character])) {
- return;
+ return [];
}
return $this->inlineParsersByCharacter[$character];
@@ -485,6 +485,7 @@ class Environment
'safe' => false, // deprecated option
'html_input' => self::HTML_INPUT_ALLOW,
'allow_unsafe_links' => true,
+ 'max_nesting_level' => INF,
]);
return $environment;
@@ -533,7 +534,7 @@ class Environment
private function getMiscExtension()
{
$lastExtension = end($this->extensions);
- if ($lastExtension !== false && $lastExtension instanceof MiscExtension) {
+ if ($lastExtension instanceof MiscExtension) {
return $lastExtension;
}
diff --git a/vendor/league/commonmark/src/Extension/CommonMarkCoreExtension.php b/vendor/league/commonmark/src/Extension/CommonMarkCoreExtension.php
index c9f47b589f..6a95023999 100644
--- a/vendor/league/commonmark/src/Extension/CommonMarkCoreExtension.php
+++ b/vendor/league/commonmark/src/Extension/CommonMarkCoreExtension.php
@@ -76,16 +76,16 @@ class CommonMarkCoreExtension extends Extension
public function getBlockRenderers()
{
return [
- 'League\CommonMark\Block\Element\BlockQuote' => new BlockRenderer\BlockQuoteRenderer(),
- 'League\CommonMark\Block\Element\Document' => new BlockRenderer\DocumentRenderer(),
- 'League\CommonMark\Block\Element\FencedCode' => new BlockRenderer\FencedCodeRenderer(),
- 'League\CommonMark\Block\Element\Heading' => new BlockRenderer\HeadingRenderer(),
- 'League\CommonMark\Block\Element\HtmlBlock' => new BlockRenderer\HtmlBlockRenderer(),
- 'League\CommonMark\Block\Element\IndentedCode' => new BlockRenderer\IndentedCodeRenderer(),
- 'League\CommonMark\Block\Element\ListBlock' => new BlockRenderer\ListBlockRenderer(),
- 'League\CommonMark\Block\Element\ListItem' => new BlockRenderer\ListItemRenderer(),
- 'League\CommonMark\Block\Element\Paragraph' => new BlockRenderer\ParagraphRenderer(),
- 'League\CommonMark\Block\Element\ThematicBreak' => new BlockRenderer\ThematicBreakRenderer(),
+ 'League\CommonMark\Block\Element\BlockQuote' => new BlockRenderer\BlockQuoteRenderer(),
+ 'League\CommonMark\Block\Element\Document' => new BlockRenderer\DocumentRenderer(),
+ 'League\CommonMark\Block\Element\FencedCode' => new BlockRenderer\FencedCodeRenderer(),
+ 'League\CommonMark\Block\Element\Heading' => new BlockRenderer\HeadingRenderer(),
+ 'League\CommonMark\Block\Element\HtmlBlock' => new BlockRenderer\HtmlBlockRenderer(),
+ 'League\CommonMark\Block\Element\IndentedCode' => new BlockRenderer\IndentedCodeRenderer(),
+ 'League\CommonMark\Block\Element\ListBlock' => new BlockRenderer\ListBlockRenderer(),
+ 'League\CommonMark\Block\Element\ListItem' => new BlockRenderer\ListItemRenderer(),
+ 'League\CommonMark\Block\Element\Paragraph' => new BlockRenderer\ParagraphRenderer(),
+ 'League\CommonMark\Block\Element\ThematicBreak' => new BlockRenderer\ThematicBreakRenderer(),
];
}
diff --git a/vendor/league/commonmark/src/Extension/MiscExtension.php b/vendor/league/commonmark/src/Extension/MiscExtension.php
index 0c3f730533..3feb791423 100644
--- a/vendor/league/commonmark/src/Extension/MiscExtension.php
+++ b/vendor/league/commonmark/src/Extension/MiscExtension.php
@@ -93,6 +93,8 @@ class MiscExtension implements ExtensionInterface
public function addInlineParser(InlineParserInterface $inlineParser)
{
$this->inlineParsers[] = $inlineParser;
+
+ return $this;
}
/**
@@ -162,6 +164,8 @@ class MiscExtension implements ExtensionInterface
}
$this->blockRenderers[$blockClass] = $blockRenderer;
+
+ return $this;
}
/**
diff --git a/vendor/league/commonmark/src/HtmlElement.php b/vendor/league/commonmark/src/HtmlElement.php
index 9dab1e9135..fee0e44059 100644
--- a/vendor/league/commonmark/src/HtmlElement.php
+++ b/vendor/league/commonmark/src/HtmlElement.php
@@ -107,7 +107,7 @@ class HtmlElement
*/
public function setContents($contents)
{
- $this->contents = !is_null($contents) ? $contents : '';
+ $this->contents = $contents !== null ? $contents : '';
return $this;
}
@@ -124,7 +124,7 @@ class HtmlElement
}
if ($this->contents !== '') {
- $result .= '>' . $this->getContents(true) . '</' . $this->tagName . '>';
+ $result .= '>' . $this->getContents() . '</' . $this->tagName . '>';
} elseif ($this->selfClosing) {
$result .= ' />';
} else {
diff --git a/vendor/league/commonmark/src/HtmlRenderer.php b/vendor/league/commonmark/src/HtmlRenderer.php
index b3a50f29a4..28bcdfe7e2 100644
--- a/vendor/league/commonmark/src/HtmlRenderer.php
+++ b/vendor/league/commonmark/src/HtmlRenderer.php
@@ -47,23 +47,6 @@ class HtmlRenderer implements ElementRendererInterface
}
/**
- * @param string $string
- * @param bool $preserveEntities
- *
- * @return string
- */
- public function escape($string, $preserveEntities = false)
- {
- if ($preserveEntities) {
- $string = preg_replace('/[&](?![#](x[a-f0-9]{1,8}|[0-9]{1,8});|[a-z][a-z0-9]{1,31};)/i', '&amp;', $string);
- } else {
- $string = str_replace('&', '&amp;', $string);
- }
-
- return str_replace(['<', '>', '"'], ['&lt;', '&gt;', '&quot;'], $string);
- }
-
- /**
* @param AbstractInline $inline
*
* @throws \RuntimeException
diff --git a/vendor/league/commonmark/src/Inline/Parser/BacktickParser.php b/vendor/league/commonmark/src/Inline/Parser/BacktickParser.php
index 86ee79fc4a..6a16703ca5 100644
--- a/vendor/league/commonmark/src/Inline/Parser/BacktickParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/BacktickParser.php
@@ -43,11 +43,12 @@ class BacktickParser extends AbstractInlineParser
return false;
}
+ $currentPosition = $cursor->getPosition();
$previousState = $cursor->saveState();
while ($matchingTicks = $cursor->match('/`+/m')) {
if ($matchingTicks === $ticks) {
- $code = mb_substr($cursor->getLine(), $previousState->getCurrentPosition(), $cursor->getPosition() - $previousState->getCurrentPosition() - strlen($ticks), 'utf-8');
+ $code = mb_substr($cursor->getLine(), $currentPosition, $cursor->getPosition() - $currentPosition - strlen($ticks), 'utf-8');
$c = preg_replace(RegexHelper::REGEX_WHITESPACE, ' ', $code);
$inlineContext->getContainer()->appendChild(new Code(trim($c)));
diff --git a/vendor/league/commonmark/src/Inline/Parser/CloseBracketParser.php b/vendor/league/commonmark/src/Inline/Parser/CloseBracketParser.php
index 111b5258bd..2fa3ba1aef 100644
--- a/vendor/league/commonmark/src/Inline/Parser/CloseBracketParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/CloseBracketParser.php
@@ -150,14 +150,14 @@ class CloseBracketParser extends AbstractInlineParser implements EnvironmentAwar
$previousState = $cursor->saveState();
$cursor->advance();
- $cursor->advanceToFirstNonSpace();
+ $cursor->advanceToNextNonSpaceOrNewline();
if (($dest = LinkParserHelper::parseLinkDestination($cursor)) === null) {
$cursor->restoreState($previousState);
return false;
}
- $cursor->advanceToFirstNonSpace();
+ $cursor->advanceToNextNonSpaceOrNewline();
$title = null;
// make sure there's a space before the title:
@@ -165,7 +165,7 @@ class CloseBracketParser extends AbstractInlineParser implements EnvironmentAwar
$title = LinkParserHelper::parseLinkTitle($cursor) ?: '';
}
- $cursor->advanceToFirstNonSpace();
+ $cursor->advanceToNextNonSpaceOrNewline();
if ($cursor->match('/^\\)/') === null) {
$cursor->restoreState($previousState);
@@ -215,8 +215,8 @@ class CloseBracketParser extends AbstractInlineParser implements EnvironmentAwar
{
if ($isImage) {
return new Image($url, null, $title);
- } else {
- return new Link($url, null, $title);
}
+
+ return new Link($url, null, $title);
}
}
diff --git a/vendor/league/commonmark/src/Inline/Parser/EmphasisParser.php b/vendor/league/commonmark/src/Inline/Parser/EmphasisParser.php
index f6d01dec11..72993e9457 100644
--- a/vendor/league/commonmark/src/Inline/Parser/EmphasisParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/EmphasisParser.php
@@ -29,10 +29,10 @@ class EmphasisParser extends AbstractInlineParser implements EnvironmentAwareInt
public function __construct(array $newConfig = [])
{
$this->config = new Configuration([
- 'use_asterisk' => true,
- 'use_underscore' => true,
- 'enable_em' => true,
- 'enable_strong' => true,
+ 'use_asterisk' => true,
+ 'use_underscore' => true,
+ 'enable_em' => true,
+ 'enable_strong' => true,
]);
$this->config->mergeConfig($newConfig);
}
@@ -131,8 +131,8 @@ class EmphasisParser extends AbstractInlineParser implements EnvironmentAwareInt
$beforeIsWhitespace = preg_match(RegexHelper::REGEX_UNICODE_WHITESPACE_CHAR, $charBefore);
$beforeIsPunctuation = preg_match(RegexHelper::REGEX_PUNCTUATION, $charBefore);
- $leftFlanking = !$afterIsWhitespace && !($afterIsPunctuation && !$beforeIsWhitespace && !$beforeIsPunctuation);
- $rightFlanking = !$beforeIsWhitespace && !($beforeIsPunctuation && !$afterIsWhitespace && !$afterIsPunctuation);
+ $leftFlanking = !$afterIsWhitespace && (!$afterIsPunctuation || $beforeIsWhitespace || $beforeIsPunctuation);
+ $rightFlanking = !$beforeIsWhitespace && (!$beforeIsPunctuation || $afterIsWhitespace || $afterIsPunctuation);
if ($character === '_') {
$canOpen = $leftFlanking && (!$rightFlanking || $beforeIsPunctuation);
diff --git a/vendor/league/commonmark/src/Inline/Parser/EntityParser.php b/vendor/league/commonmark/src/Inline/Parser/EntityParser.php
index 577e7a5a78..242f9ab516 100644
--- a/vendor/league/commonmark/src/Inline/Parser/EntityParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/EntityParser.php
@@ -36,7 +36,7 @@ class EntityParser extends AbstractInlineParser
*/
public function parse(InlineParserContext $inlineContext)
{
- if ($m = $inlineContext->getCursor()->match('/^' . RegexHelper::REGEX_ENTITY . '/i')) {
+ if ($m = $inlineContext->getCursor()->match('/^' . RegexHelper::PARTIAL_ENTITY . '/i')) {
$inlineContext->getContainer()->appendChild(new Text(Html5Entities::decodeEntity($m)));
return true;
diff --git a/vendor/league/commonmark/src/Inline/Parser/EscapableParser.php b/vendor/league/commonmark/src/Inline/Parser/EscapableParser.php
index 5c8b42dba7..bfd8802f07 100644
--- a/vendor/league/commonmark/src/Inline/Parser/EscapableParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/EscapableParser.php
@@ -49,7 +49,7 @@ class EscapableParser extends AbstractInlineParser
return true;
} elseif ($nextChar !== null &&
- preg_match('/' . RegexHelper::REGEX_ESCAPABLE . '/', $nextChar)
+ preg_match('/' . RegexHelper::PARTIAL_ESCAPABLE . '/', $nextChar)
) {
$cursor->advanceBy(2);
$inlineContext->getContainer()->appendChild(new Text($nextChar));
diff --git a/vendor/league/commonmark/src/Inline/Parser/HtmlInlineParser.php b/vendor/league/commonmark/src/Inline/Parser/HtmlInlineParser.php
index 02368ed6c4..c6db4f44d7 100644
--- a/vendor/league/commonmark/src/Inline/Parser/HtmlInlineParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/HtmlInlineParser.php
@@ -36,7 +36,7 @@ class HtmlInlineParser extends AbstractInlineParser
public function parse(InlineParserContext $inlineContext)
{
$cursor = $inlineContext->getCursor();
- if ($m = $cursor->match(RegexHelper::getInstance()->getHtmlTagRegex())) {
+ if ($m = $cursor->match('/^' . RegexHelper::PARTIAL_HTMLTAG . '/i')) {
$inlineContext->getContainer()->appendChild(new HtmlInline($m));
return true;
diff --git a/vendor/league/commonmark/src/Inline/Processor/EmphasisProcessor.php b/vendor/league/commonmark/src/Inline/Processor/EmphasisProcessor.php
index 797f6ec2d7..b6c6f9cb98 100644
--- a/vendor/league/commonmark/src/Inline/Processor/EmphasisProcessor.php
+++ b/vendor/league/commonmark/src/Inline/Processor/EmphasisProcessor.php
@@ -26,13 +26,7 @@ class EmphasisProcessor implements InlineProcessorInterface
{
$callback = function (Delimiter $opener, Delimiter $closer, DelimiterStack $stack) {
// Calculate actual number of delimiters used from this closer
- if ($closer->getNumDelims() < 3 || $opener->getNumDelims() < 3) {
- $useDelims = $closer->getNumDelims() <= $opener->getNumDelims()
- ? $closer->getNumDelims()
- : $opener->getNumDelims();
- } else {
- $useDelims = $closer->getNumDelims() % 2 === 0 ? 2 : 1;
- }
+ $useDelims = ($closer->getNumDelims() >= 2 && $opener->getNumDelims() >= 2) ? 2 : 1;
/** @var Text $openerInline */
$openerInline = $opener->getInlineNode();
/** @var Text $closerInline */
diff --git a/vendor/league/commonmark/src/Inline/Renderer/CodeRenderer.php b/vendor/league/commonmark/src/Inline/Renderer/CodeRenderer.php
index 5cf70f74ad..9c7794b5b3 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/CodeRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/CodeRenderer.php
@@ -18,6 +18,7 @@ use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
use League\CommonMark\Inline\Element\AbstractInline;
use League\CommonMark\Inline\Element\Code;
+use League\CommonMark\Util\Xml;
class CodeRenderer implements InlineRendererInterface
{
@@ -35,9 +36,9 @@ class CodeRenderer implements InlineRendererInterface
$attrs = [];
foreach ($inline->getData('attributes', []) as $key => $value) {
- $attrs[$key] = $htmlRenderer->escape($value, true);
+ $attrs[$key] = Xml::escape($value, true);
}
- return new HtmlElement('code', $attrs, $htmlRenderer->escape($inline->getContent()));
+ return new HtmlElement('code', $attrs, Xml::escape($inline->getContent()));
}
}
diff --git a/vendor/league/commonmark/src/Inline/Renderer/EmphasisRenderer.php b/vendor/league/commonmark/src/Inline/Renderer/EmphasisRenderer.php
index 8ccefbcd8e..9692c2b5e1 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/EmphasisRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/EmphasisRenderer.php
@@ -18,6 +18,7 @@ use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
use League\CommonMark\Inline\Element\AbstractInline;
use League\CommonMark\Inline\Element\Emphasis;
+use League\CommonMark\Util\Xml;
class EmphasisRenderer implements InlineRendererInterface
{
@@ -35,7 +36,7 @@ class EmphasisRenderer implements InlineRendererInterface
$attrs = [];
foreach ($inline->getData('attributes', []) as $key => $value) {
- $attrs[$key] = $htmlRenderer->escape($value, true);
+ $attrs[$key] = Xml::escape($value, true);
}
return new HtmlElement('em', $attrs, $htmlRenderer->renderInlines($inline->children()));
diff --git a/vendor/league/commonmark/src/Inline/Renderer/ImageRenderer.php b/vendor/league/commonmark/src/Inline/Renderer/ImageRenderer.php
index 6a7e18050d..25fca1ab6b 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/ImageRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/ImageRenderer.php
@@ -21,6 +21,7 @@ use League\CommonMark\Inline\Element\Image;
use League\CommonMark\Util\Configuration;
use League\CommonMark\Util\ConfigurationAwareInterface;
use League\CommonMark\Util\RegexHelper;
+use League\CommonMark\Util\Xml;
class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterface
{
@@ -43,14 +44,14 @@ class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterf
$attrs = [];
foreach ($inline->getData('attributes', []) as $key => $value) {
- $attrs[$key] = $htmlRenderer->escape($value, true);
+ $attrs[$key] = Xml::escape($value, true);
}
$forbidUnsafeLinks = $this->config->getConfig('safe') || !$this->config->getConfig('allow_unsafe_links');
if ($forbidUnsafeLinks && RegexHelper::isLinkPotentiallyUnsafe($inline->getUrl())) {
$attrs['src'] = '';
} else {
- $attrs['src'] = $htmlRenderer->escape($inline->getUrl(), true);
+ $attrs['src'] = Xml::escape($inline->getUrl(), true);
}
$alt = $htmlRenderer->renderInlines($inline->children());
@@ -58,7 +59,7 @@ class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterf
$attrs['alt'] = preg_replace('/\<[^>]*\>/', '', $alt);
if (isset($inline->data['title'])) {
- $attrs['title'] = $htmlRenderer->escape($inline->data['title'], true);
+ $attrs['title'] = Xml::escape($inline->data['title'], true);
}
return new HtmlElement('img', $attrs, '', true);
diff --git a/vendor/league/commonmark/src/Inline/Renderer/LinkRenderer.php b/vendor/league/commonmark/src/Inline/Renderer/LinkRenderer.php
index 54b32c59a6..293710b4d3 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/LinkRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/LinkRenderer.php
@@ -21,6 +21,7 @@ use League\CommonMark\Inline\Element\Link;
use League\CommonMark\Util\Configuration;
use League\CommonMark\Util\ConfigurationAwareInterface;
use League\CommonMark\Util\RegexHelper;
+use League\CommonMark\Util\Xml;
class LinkRenderer implements InlineRendererInterface, ConfigurationAwareInterface
{
@@ -43,16 +44,16 @@ class LinkRenderer implements InlineRendererInterface, ConfigurationAwareInterfa
$attrs = [];
foreach ($inline->getData('attributes', []) as $key => $value) {
- $attrs[$key] = $htmlRenderer->escape($value, true);
+ $attrs[$key] = Xml::escape($value, true);
}
$forbidUnsafeLinks = $this->config->getConfig('safe') || !$this->config->getConfig('allow_unsafe_links');
if (!($forbidUnsafeLinks && RegexHelper::isLinkPotentiallyUnsafe($inline->getUrl()))) {
- $attrs['href'] = $htmlRenderer->escape($inline->getUrl(), true);
+ $attrs['href'] = Xml::escape($inline->getUrl(), true);
}
if (isset($inline->data['title'])) {
- $attrs['title'] = $htmlRenderer->escape($inline->data['title'], true);
+ $attrs['title'] = Xml::escape($inline->data['title'], true);
}
return new HtmlElement('a', $attrs, $htmlRenderer->renderInlines($inline->children()));
diff --git a/vendor/league/commonmark/src/Inline/Renderer/NewlineRenderer.php b/vendor/league/commonmark/src/Inline/Renderer/NewlineRenderer.php
index 4a94c675a3..024abaeb55 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/NewlineRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/NewlineRenderer.php
@@ -35,8 +35,8 @@ class NewlineRenderer implements InlineRendererInterface
if ($inline->getType() === Newline::HARDBREAK) {
return new HtmlElement('br', [], '', true) . "\n";
- } else {
- return $htmlRenderer->getOption('soft_break', "\n");
}
+
+ return $htmlRenderer->getOption('soft_break', "\n");
}
}
diff --git a/vendor/league/commonmark/src/Inline/Renderer/StrongRenderer.php b/vendor/league/commonmark/src/Inline/Renderer/StrongRenderer.php
index 95234159c4..2ea6c4a52c 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/StrongRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/StrongRenderer.php
@@ -18,6 +18,7 @@ use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
use League\CommonMark\Inline\Element\AbstractInline;
use League\CommonMark\Inline\Element\Strong;
+use League\CommonMark\Util\Xml;
class StrongRenderer implements InlineRendererInterface
{
@@ -35,7 +36,7 @@ class StrongRenderer implements InlineRendererInterface
$attrs = [];
foreach ($inline->getData('attributes', []) as $key => $value) {
- $attrs[$key] = $htmlRenderer->escape($value, true);
+ $attrs[$key] = Xml::escape($value, true);
}
return new HtmlElement('strong', $attrs, $htmlRenderer->renderInlines($inline->children()));
diff --git a/vendor/league/commonmark/src/Inline/Renderer/TextRenderer.php b/vendor/league/commonmark/src/Inline/Renderer/TextRenderer.php
index 575c3bc028..dcd3cdea88 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/TextRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/TextRenderer.php
@@ -17,6 +17,7 @@ namespace League\CommonMark\Inline\Renderer;
use League\CommonMark\ElementRendererInterface;
use League\CommonMark\Inline\Element\AbstractInline;
use League\CommonMark\Inline\Element\Text;
+use League\CommonMark\Util\Xml;
class TextRenderer implements InlineRendererInterface
{
@@ -32,6 +33,6 @@ class TextRenderer implements InlineRendererInterface
throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
}
- return $htmlRenderer->escape($inline->getContent());
+ return Xml::escape($inline->getContent());
}
}
diff --git a/vendor/league/commonmark/src/InlineParserEngine.php b/vendor/league/commonmark/src/InlineParserEngine.php
index 926934d091..45deacaef3 100644
--- a/vendor/league/commonmark/src/InlineParserEngine.php
+++ b/vendor/league/commonmark/src/InlineParserEngine.php
@@ -51,12 +51,7 @@ class InlineParserEngine
*/
protected function parseCharacter($character, InlineParserContext $inlineParserContext)
{
- $matchingParsers = $this->environment->getInlineParsersForCharacter($character);
- if (empty($matchingParsers)) {
- return false;
- }
-
- foreach ($matchingParsers as $parser) {
+ foreach ($this->environment->getInlineParsersForCharacter($character) as $parser) {
if ($parser->parse($inlineParserContext)) {
return true;
}
diff --git a/vendor/league/commonmark/src/Node/Node.php b/vendor/league/commonmark/src/Node/Node.php
index fb8683c889..55be265333 100644
--- a/vendor/league/commonmark/src/Node/Node.php
+++ b/vendor/league/commonmark/src/Node/Node.php
@@ -7,6 +7,11 @@ use League\CommonMark\Util\ArrayCollection;
abstract class Node
{
/**
+ * @var int
+ */
+ protected $depth = 0;
+
+ /**
* @var Node|null
*/
protected $parent;
@@ -61,6 +66,7 @@ abstract class Node
protected function setParent(Node $node = null)
{
$this->parent = $node;
+ $this->depth = ($node === null) ? 0 : $node->depth + 1;
}
/**
@@ -129,6 +135,7 @@ abstract class Node
$this->parent = null;
$this->next = null;
$this->previous = null;
+ $this->depth = 0;
}
/**
@@ -226,6 +233,14 @@ abstract class Node
}
/**
+ * @return int
+ */
+ public function getDepth()
+ {
+ return $this->depth;
+ }
+
+ /**
* @return NodeWalker
*/
public function walker()
diff --git a/vendor/league/commonmark/src/Reference/Reference.php b/vendor/league/commonmark/src/Reference/Reference.php
index 2cf8cb8386..c150c2791e 100644
--- a/vendor/league/commonmark/src/Reference/Reference.php
+++ b/vendor/league/commonmark/src/Reference/Reference.php
@@ -85,7 +85,7 @@ class Reference
{
// Collapse internal whitespace to single space and remove
// leading/trailing whitespace
- $string = preg_replace('/\s+/', '', trim($string));
+ $string = preg_replace('/\s+/', ' ', trim($string));
return mb_strtoupper($string, 'UTF-8');
}
diff --git a/vendor/league/commonmark/src/Reference/ReferenceMap.php b/vendor/league/commonmark/src/Reference/ReferenceMap.php
index cd14b39a45..db2ceedcda 100644
--- a/vendor/league/commonmark/src/Reference/ReferenceMap.php
+++ b/vendor/league/commonmark/src/Reference/ReferenceMap.php
@@ -58,9 +58,11 @@ class ReferenceMap
{
$label = Reference::normalizeReference($label);
- if (isset($this->references[$label])) {
- return $this->references[$label];
+ if (!isset($this->references[$label])) {
+ return;
}
+
+ return $this->references[$label];
}
/**
diff --git a/vendor/league/commonmark/src/ReferenceParser.php b/vendor/league/commonmark/src/ReferenceParser.php
index f131bd5ea5..3324dd3f26 100644
--- a/vendor/league/commonmark/src/ReferenceParser.php
+++ b/vendor/league/commonmark/src/ReferenceParser.php
@@ -71,7 +71,7 @@ class ReferenceParser
$cursor->advance();
// Link URL
- $cursor->advanceToFirstNonSpace();
+ $cursor->advanceToNextNonSpaceOrNewline();
$destination = LinkParserHelper::parseLinkDestination($cursor);
if (empty($destination)) {
@@ -81,7 +81,7 @@ class ReferenceParser
}
$previousState = $cursor->saveState();
- $cursor->advanceToFirstNonSpace();
+ $cursor->advanceToNextNonSpaceOrNewline();
$title = LinkParserHelper::parseLinkTitle($cursor);
if ($title === null) {
diff --git a/vendor/league/commonmark/src/Util/ArrayCollection.php b/vendor/league/commonmark/src/Util/ArrayCollection.php
index 6d73b0cc1c..e2492636b9 100644
--- a/vendor/league/commonmark/src/Util/ArrayCollection.php
+++ b/vendor/league/commonmark/src/Util/ArrayCollection.php
@@ -93,11 +93,11 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
/**
* @param mixed $key
*
- * @return mixed
+ * @return mixed|null
*/
public function remove($key)
{
- if (!isset($this->elements[$key]) && !array_key_exists($key, $this->elements)) {
+ if (!array_key_exists($key, $this->elements)) {
return;
}
@@ -142,7 +142,7 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
*/
public function containsKey($key)
{
- return isset($this->elements[$key]) || array_key_exists($key, $this->elements);
+ return array_key_exists($key, $this->elements);
}
/**
@@ -189,7 +189,7 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
*/
public function offsetSet($offset, $value)
{
- if (!isset($offset)) {
+ if ($offset === null) {
$this->add($value);
} else {
$this->set($offset, $value);
diff --git a/vendor/league/commonmark/src/Util/Html5Entities.php b/vendor/league/commonmark/src/Util/Html5Entities.php
index c13d38e78b..d0509f719b 100644
--- a/vendor/league/commonmark/src/Util/Html5Entities.php
+++ b/vendor/league/commonmark/src/Util/Html5Entities.php
@@ -14,7 +14,7 @@
namespace League\CommonMark\Util;
-class Html5Entities
+final class Html5Entities
{
public static $entitiesByName = [
'Aacute' => 'Á',
@@ -2256,9 +2256,9 @@ class Html5Entities
if (substr($entity, 0, 2) === '&#') {
if (strtolower(substr($entity, 2, 1)) === 'x') {
return self::fromHex(substr($entity, 3, -1));
- } else {
- return self::fromDecimal(substr($entity, 2, -1));
}
+
+ return self::fromDecimal(substr($entity, 2, -1));
}
$name = substr($entity, 1, -1);
diff --git a/vendor/league/commonmark/src/Util/LinkParserHelper.php b/vendor/league/commonmark/src/Util/LinkParserHelper.php
index 31fc4ab089..116a921e5e 100644
--- a/vendor/league/commonmark/src/Util/LinkParserHelper.php
+++ b/vendor/league/commonmark/src/Util/LinkParserHelper.php
@@ -16,7 +16,7 @@ namespace League\CommonMark\Util;
use League\CommonMark\Cursor;
-class LinkParserHelper
+final class LinkParserHelper
{
/**
* Attempt to parse link destination
@@ -27,19 +27,45 @@ class LinkParserHelper
*/
public static function parseLinkDestination(Cursor $cursor)
{
- if ($res = $cursor->match(RegexHelper::getInstance()->getLinkDestinationBracesRegex())) {
+ if ($res = $cursor->match(RegexHelper::REGEX_LINK_DESTINATION_BRACES)) {
// Chop off surrounding <..>:
return UrlEncoder::unescapeAndEncode(
- RegexHelper::unescape(substr($res, 1, strlen($res) - 2))
+ RegexHelper::unescape(substr($res, 1, -1))
);
}
- $res = $cursor->match(RegexHelper::getInstance()->getLinkDestinationRegex());
- if ($res !== null) {
- return UrlEncoder::unescapeAndEncode(
- RegexHelper::unescape($res)
- );
+ $oldState = $cursor->saveState();
+ $openParens = 0;
+ while (($c = $cursor->getCharacter()) !== null) {
+ if ($c === '\\') {
+ $cursor->advanceBy(2);
+ } elseif ($c === '(') {
+ $cursor->advance();
+ $openParens++;
+ } elseif ($c === ')') {
+ if ($openParens < 1) {
+ break;
+ }
+
+ $cursor->advance();
+ $openParens--;
+ } elseif (preg_match(RegexHelper::REGEX_WHITESPACE_CHAR, $c)) {
+ break;
+ } else {
+ $cursor->advance();
+ }
}
+
+ $newPos = $cursor->getPosition();
+ $cursor->restoreState($oldState);
+
+ $cursor->advanceBy($newPos - $cursor->getPosition());
+
+ $res = $cursor->getPreviousText();
+
+ return UrlEncoder::unescapeAndEncode(
+ RegexHelper::unescape($res)
+ );
}
/**
@@ -49,11 +75,10 @@ class LinkParserHelper
*/
public static function parseLinkLabel(Cursor $cursor)
{
- $escapedChar = RegexHelper::getInstance()->getPartialRegex(RegexHelper::ESCAPED_CHAR);
- $match = $cursor->match('/^\[(?:[^\\\\\[\]]|' . $escapedChar . '|\\\\)*\]/');
+ $match = $cursor->match('/^\[(?:[^\\\\\[\]]|' . RegexHelper::PARTIAL_ESCAPED_CHAR . '|\\\\)*\]/');
$length = mb_strlen($match, 'utf-8');
- if ($match === null || $length > 1001) {
+ if ($match === null || $length > 1001 || preg_match('/[^\\\\]\\\\\]$/', $match)) {
return 0;
}
@@ -69,9 +94,9 @@ class LinkParserHelper
*/
public static function parseLinkTitle(Cursor $cursor)
{
- if ($title = $cursor->match(RegexHelper::getInstance()->getLinkTitleRegex())) {
+ if ($title = $cursor->match('/' . RegexHelper::PARTIAL_LINK_TITLE . '/')) {
// Chop off quotes from title and unescape
- return RegexHelper::unescape(substr($title, 1, strlen($title) - 2));
+ return RegexHelper::unescape(substr($title, 1, -1));
}
}
}
diff --git a/vendor/league/commonmark/src/Util/RegexHelper.php b/vendor/league/commonmark/src/Util/RegexHelper.php
index 269c47248a..4a8ea4b81f 100644
--- a/vendor/league/commonmark/src/Util/RegexHelper.php
+++ b/vendor/league/commonmark/src/Util/RegexHelper.php
@@ -17,42 +17,131 @@ namespace League\CommonMark\Util;
use League\CommonMark\Block\Element\HtmlBlock;
/**
- * Provides regular expressions and utilties for parsing Markdown
- *
- * Singletons are generally bad, but it allows us to build the regexes once (and only once).
+ * Provides regular expressions and utilities for parsing Markdown
*/
-class RegexHelper
+final class RegexHelper
{
+ /** @deprecated Use PARTIAL_ESCAPABLE instead */
const ESCAPABLE = 0;
+
+ /** @deprecated Use PARTIAL_ESCAPED_CHAR instead */
const ESCAPED_CHAR = 1;
+
+ /** @deprecated Use PARTIAL_IN_DOUBLE_QUOTES instead */
const IN_DOUBLE_QUOTES = 2;
+
+ /** @deprecated Use PARTIAL_IN_SINGLE_QUOTES instead */
const IN_SINGLE_QUOTES = 3;
+
+ /** @deprecated Use PARTIAL_IN_PARENS instead */
const IN_PARENS = 4;
+
+ /** @deprecated Use PARTIAL_REG_CHAR instead */
const REG_CHAR = 5;
+
+ /** @deprecated Use PARTIAL_IN_PARENS_NOSP instead */
const IN_PARENS_NOSP = 6;
+
+ /** @deprecated Use PARTIAL_TAGNAME instead */
const TAGNAME = 7;
+
+ /** @deprecated Use PARTIAL_BLOCKTAGNAME instead */
const BLOCKTAGNAME = 8;
+
+ /** @deprecated Use PARTIAL_ATTRIBUTENAME instead */
const ATTRIBUTENAME = 9;
+
+ /** @deprecated Use PARTIAL_UNQUOTEDVALUE instead */
const UNQUOTEDVALUE = 10;
+
+ /** @deprecated Use PARTIAL_SINGLEQUOTEDVALUE instead */
const SINGLEQUOTEDVALUE = 11;
+
+ /** @deprecated Use PARTIAL_DOUBLEQUOTEDVALUE instead */
const DOUBLEQUOTEDVALUE = 12;
+
+ /** @deprecated Use PARTIAL_ATTRIBUTEVALUE instead */
const ATTRIBUTEVALUE = 13;
+
+ /** @deprecated Use PARTIAL_ATTRIBUTEVALUESPEC instead */
const ATTRIBUTEVALUESPEC = 14;
+
+ /** @deprecated Use PARTIAL_ATTRIBUTE instead */
const ATTRIBUTE = 15;
+
+ /** @deprecated Use PARTIAL_OPENTAG instead */
const OPENTAG = 16;
+
+ /** @deprecated Use PARTIAL_CLOSETAG instead */
const CLOSETAG = 17;
+
+ /** @deprecated Use PARTIAL_OPENBLOCKTAG instead */
const OPENBLOCKTAG = 18;
+
+ /** @deprecated Use PARTIAL_CLOSEBLOCKTAG instead */
const CLOSEBLOCKTAG = 19;
+
+ /** @deprecated Use PARTIAL_HTMLCOMMENT instead */
const HTMLCOMMENT = 20;
+
+ /** @deprecated Use PARTIAL_PROCESSINGINSTRUCTION instead */
const PROCESSINGINSTRUCTION = 21;
+
+ /** @deprecated Use PARTIAL_DECLARATION instead */
const DECLARATION = 22;
+
+ /** @deprecated Use PARTIAL_CDATA instead */
const CDATA = 23;
+
+ /** @deprecated Use PARTIAL_HTMLTAG instead */
const HTMLTAG = 24;
+
+ /** @deprecated Use PARTIAL_HTMLBLOCKOPEN instead */
const HTMLBLOCKOPEN = 25;
+
+ /** @deprecated Use PARTIAL_LINK_TITLE instead */
const LINK_TITLE = 26;
- const REGEX_ESCAPABLE = '[!"#$%&\'()*+,.\/:;<=>?@[\\\\\]^_`{|}~-]';
- const REGEX_ENTITY = '&(?:#x[a-f0-9]{1,8}|#[0-9]{1,8}|[a-z][a-z0-9]{1,31});';
+ // Partial regular expressions (wrap with `/` on each side before use)
+ const PARTIAL_ENTITY = '&(?:#x[a-f0-9]{1,8}|#[0-9]{1,8}|[a-z][a-z0-9]{1,31});';
+ const PARTIAL_ESCAPABLE = '[!"#$%&\'()*+,.\/:;<=>?@[\\\\\]^_`{|}~-]';
+ const PARTIAL_ESCAPED_CHAR = '\\\\' . self::PARTIAL_ESCAPABLE;
+ const PARTIAL_IN_DOUBLE_QUOTES = '"(' . self::PARTIAL_ESCAPED_CHAR . '|[^"\x00])*"';
+ const PARTIAL_IN_SINGLE_QUOTES = '\'(' . self::PARTIAL_ESCAPED_CHAR . '|[^\'\x00])*\'';
+ const PARTIAL_IN_PARENS = '\\((' . self::PARTIAL_ESCAPED_CHAR . '|[^)\x00])*\\)';
+ const PARTIAL_REG_CHAR = '[^\\\\()\x00-\x20]';
+ const PARTIAL_IN_PARENS_NOSP = '\((' . self::PARTIAL_REG_CHAR . '|' . self::PARTIAL_ESCAPED_CHAR . '|\\\\)*\)';
+ const PARTIAL_TAGNAME = '[A-Za-z][A-Za-z0-9-]*';
+ const PARTIAL_BLOCKTAGNAME = '(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|title|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)';
+ const PARTIAL_ATTRIBUTENAME = '[a-zA-Z_:][a-zA-Z0-9:._-]*';
+ const PARTIAL_UNQUOTEDVALUE = '[^"\'=<>`\x00-\x20]+';
+ const PARTIAL_SINGLEQUOTEDVALUE = '\'[^\']*\'';
+ const PARTIAL_DOUBLEQUOTEDVALUE = '"[^"]*"';
+ const PARTIAL_ATTRIBUTEVALUE = '(?:' . self::PARTIAL_UNQUOTEDVALUE . '|' . self::PARTIAL_SINGLEQUOTEDVALUE . '|' . self::PARTIAL_DOUBLEQUOTEDVALUE . ')';
+ const PARTIAL_ATTRIBUTEVALUESPEC = '(?:' . '\s*=' . '\s*' . self::PARTIAL_ATTRIBUTEVALUE . ')';
+ const PARTIAL_ATTRIBUTE = '(?:' . '\s+' . self::PARTIAL_ATTRIBUTENAME . self::PARTIAL_ATTRIBUTEVALUESPEC . '?)';
+ const PARTIAL_OPENTAG = '<' . self::PARTIAL_TAGNAME . self::PARTIAL_ATTRIBUTE . '*' . '\s*\/?>';
+ const PARTIAL_CLOSETAG = '<\/' . self::PARTIAL_TAGNAME . '\s*[>]';
+ const PARTIAL_OPENBLOCKTAG = '<' . self::PARTIAL_BLOCKTAGNAME . self::PARTIAL_ATTRIBUTE . '*' . '\s*\/?>';
+ const PARTIAL_CLOSEBLOCKTAG = '<\/' . self::PARTIAL_BLOCKTAGNAME . '\s*[>]';
+ const PARTIAL_HTMLCOMMENT = '<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->';
+ const PARTIAL_PROCESSINGINSTRUCTION = '[<][?].*?[?][>]';
+ const PARTIAL_DECLARATION = '<![A-Z]+' . '\s+[^>]*>';
+ const PARTIAL_CDATA = '<!\[CDATA\[[\s\S]*?]\]>';
+ const PARTIAL_HTMLTAG = '(?:' . self::PARTIAL_OPENTAG . '|' . self::PARTIAL_CLOSETAG . '|' . self::PARTIAL_HTMLCOMMENT . '|' .
+ self::PARTIAL_PROCESSINGINSTRUCTION . '|' . self::PARTIAL_DECLARATION . '|' . self::PARTIAL_CDATA . ')';
+ const PARTIAL_HTMLBLOCKOPEN = '<(?:' . self::PARTIAL_BLOCKTAGNAME . '(?:[\s\/>]|$)' . '|' .
+ '\/' . self::PARTIAL_BLOCKTAGNAME . '(?:[\s>]|$)' . '|' . '[?!])';
+ const PARTIAL_LINK_TITLE = '^(?:"(' . self::PARTIAL_ESCAPED_CHAR . '|[^"\x00])*"' .
+ '|' . '\'(' . self::PARTIAL_ESCAPED_CHAR . '|[^\'\x00])*\'' .
+ '|' . '\((' . self::PARTIAL_ESCAPED_CHAR . '|[^)\x00])*\))';
+
+ /** @deprecated Use PARTIAL_ESCAPABLE instead */
+ const REGEX_ESCAPABLE = self::PARTIAL_ESCAPABLE;
+
+ /** @deprecated Use PARTIAL_ENTITY instead */
+ const REGEX_ENTITY = self::PARTIAL_ENTITY;
+
const REGEX_PUNCTUATION = '/^[\x{2000}-\x{206F}\x{2E00}-\x{2E7F}\p{Pc}\p{Pd}\p{Pe}\p{Pf}\p{Pi}\p{Po}\p{Ps}\\\\\'!"#\$%&\(\)\*\+,\-\.\\/:;<=>\?@\[\]\^_`\{\|\}~]/u';
const REGEX_UNSAFE_PROTOCOL = '/^javascript:|vbscript:|file:|data:/i';
const REGEX_SAFE_DATA_PROTOCOL = '/^data:image\/(?:png|gif|jpeg|webp)/i';
@@ -61,25 +150,23 @@ class RegexHelper
const REGEX_WHITESPACE_CHAR = '/^[ \t\n\x0b\x0c\x0d]/';
const REGEX_WHITESPACE = '/[ \t\n\x0b\x0c\x0d]+/';
const REGEX_UNICODE_WHITESPACE_CHAR = '/^\pZ|\s/u';
- const REGEX_UNICODE_WHITESPACE = '/\pZ|\s/u';
-
- protected $regex = [];
-
- protected static $instance;
+ const REGEX_THEMATIC_BREAK = '/^(?:(?:\*[ \t]*){3,}|(?:_[ \t]*){3,}|(?:-[ \t]*){3,})[ \t]*$/';
+ const REGEX_LINK_DESTINATION_BRACES = '/^(?:' . '[<](?:[^ <>\\t\\n\\\\\\x00]' . '|' . self::PARTIAL_ESCAPED_CHAR . '|' . '\\\\)*[>]' . ')/';
/**
- * Constructor
+ * @deprecated Instance methods will be removed in 0.18 or 1.0 (whichever comes first)
*/
- protected function __construct()
- {
- $this->buildRegexPatterns();
- }
+ protected static $instance;
/**
* @return RegexHelper
+ *
+ * @deprecated Instances are no longer needed and will be removed in 0.18 or 1.0
*/
public static function getInstance()
{
+ @trigger_error('RegexHelper no longer uses the singleton pattern. Directly grab the REGEX_ or PARTIAL_ constant you need instead.', E_USER_DEPRECATED);
+
if (self::$instance === null) {
self::$instance = new self();
}
@@ -88,49 +175,6 @@ class RegexHelper
}
/**
- * Builds the regular expressions required to parse Markdown
- *
- * We could hard-code them all as pre-built constants, but that would be more difficult to manage.
- */
- protected function buildRegexPatterns()
- {
- $regex = [];
- $regex[self::ESCAPABLE] = self::REGEX_ESCAPABLE;
- $regex[self::ESCAPED_CHAR] = '\\\\' . $regex[self::ESCAPABLE];
- $regex[self::IN_DOUBLE_QUOTES] = '"(' . $regex[self::ESCAPED_CHAR] . '|[^"\x00])*"';
- $regex[self::IN_SINGLE_QUOTES] = '\'(' . $regex[self::ESCAPED_CHAR] . '|[^\'\x00])*\'';
- $regex[self::IN_PARENS] = '\\((' . $regex[self::ESCAPED_CHAR] . '|[^)\x00])*\\)';
- $regex[self::REG_CHAR] = '[^\\\\()\x00-\x20]';
- $regex[self::IN_PARENS_NOSP] = '\((' . $regex[self::REG_CHAR] . '|' . $regex[self::ESCAPED_CHAR] . '|\\\\)*\)';
- $regex[self::TAGNAME] = '[A-Za-z][A-Za-z0-9-]*';
- $regex[self::BLOCKTAGNAME] = '(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|title|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)';
- $regex[self::ATTRIBUTENAME] = '[a-zA-Z_:][a-zA-Z0-9:._-]*';
- $regex[self::UNQUOTEDVALUE] = '[^"\'=<>`\x00-\x20]+';
- $regex[self::SINGLEQUOTEDVALUE] = '\'[^\']*\'';
- $regex[self::DOUBLEQUOTEDVALUE] = '"[^"]*"';
- $regex[self::ATTRIBUTEVALUE] = '(?:' . $regex[self::UNQUOTEDVALUE] . '|' . $regex[self::SINGLEQUOTEDVALUE] . '|' . $regex[self::DOUBLEQUOTEDVALUE] . ')';
- $regex[self::ATTRIBUTEVALUESPEC] = '(?:' . '\s*=' . '\s*' . $regex[self::ATTRIBUTEVALUE] . ')';
- $regex[self::ATTRIBUTE] = '(?:' . '\s+' . $regex[self::ATTRIBUTENAME] . $regex[self::ATTRIBUTEVALUESPEC] . '?)';
- $regex[self::OPENTAG] = '<' . $regex[self::TAGNAME] . $regex[self::ATTRIBUTE] . '*' . '\s*\/?>';
- $regex[self::CLOSETAG] = '<\/' . $regex[self::TAGNAME] . '\s*[>]';
- $regex[self::OPENBLOCKTAG] = '<' . $regex[self::BLOCKTAGNAME] . $regex[self::ATTRIBUTE] . '*' . '\s*\/?>';
- $regex[self::CLOSEBLOCKTAG] = '<\/' . $regex[self::BLOCKTAGNAME] . '\s*[>]';
- $regex[self::HTMLCOMMENT] = '<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->';
- $regex[self::PROCESSINGINSTRUCTION] = '[<][?].*?[?][>]';
- $regex[self::DECLARATION] = '<![A-Z]+' . '\s+[^>]*>';
- $regex[self::CDATA] = '<!\[CDATA\[[\s\S]*?]\]>';
- $regex[self::HTMLTAG] = '(?:' . $regex[self::OPENTAG] . '|' . $regex[self::CLOSETAG] . '|' . $regex[self::HTMLCOMMENT] . '|' .
- $regex[self::PROCESSINGINSTRUCTION] . '|' . $regex[self::DECLARATION] . '|' . $regex[self::CDATA] . ')';
- $regex[self::HTMLBLOCKOPEN] = '<(?:' . $regex[self::BLOCKTAGNAME] . '(?:[\s\/>]|$)' . '|' .
- '\/' . $regex[self::BLOCKTAGNAME] . '(?:[\s>]|$)' . '|' . '[?!])';
- $regex[self::LINK_TITLE] = '^(?:"(' . $regex[self::ESCAPED_CHAR] . '|[^"\x00])*"' .
- '|' . '\'(' . $regex[self::ESCAPED_CHAR] . '|[^\'\x00])*\'' .
- '|' . '\((' . $regex[self::ESCAPED_CHAR] . '|[^)\x00])*\))';
-
- $this->regex = $regex;
- }
-
- /**
* Returns a partial regex
*
* It'll need to be wrapped with /.../ before use
@@ -138,50 +182,90 @@ class RegexHelper
* @param int $const
*
* @return string
+ *
+ * @deprecated Just grab the constant directly
*/
public function getPartialRegex($const)
{
- return $this->regex[$const];
+ @trigger_error('RegexHelper no longer supports the getPartialRegex() function. Directly grab the PARTIAL_ constant you need instead.', E_USER_DEPRECATED);
+
+ switch ($const) {
+ case self::ESCAPABLE: return self::PARTIAL_ESCAPABLE;
+ case self::ESCAPED_CHAR: return self::PARTIAL_ESCAPED_CHAR;
+ case self::IN_DOUBLE_QUOTES: return self::PARTIAL_IN_DOUBLE_QUOTES;
+ case self::IN_SINGLE_QUOTES: return self::PARTIAL_IN_SINGLE_QUOTES;
+ case self::IN_PARENS: return self::PARTIAL_IN_PARENS;
+ case self::REG_CHAR: return self::PARTIAL_REG_CHAR;
+ case self::IN_PARENS_NOSP: return self::PARTIAL_IN_PARENS_NOSP;
+ case self::TAGNAME: return self::PARTIAL_TAGNAME;
+ case self::BLOCKTAGNAME: return self::PARTIAL_BLOCKTAGNAME;
+ case self::ATTRIBUTENAME: return self::PARTIAL_ATTRIBUTENAME;
+ case self::UNQUOTEDVALUE: return self::PARTIAL_UNQUOTEDVALUE;
+ case self::SINGLEQUOTEDVALUE: return self::PARTIAL_SINGLEQUOTEDVALUE;
+ case self::DOUBLEQUOTEDVALUE: return self::PARTIAL_DOUBLEQUOTEDVALUE;
+ case self::ATTRIBUTEVALUE: return self::PARTIAL_ATTRIBUTEVALUE;
+ case self::ATTRIBUTEVALUESPEC: return self::PARTIAL_ATTRIBUTEVALUESPEC;
+ case self::ATTRIBUTE: return self::PARTIAL_ATTRIBUTE;
+ case self::OPENTAG: return self::PARTIAL_OPENTAG;
+ case self::CLOSETAG: return self::PARTIAL_CLOSETAG;
+ case self::OPENBLOCKTAG: return self::PARTIAL_OPENBLOCKTAG;
+ case self::CLOSEBLOCKTAG: return self::PARTIAL_CLOSEBLOCKTAG;
+ case self::HTMLCOMMENT: return self::PARTIAL_HTMLCOMMENT;
+ case self::PROCESSINGINSTRUCTION: return self::PARTIAL_PROCESSINGINSTRUCTION;
+ case self::DECLARATION: return self::PARTIAL_DECLARATION;
+ case self::CDATA: return self::PARTIAL_CDATA;
+ case self::HTMLTAG: return self::PARTIAL_HTMLTAG;
+ case self::HTMLBLOCKOPEN: return self::PARTIAL_HTMLBLOCKOPEN;
+ case self::LINK_TITLE: return self::PARTIAL_LINK_TITLE;
+ }
}
/**
* @return string
+ *
+ * @deprecated Use PARTIAL_HTMLTAG and wrap it yourself instead
*/
public function getHtmlTagRegex()
{
- return '/^' . $this->regex[self::HTMLTAG] . '/i';
+ @trigger_error('RegexHelper::getHtmlTagRegex() has been deprecated. Use the RegexHelper::PARTIAL_HTMLTAG constant instead.', E_USER_DEPRECATED);
+
+ return '/^' . self::PARTIAL_HTMLTAG . '/i';
}
/**
* @return string
+ *
+ * @deprecated Use PARTIAL_LINK_TITLE and wrap it yourself instead
*/
public function getLinkTitleRegex()
{
- return '/' . $this->regex[self::LINK_TITLE] . '/';
- }
+ @trigger_error('RegexHelper::getLinkTitleRegex() has been deprecated. Use the RegexHelper::PARTIAL_LINK_TITLE constant instead.', E_USER_DEPRECATED);
- /**
- * @return string
- */
- public function getLinkDestinationRegex()
- {
- return '/^' . '(?:' . $this->regex[self::REG_CHAR] . '+|' . $this->regex[self::ESCAPED_CHAR] . '|\\\\|' . $this->regex[self::IN_PARENS_NOSP] . ')*' . '/';
+ return '/' . self::PARTIAL_LINK_TITLE . '/';
}
/**
* @return string
+ *
+ * @deprecated Use REGEX_LINK_DESTINATION_BRACES instead
*/
public function getLinkDestinationBracesRegex()
{
- return '/^(?:' . '[<](?:[^ <>\\t\\n\\\\\\x00]' . '|' . $this->regex[self::ESCAPED_CHAR] . '|' . '\\\\)*[>]' . ')/';
+ @trigger_error('RegexHelper::getLinkDestinationBracesRegex() has been deprecated. Use the RegexHelper::REGEX_LINK_DESTINATION_BRACES constant instead.', E_USER_DEPRECATED);
+
+ return self::REGEX_LINK_DESTINATION_BRACES;
}
/**
* @return string
+ *
+ * @deprecated Use the REGEX_THEMATIC_BREAK constant directly
*/
public function getThematicBreakRegex()
{
- return '/^(?:(?:\*[ \t]*){3,}|(?:_[ \t]*){3,}|(?:-[ \t]*){3,})[ \t]*$/';
+ @trigger_error('RegexHelper::getThematicBreakRegex() has been deprecated. Use the RegexHelper::REGEX_THEMATIC_BREAK constant instead.', E_USER_DEPRECATED);
+
+ return self::REGEX_THEMATIC_BREAK;
}
/**
@@ -247,10 +331,10 @@ class RegexHelper
*/
public static function unescape($string)
{
- $allEscapedChar = '/\\\\(' . self::REGEX_ESCAPABLE . ')/';
+ $allEscapedChar = '/\\\\(' . self::PARTIAL_ESCAPABLE . ')/';
$escaped = preg_replace($allEscapedChar, '$1', $string);
- $replaced = preg_replace_callback('/' . self::REGEX_ENTITY . '/i', function ($e) {
+ $replaced = preg_replace_callback('/' . self::PARTIAL_ENTITY . '/i', function ($e) {
return Html5Entities::decodeEntity($e[0]);
}, $escaped);
@@ -276,11 +360,9 @@ class RegexHelper
case HtmlBlock::TYPE_5_CDATA:
return '/^<!\[CDATA\[/';
case HtmlBlock::TYPE_6_BLOCK_ELEMENT:
- return '%^<[/]?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[123456]|head|header|hr|html|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|pre|section|source|title|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|[/]?[>]|$)%i';
+ return '%^<[/]?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[123456]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|title|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|[/]?[>]|$)%i';
case HtmlBlock::TYPE_7_MISC_ELEMENT:
- $self = self::getInstance();
-
- return '/^(?:' . $self->getPartialRegex(self::OPENTAG) . '|' . $self->getPartialRegex(self::CLOSETAG) . ')\\s*$/i';
+ return '/^(?:' . self::PARTIAL_OPENTAG . '|' . self::PARTIAL_CLOSETAG . ')\\s*$/i';
}
}
diff --git a/vendor/league/commonmark/src/Util/UrlEncoder.php b/vendor/league/commonmark/src/Util/UrlEncoder.php
index 8d4fcfbdd4..67682ca15a 100644
--- a/vendor/league/commonmark/src/Util/UrlEncoder.php
+++ b/vendor/league/commonmark/src/Util/UrlEncoder.php
@@ -14,7 +14,7 @@
namespace League\CommonMark\Util;
-class UrlEncoder
+final class UrlEncoder
{
protected static $dontEncode = [
'%21' => '!',
@@ -48,6 +48,53 @@ class UrlEncoder
{
$decoded = html_entity_decode($uri);
- return strtr(rawurlencode(rawurldecode($decoded)), self::$dontEncode);
+ return self::encode(self::decode($decoded));
+ }
+
+ /**
+ * Decode a percent-encoded URI
+ *
+ * @param string $uri
+ *
+ * @return string
+ */
+ private static function decode($uri)
+ {
+ return preg_replace_callback('/%([0-9a-f]{2})/iu', function ($matches) {
+ // Convert percent-encoded codes to uppercase
+ $upper = strtoupper($matches[0]);
+ // Keep excluded characters as-is
+ if (array_key_exists($upper, self::$dontEncode)) {
+ return $upper;
+ }
+
+ // Otherwise, return the character for this codepoint
+ return chr(hexdec($matches[1]));
+ }, $uri);
+ }
+
+ /**
+ * Encode a URI, preserving already-encoded and excluded characters
+ *
+ * @param string $uri
+ *
+ * @return string
+ */
+ private static function encode($uri)
+ {
+ return preg_replace_callback('/(%[0-9a-f]{2})|./iu', function ($matches) {
+ // Keep already-encoded characters as-is
+ if (count($matches) > 1) {
+ return $matches[0];
+ }
+
+ // Keep excluded characters as-is
+ if (in_array($matches[0], self::$dontEncode)) {
+ return $matches[0];
+ }
+
+ // Otherwise, encode the character
+ return rawurlencode($matches[0]);
+ }, $uri);
}
}
diff --git a/vendor/league/commonmark/src/Util/Xml.php b/vendor/league/commonmark/src/Util/Xml.php
new file mode 100644
index 0000000000..7407d9ca31
--- /dev/null
+++ b/vendor/league/commonmark/src/Util/Xml.php
@@ -0,0 +1,38 @@
+<?php
+
+/*
+ * This file is part of the league/commonmark package.
+ *
+ * (c) Colin O'Dell <colinodell@gmail.com>
+ *
+ * Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
+ * - (c) John MacFarlane
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace League\CommonMark\Util;
+
+/**
+ * Utility class for handling/generating XML and HTML
+ */
+final class Xml
+{
+ /**
+ * @param string $string
+ * @param bool $preserveEntities
+ *
+ * @return string
+ */
+ public static function escape($string, $preserveEntities = false)
+ {
+ if ($preserveEntities) {
+ $string = preg_replace('/[&](?![#](x[a-f0-9]{1,8}|[0-9]{1,8});|[a-z][a-z0-9]{1,31};)/i', '&amp;', $string);
+ } else {
+ $string = str_replace('&', '&amp;', $string);
+ }
+
+ return str_replace(['<', '>', '"'], ['&lt;', '&gt;', '&quot;'], $string);
+ }
+}
diff --git a/vendor/webuni/commonmark-table-extension/CHANGELOG.md b/vendor/webuni/commonmark-table-extension/CHANGELOG.md
index 2cd7a7051b..a011863e7d 100644
--- a/vendor/webuni/commonmark-table-extension/CHANGELOG.md
+++ b/vendor/webuni/commonmark-table-extension/CHANGELOG.md
@@ -1,6 +1,14 @@
CHANGELOG
=========
+0.7.0 (2018-01-09)
+------------------
+
+ * Increased minimum PHP version to 5.6
+ * Removed support for commonmark 0.14 and 0.15 API
+ * Updated to the commonmark 0.16 and 0.17 API
+ * Fix a problem with parsing whitespaces at the end of line
+
0.6.1 (2017-01-11)
------------------
diff --git a/vendor/webuni/commonmark-table-extension/composer.json b/vendor/webuni/commonmark-table-extension/composer.json
index 155a21edb5..3c5814526c 100644
--- a/vendor/webuni/commonmark-table-extension/composer.json
+++ b/vendor/webuni/commonmark-table-extension/composer.json
@@ -8,8 +8,7 @@
"authors": [
{
"name": "Martin Hasoň",
- "email": "martin.hason@gmail.com",
- "role": "Lead Developer"
+ "email": "martin.hason@gmail.com"
},
{
"name": "Webuni s.r.o.",
@@ -17,14 +16,13 @@
}
],
"require": {
- "php": "^5.5|^7.0",
- "league/commonmark": "^0.14|^0.15"
+ "php": "^5.6|^7.0",
+ "league/commonmark": "^0.16|^0.17"
},
"require-dev": {
- "phpunit/phpunit": "^4.3|^5.0",
- "friendsofphp/php-cs-fixer": "^1.9",
- "sllh/php-cs-fixer-styleci-bridge": "^2.0",
- "symfony/var-dumper": "^2.7|^3.0"
+ "phpunit/phpunit": "^5.4|^6.0",
+ "friendsofphp/php-cs-fixer": "^2.9",
+ "symfony/var-dumper": "^3.0|^4.0"
},
"autoload": {
"psr-4": {
diff --git a/vendor/webuni/commonmark-table-extension/src/TableParser.php b/vendor/webuni/commonmark-table-extension/src/TableParser.php
index 1391ceeca3..9519a638a9 100644
--- a/vendor/webuni/commonmark-table-extension/src/TableParser.php
+++ b/vendor/webuni/commonmark-table-extension/src/TableParser.php
@@ -21,7 +21,7 @@ use League\CommonMark\Util\RegexHelper;
class TableParser extends AbstractBlockParser
{
const REGEXP_DEFINITION = '/(?: *(:?) *-+ *(:?) *)+(?=\||$)/';
- const REGEXP_CELLS = '/(?:`[^`]*`|\\\\\\\\|\\\\\||[^|`\\\\]+)+(?=\||$)/';
+ const REGEXP_CELLS = '/(?:`[^`]*`|\\\\\||\\\\|[^|`\\\\]+)+(?=\||$)/';
const REGEXP_CAPTION = '/^\[(.+?)\](?:\[(.+)\])?\s*$/';
public function parse(ContextInterface $context, Cursor $cursor)
@@ -37,7 +37,9 @@ class TableParser extends AbstractBlockParser
return false;
}
- $match = RegexHelper::matchAll(self::REGEXP_DEFINITION, $cursor->getLine(), $cursor->getFirstNonSpacePosition());
+ $expressionOffset = $cursor->getNextNonSpacePosition();
+
+ $match = RegexHelper::matchAll(self::REGEXP_DEFINITION, $cursor->getLine(), $expressionOffset);
if (null === $match) {
return false;
}
@@ -97,7 +99,7 @@ class TableParser extends AbstractBlockParser
} elseif (isset($match[2][$i]) && $match[2][$i]) {
$columns[] = TableCell::ALIGN_RIGHT;
} else {
- $columns[] = null;
+ $columns[] = '';
}
}
@@ -114,6 +116,10 @@ class TableParser extends AbstractBlockParser
$row = new TableRow();
foreach ((array) $cells[0] as $i => $cell) {
+ if (!isset($columns[$i])) {
+ return $row;
+ }
+
$row->appendChild(new TableCell(trim($cell), $type, isset($columns[$i]) ? $columns[$i] : null));
}