summaryrefslogtreecommitdiff
path: root/vendor/league/commonmark
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-07-15 11:08:16 +0100
committerGreg Roach <fisharebest@webtrees.net>2019-07-16 10:52:40 +0100
commit4a1f1d433794f86f893b59883147e57af4e94374 (patch)
tree5cb9572b1be24c130a5b8a86b0e1672f822cdfc4 /vendor/league/commonmark
parent22cfa91cf34e9677c2d99c712c2fc9e1c2c8f741 (diff)
downloadwebtrees-4a1f1d433794f86f893b59883147e57af4e94374.tar.gz
webtrees-4a1f1d433794f86f893b59883147e57af4e94374.tar.bz2
webtrees-4a1f1d433794f86f893b59883147e57af4e94374.zip
Package webuni/commonmark-table-extension is abandoned, you should avoid using it. Use league/commonmark-ext-table instead.
Diffstat (limited to 'vendor/league/commonmark')
-rw-r--r--vendor/league/commonmark/.github/ISSUE_TEMPLATE/1_Bug_report.md19
-rw-r--r--vendor/league/commonmark/.github/ISSUE_TEMPLATE/2_Feature_request.md12
-rw-r--r--vendor/league/commonmark/.github/ISSUE_TEMPLATE/3_Security_issue.md11
-rw-r--r--vendor/league/commonmark/.phpstorm.meta.php30
-rw-r--r--vendor/league/commonmark/.styleci.yml13
-rw-r--r--vendor/league/commonmark/CHANGELOG.md90
-rw-r--r--vendor/league/commonmark/CONTRIBUTING.md32
-rw-r--r--vendor/league/commonmark/README.md67
-rw-r--r--vendor/league/commonmark/UPGRADE.md91
-rw-r--r--vendor/league/commonmark/composer.json35
-rw-r--r--vendor/league/commonmark/src/Block/Element/AbstractBlock.php103
-rw-r--r--vendor/league/commonmark/src/Block/Element/AbstractStringContainerBlock.php59
-rw-r--r--vendor/league/commonmark/src/Block/Element/BlockQuote.php18
-rw-r--r--vendor/league/commonmark/src/Block/Element/Document.php20
-rw-r--r--vendor/league/commonmark/src/Block/Element/FencedCode.php50
-rw-r--r--vendor/league/commonmark/src/Block/Element/Heading.php30
-rw-r--r--vendor/league/commonmark/src/Block/Element/HtmlBlock.php33
-rw-r--r--vendor/league/commonmark/src/Block/Element/IndentedCode.php34
-rw-r--r--vendor/league/commonmark/src/Block/Element/InlineContainer.php10
-rw-r--r--vendor/league/commonmark/src/Block/Element/InlineContainerInterface.php16
-rw-r--r--vendor/league/commonmark/src/Block/Element/ListBlock.php28
-rw-r--r--vendor/league/commonmark/src/Block/Element/ListData.php4
-rw-r--r--vendor/league/commonmark/src/Block/Element/ListItem.php22
-rw-r--r--vendor/league/commonmark/src/Block/Element/Paragraph.php35
-rw-r--r--vendor/league/commonmark/src/Block/Element/StringContainerInterface.php40
-rw-r--r--vendor/league/commonmark/src/Block/Element/ThematicBreak.php16
-rw-r--r--vendor/league/commonmark/src/Block/Parser/ATXHeadingParser.php12
-rw-r--r--vendor/league/commonmark/src/Block/Parser/AbstractBlockParser.php25
-rw-r--r--vendor/league/commonmark/src/Block/Parser/BlockParserInterface.php7
-rw-r--r--vendor/league/commonmark/src/Block/Parser/BlockQuoteParser.php4
-rw-r--r--vendor/league/commonmark/src/Block/Parser/FencedCodeParser.php10
-rw-r--r--vendor/league/commonmark/src/Block/Parser/HtmlBlockParser.php4
-rw-r--r--vendor/league/commonmark/src/Block/Parser/IndentedCodeParser.php4
-rw-r--r--vendor/league/commonmark/src/Block/Parser/LazyParagraphParser.php4
-rw-r--r--vendor/league/commonmark/src/Block/Parser/ListParser.php24
-rw-r--r--vendor/league/commonmark/src/Block/Parser/SetExtHeadingParser.php39
-rw-r--r--vendor/league/commonmark/src/Block/Parser/ThematicBreakParser.php4
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/BlockQuoteRenderer.php10
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/BlockRendererInterface.php4
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/DocumentRenderer.php4
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/FencedCodeRenderer.php13
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/HeadingRenderer.php10
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/HtmlBlockRenderer.php12
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/IndentedCodeRenderer.php9
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/ListBlockRenderer.php10
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/ListItemRenderer.php14
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/ParagraphRenderer.php10
-rw-r--r--vendor/league/commonmark/src/Block/Renderer/ThematicBreakRenderer.php10
-rw-r--r--vendor/league/commonmark/src/CommonMarkConverter.php13
-rw-r--r--vendor/league/commonmark/src/ConfigurableEnvironmentInterface.php104
-rw-r--r--vendor/league/commonmark/src/Context.php46
-rw-r--r--vendor/league/commonmark/src/ContextInterface.php38
-rw-r--r--vendor/league/commonmark/src/Converter.php4
-rw-r--r--vendor/league/commonmark/src/ConverterInterface.php2
-rw-r--r--vendor/league/commonmark/src/Cursor.php86
-rw-r--r--vendor/league/commonmark/src/Delimiter/Delimiter.php38
-rw-r--r--vendor/league/commonmark/src/Delimiter/DelimiterStack.php26
-rw-r--r--vendor/league/commonmark/src/DocParser.php55
-rw-r--r--vendor/league/commonmark/src/ElementRendererInterface.php10
-rw-r--r--vendor/league/commonmark/src/Environment.php368
-rw-r--r--vendor/league/commonmark/src/EnvironmentAwareInterface.php4
-rw-r--r--vendor/league/commonmark/src/EnvironmentInterface.php78
-rw-r--r--vendor/league/commonmark/src/Extension/CommonMarkCoreExtension.php123
-rw-r--r--vendor/league/commonmark/src/Extension/Extension.php73
-rw-r--r--vendor/league/commonmark/src/Extension/ExtensionInterface.php53
-rw-r--r--vendor/league/commonmark/src/Extension/MiscExtension.php199
-rw-r--r--vendor/league/commonmark/src/HtmlElement.php42
-rw-r--r--vendor/league/commonmark/src/HtmlRenderer.php48
-rw-r--r--vendor/league/commonmark/src/Inline/Element/AbstractInline.php4
-rw-r--r--vendor/league/commonmark/src/Inline/Element/AbstractInlineContainer.php2
-rw-r--r--vendor/league/commonmark/src/Inline/Element/AbstractStringContainer.php6
-rw-r--r--vendor/league/commonmark/src/Inline/Element/AbstractWebResource.php6
-rw-r--r--vendor/league/commonmark/src/Inline/Element/Image.php10
-rw-r--r--vendor/league/commonmark/src/Inline/Element/Link.php6
-rw-r--r--vendor/league/commonmark/src/Inline/Element/Newline.php5
-rw-r--r--vendor/league/commonmark/src/Inline/Element/Text.php2
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/AbstractInlineParser.php32
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/AutolinkParser.php10
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/BacktickParser.php18
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/BangParser.php6
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/CloseBracketParser.php30
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/EmphasisParser.php22
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/EntityParser.php6
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/EscapableParser.php8
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/HtmlInlineParser.php6
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/InlineParserInterface.php13
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/NewlineParser.php10
-rw-r--r--vendor/league/commonmark/src/Inline/Parser/OpenBracketParser.php6
-rw-r--r--vendor/league/commonmark/src/Inline/Processor/EmphasisProcessor.php4
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/CodeRenderer.php7
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/EmphasisRenderer.php8
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/HtmlInlineRenderer.php8
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/ImageRenderer.php16
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/InlineRendererInterface.php2
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/LinkRenderer.php12
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/NewlineRenderer.php2
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/StrongRenderer.php8
-rw-r--r--vendor/league/commonmark/src/Inline/Renderer/TextRenderer.php2
-rw-r--r--vendor/league/commonmark/src/InlineParserContext.php13
-rw-r--r--vendor/league/commonmark/src/InlineParserEngine.php6
-rw-r--r--vendor/league/commonmark/src/Node/Node.php28
-rw-r--r--vendor/league/commonmark/src/Node/NodeWalker.php8
-rw-r--r--vendor/league/commonmark/src/Node/NodeWalkerEvent.php4
-rw-r--r--vendor/league/commonmark/src/Reference/Reference.php14
-rw-r--r--vendor/league/commonmark/src/Reference/ReferenceMap.php10
-rw-r--r--vendor/league/commonmark/src/ReferenceParser.php14
-rw-r--r--vendor/league/commonmark/src/UnmatchedBlockCloser.php3
-rw-r--r--vendor/league/commonmark/src/Util/ArrayCollection.php36
-rw-r--r--vendor/league/commonmark/src/Util/Configuration.php12
-rw-r--r--vendor/league/commonmark/src/Util/Html5Entities.php22
-rw-r--r--vendor/league/commonmark/src/Util/LinkParserHelper.php91
-rw-r--r--vendor/league/commonmark/src/Util/PrioritizedList.php53
-rw-r--r--vendor/league/commonmark/src/Util/RegexHelper.php182
-rw-r--r--vendor/league/commonmark/src/Util/UrlEncoder.php24
-rw-r--r--vendor/league/commonmark/src/Util/Xml.php15
115 files changed, 1512 insertions, 1871 deletions
diff --git a/vendor/league/commonmark/.github/ISSUE_TEMPLATE/1_Bug_report.md b/vendor/league/commonmark/.github/ISSUE_TEMPLATE/1_Bug_report.md
deleted file mode 100644
index 323e9a541e..0000000000
--- a/vendor/league/commonmark/.github/ISSUE_TEMPLATE/1_Bug_report.md
+++ /dev/null
@@ -1,19 +0,0 @@
----
-name: 🐛 Bug Report
-about: Report errors and problems
-
----
-
-**Version(s) affected**: x.y.z
-
-**Description**
-<!-- A clear and concise description of the problem. -->
-
-**How to reproduce**
-<!-- Markdown and/or config needed to reproduce the problem. -->
-
-**Possible Solution**
-<!--- Optional: only if you have suggestions on a fix/reason for the bug -->
-
-**Additional context**
-<!-- Optional: any other context about the problem: log messages, screenshots, etc. -->
diff --git a/vendor/league/commonmark/.github/ISSUE_TEMPLATE/2_Feature_request.md b/vendor/league/commonmark/.github/ISSUE_TEMPLATE/2_Feature_request.md
deleted file mode 100644
index 066ad8b36b..0000000000
--- a/vendor/league/commonmark/.github/ISSUE_TEMPLATE/2_Feature_request.md
+++ /dev/null
@@ -1,12 +0,0 @@
----
-name: 🚀 Feature Request
-about: RFC and ideas for new features and improvements
-
----
-
-**Description**
-<!-- A clear and concise description of the new feature. -->
-
-**Example**
-<!-- A simple example of the new feature in action (include PHP code, sample Markdown, etc.)
- If the new feature changes an existing feature, include a simple before/after comparison. -->
diff --git a/vendor/league/commonmark/.github/ISSUE_TEMPLATE/3_Security_issue.md b/vendor/league/commonmark/.github/ISSUE_TEMPLATE/3_Security_issue.md
deleted file mode 100644
index 544ebb5d4c..0000000000
--- a/vendor/league/commonmark/.github/ISSUE_TEMPLATE/3_Security_issue.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-name: ⛔ Security Issue
-about: See the README instructions for reporting security issues
-
----
-
-⚠ PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY, SEE BELOW.
-
-If you have found a security issue in Symfony, please send the details to
-colinodell [at] gmail.com and don't disclose it publicly until we can provide a
-fix for it.
diff --git a/vendor/league/commonmark/.phpstorm.meta.php b/vendor/league/commonmark/.phpstorm.meta.php
new file mode 100644
index 0000000000..1089f48a37
--- /dev/null
+++ b/vendor/league/commonmark/.phpstorm.meta.php
@@ -0,0 +1,30 @@
+<?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 PHPSTORM_META
+{
+ expectedArguments(\League\CommonMark\Context::setEncoding(), 0, 'UTF-8', 'ASCII', 'ISO-8859-1');
+ expectedArguments(\League\CommonMark\Cursor::__construct(), 1, 'UTF-8', 'ASCII', 'ISO-8859-1');
+ expectedArguments(\League\CommonMark\HtmlElement::__construct(), 0, 'a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kdb', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'pre', 'progress', 'q', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr');
+ expectedArguments(\League\CommonMark\Block\Element\Heading::__construct(), 0, 1, 2, 3, 4, 5, 6);
+ expectedReturnValues(\League\CommonMark\Block\Element\Heading::getLevel(), 1, 2, 3, 4, 5, 6);
+
+ registerArgumentsSet('league_commonmark_htmlblock_types', \League\CommonMark\Block\Element\HtmlBlock::TYPE_1_CODE_CONTAINER, \League\CommonMark\Block\Element\HtmlBlock::TYPE_2_COMMENT, \League\CommonMark\Block\Element\HtmlBlock::TYPE_3, \League\CommonMark\Block\Element\HtmlBlock::TYPE_4, \League\CommonMark\Block\Element\HtmlBlock::TYPE_5_CDATA, \League\CommonMark\Block\Element\HtmlBlock::TYPE_6_BLOCK_ELEMENT, \League\CommonMark\Block\Element\HtmlBlock::TYPE_7_MISC_ELEMENT);
+ expectedArguments(\League\CommonMark\Block\Element\HtmlBlock::__construct(), 0, argumentsSet('league_commonmark_htmlblock_types'));
+ expectedArguments(\League\CommonMark\Block\Element\HtmlBlock::setType(), 0, argumentsSet('league_commonmark_htmlblock_types'));
+ expectedReturnValues(\League\CommonMark\Block\Element\HtmlBlock::getType(), argumentsSet('league_commonmark_htmlblock_types'));
+ expectedArguments(\League\CommonMark\Util\RegexHelper::getHtmlBlockOpenRegex(), 0, argumentsSet('league_commonmark_htmlblock_types'));
+ expectedArguments(\League\CommonMark\Util\RegexHelper::getHtmlBlockCloseRegex(), 0, argumentsSet('league_commonmark_htmlblock_types'));
+
+ registerArgumentsSet('league_commonmark_newline_types', \League\CommonMark\Inline\Element\Newline::HARDBREAK, \League\CommonMark\Inline\Element\Newline::SOFTBREAK);
+ expectedArguments(\League\CommonMark\Inline\Element\Newline::__construct(), 0, argumentsSet('league_commonmark_newline_types'));
+ expectedReturnValues(\League\CommonMark\Inline\Element\Newline::getType(), argumentsSet('league_commonmark_newline_types'));
+}
diff --git a/vendor/league/commonmark/.styleci.yml b/vendor/league/commonmark/.styleci.yml
deleted file mode 100644
index af9054cd43..0000000000
--- a/vendor/league/commonmark/.styleci.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-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 ef43d9c743..17b2335049 100644
--- a/vendor/league/commonmark/CHANGELOG.md
+++ b/vendor/league/commonmark/CHANGELOG.md
@@ -1,9 +1,91 @@
# Change Log
All notable changes to this project will be documented in this file.
-Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
+Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
## [Unreleased][unreleased]
+## [0.19.3] - 2019-06-18
+
+### Fixed
+
+ - Fixed bug where elements with content of `"0"` wouldn't be rendered (#376)
+
+## [0.19.2] - 2019-05-19
+
+### Fixed
+
+ - Fixed bug where default values for nested configuration paths were inadvertently cast to strings
+
+## [0.19.1] - 2019-04-10
+
+### Added
+
+ - Added the missing `addExtension()` method to the new `ConfigurableEnvironmentInterface`
+
+### Fixed
+
+ - Fixed extensions not being able to register other extensions
+
+## [0.19.0] - 2019-04-10
+
+### Added
+
+ - The priority of parsers, processors, and renderers can now be set when `add()`ing them; you no longer need to rely on the order in which they are added
+ - Added support for trying multiple parsers per block/inline
+ - Extracted two new base interfaces from `Environment`:
+ - `EnvironmentInterface`
+ - `ConfigurableEnvironmentInterface`
+ - Extracted a new `AbstractStringContainerBlock` base class and corresponding `StringContainerInterface` from `AbstractBlock`
+ - Added `Cursor::getEncoding()` method
+ - Added `.phpstorm.meta.php` file for better IDE code completion
+ - Made some minor optimizations here and there
+
+### Changed
+
+ - Pretty much everything now has parameter and return types (#346)
+ - Attributes passed to `HtmlElement` will now be escaped by default
+ - `Environment` is now a `final` class
+ - `Environment::getBlockRendererForClass()` was replaced with `Environment::getBlockRenderersForClass()` (note the added `s`)
+ - `Environment::getInlineRendererForClass()` was replaced with `Environment::getInlineRenderersForClass()` (note the added `s`)
+ - The `Environment::get____()` methods now return an iterator instead of an array
+ - `Context::addBlock()` no longer returns the same block instance you passed into the method, as this served no useful purpose
+ - `RegexHelper::isEscapable()` no longer accepts `null` values
+ - `Node::replaceChildren()` now accepts any type of `iterable`, not just `array`s
+ - Some block elements now extend `AbstractStringContainerBlock` instead of `AbstractBlock`
+ - `InlineContainerInterface` now extends the new `StringContainerInterface`
+ - The `handleRemainingContents()` method (formerly on `AbstractBlock`, now on `AbstractStringContainerBlock`) is now an `abstract method
+ - The `InlineParserContext` constructor now requires an `AbstractStringContainerBlock` instead of an `AbstractBlock`
+
+### Removed
+
+ - Removed support for PHP 5.6 and 7.0 (#346)
+ - Removed support for `add()`ing parsers with just the target block/inline class name - you need to include the full namespace now
+ - Removed the following unused methods from `Environment`:
+ - `getInlineParser($name)`
+ - `getInlineParsers()`
+ - `createInlineParserEngine()`
+ - Removed the unused `getName()` methods:
+ - `AbstractBlockParser::getName()`
+ - `AbstractInlineParser::getName()`
+ - `BlockParserInterface::getName()`
+ - `InlinerParserInterface::getName()`
+ - Removed the now-useless classes:
+ - `AbstractBlockParser`
+ - `AbstractInlinerParser`
+ - `InlineContainer`
+ - Removed the `AbstractBlock::acceptsLines()` method
+ - Removed the now-useless constructor from `AbstractBlock`
+ - Removed previously-deprecated functionality:
+ - `InlineContainer` class
+ - `RegexHelper::$instance`
+ - `RegexHelper::getInstance()`
+ - `RegexHelper::getPartialRegex()`
+ - `RegexHelper::getHtmlTagRegex()`
+ - `RegexHelper::getLinkTitleRegex()`
+ - `RegexHelper::getLinkDestinationBracesRegex()`
+ - `RegexHelper::getThematicBreakRegex()`
+ - Removed the second `$preserveEntities` parameter from `Xml:escape()`
+
## [0.18.5] - 2019-03-28
### Fixed
@@ -708,7 +790,11 @@ An unused constant and static method were deprecated and will be removed in a fu
### Added
- Initial commit (compatible with jgm/stmd:spec.txt @ 0275f34)
-[unreleased]: https://github.com/thephpleague/commonmark/compare/0.18.5...HEAD
+[unreleased]: https://github.com/thephpleague/commonmark/compare/0.19.3...HEAD
+[0.19.3]: https://github.com/thephpleague/commonmark/compare/0.19.2...0.19.3
+[0.19.2]: https://github.com/thephpleague/commonmark/compare/0.19.1...0.19.2
+[0.19.1]: https://github.com/thephpleague/commonmark/compare/0.19.0...0.19.1
+[0.19.0]: https://github.com/thephpleague/commonmark/compare/0.18.5...0.19.0
[0.18.5]: https://github.com/thephpleague/commonmark/compare/0.18.4...0.18.5
[0.18.4]: https://github.com/thephpleague/commonmark/compare/0.18.3...0.18.4
[0.18.3]: https://github.com/thephpleague/commonmark/compare/0.18.2...0.18.3
diff --git a/vendor/league/commonmark/CONTRIBUTING.md b/vendor/league/commonmark/CONTRIBUTING.md
deleted file mode 100644
index 7e934f5b73..0000000000
--- a/vendor/league/commonmark/CONTRIBUTING.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# Contributing
-
-Contributions are **welcome** and will be fully **credited**.
-
-We accept contributions via Pull Requests on [GitHub](https://github.com/thephpleague/commonmark).
-
-
-## Pull Requests
-
-- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
-
-- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
-
-- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
-
-- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
-
-- **Create feature branches** - Don't ask us to pull from your master branch.
-
-- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
-
-- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.
-
-
-## Running Tests
-
-``` bash
-$ phpunit
-```
-
-
-**Happy coding**!
diff --git a/vendor/league/commonmark/README.md b/vendor/league/commonmark/README.md
index 7bc6646f3b..06b238ea57 100644
--- a/vendor/league/commonmark/README.md
+++ b/vendor/league/commonmark/README.md
@@ -1,7 +1,5 @@
# league/commonmark
-[![Join the chat at https://gitter.im/thephpleague/commonmark](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/thephpleague/commonmark?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-
[![Latest Version](https://img.shields.io/packagist/v/league/commonmark.svg?style=flat-square)](https://packagist.org/packages/league/commonmark)
[![Total Downloads](https://img.shields.io/packagist/dt/league/commonmark.svg?style=flat-square)](https://packagist.org/packages/league/commonmark)
[![Software License](https://img.shields.io/badge/License-BSD--3-brightgreen.svg?style=flat-square)](LICENSE)
@@ -45,54 +43,15 @@ echo $converter->convertToHtml('# Hello World!');
:warning: **Security warning:** If you will be parsing untrusted input from users, please consider setting the `html_input` and `allow_unsafe_links` options. See <https://commonmark.thephpleague.com/security/> for more details.
-## Advanced Usage & Customization
-
-The actual conversion process requires two steps:
-
- 1. Parsing the Markdown input into an AST
- 2. Rendering the AST document as HTML
-
-Although the `CommonMarkConverter` wrapper simplifies this process for you, advanced users will likely want to do this themselves:
-
-```php
-use League\CommonMark\CommonMarkConverter;
-use League\CommonMark\Environment;
-
-// Obtain a pre-configured Environment with all the CommonMark parsers/renderers ready-to-go
-$environment = Environment::createCommonMarkEnvironment();
-
-// Optional: Add your own parsers, renderers, extensions, etc. (if desired)
-// For example: $environment->addInlineParser(new TwitterHandleParser());
-
-// Define your configuration:
-$config = ['html_input' => 'escape'];
-
-// Create the converter
-$converter = new CommonMarkConverter($config, $environment);
+If you also do choose to allow raw HTML input from untrusted users, considering using a library (like [HTML Purifier](https://github.com/ezyang/htmlpurifier)) to provide additional HTML filtering.
-// Here's our sample input
-$markdown = '# Hello World!';
-
-// Let's render it!
-echo $converter->convertToHtml($markdown);
-
-// The output should be:
-// <h1>Hello World!</h1>
-```
-
-This approach allows you to access/modify the AST before rendering it.
-
-You can also add custom parsers/renderers by [registering them with the `Environment` class](https://commonmark.thephpleague.com/customization/environment/).
-The [documentation][docs] provides several [customization examples][docs-examples] such as:
-
-- [Parsing Twitter handles into profile links][docs-example-twitter]
-- [Converting smilies into emoticon images][docs-example-smilies]
+## Documentation
-You can also reference the core CommonMark parsers/renderers as they use the same functionality available to you.
+Full documentation on advanced usage, configuration, and customization can be found at [commonmark.thephpleague.com][docs].
-## Documentation
+## Upgrading
-Documentation can be found at [commonmark.thephpleague.com][docs].
+Information on how to upgrade to newer versions of this library can be found at <https://commonmark.thephpleague.com/releases>.
## Related Packages
@@ -108,15 +67,21 @@ Documentation can be found at [commonmark.thephpleague.com][docs].
- [Twig-based renderer](https://github.com/webuni/commonmark-twig-renderer)
- [Twig filter and tag](https://github.com/aptoma/twig-markdown)
-### CommonMark Extras
+### League Extensions
+
+The PHP League offers useful extensions that add extra syntax and features:
+
+ - [`league/commonmark-extras`](https://github.com/thephpleague/commonmark-extras) - Bundles the extensions below into a single dependency for convenience
+ - [`league/commonmark-ext-autolink`](https://github.com/thephpleague/commonmark-ext-autolink) - Extension for league/commonmark which autolinks URLs, emails, and (optionally) @-mentions
+ - [`league/commonmark-ext-smartpunct`](https://github.com/thephpleague/commonmark-ext-smartpunct) - Intelligently converts ASCII quotes, dashes, and ellipses to their Unicode equivalents
+ - [`league/commonmark-ext-inlines-only`](https://github.com/thephpleague/commonmark-ext-inlines-only) - Renders inline text without paragraph tags or other block-level elements
-You can find several examples of useful extensions and customizations in the [league/commonmark-extras package](https://github.com/thephpleague/commonmark-extras). You can add them to your parser or use them as examples to [develop your own custom features](https://commonmark.thephpleague.com/customization/overview/).
+You can add them to your project or use them as examples to [develop your own custom features](https://commonmark.thephpleague.com/customization/overview/).
### Community Extensions
Custom parsers/renderers can be bundled into extensions which extend CommonMark. Here are some that you may find interesting:
- - [Markua](https://github.com/dshafik/markua) - Markdown parser for PHP which intends to support the full Markua spec.
- [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.
@@ -133,14 +98,14 @@ Check out the other cool things people are doing with `league/commonmark`: <http
This project aims to fully support the entire [CommonMark spec]. Other flavors of Markdown may work but are not supported. Any/all changes made to the [spec][CommonMark spec] or [JS reference implementation][commonmark.js] should eventually find their way back into this codebase.
-league/commonmark 0.15.5 and higher supports version 0.28 of the [CommonMark spec].
+league/commonmark 0.19.0 and higher supports version 0.29 of the [CommonMark spec].
(This package is **not** part of CommonMark, but rather a compatible derivative.)
## Testing
``` bash
-$ ./vendor/bin/phpunit
+$ composer test
```
This will also test league/commonmark against the latest supported spec.
diff --git a/vendor/league/commonmark/UPGRADE.md b/vendor/league/commonmark/UPGRADE.md
index a71d9a95bc..d33e139bdd 100644
--- a/vendor/league/commonmark/UPGRADE.md
+++ b/vendor/league/commonmark/UPGRADE.md
@@ -1,5 +1,96 @@
# Upgrade Instructions
+**Note:** This file has been deprecated. Future upgrade instructions can be found on our website: <https://commonmark.thephpleague.com/releases>
+
+## UNRELEASED
+
+## 0.19
+
+The `Environment` and extension framework underwent some major changes in this release.
+
+### PHP support
+
+This library no longer supports PHP 5.6 or 7.0. Feel free to remove support for those from your extensions as well.
+
+### HTML attribute escaping
+
+Previously, any attributes passed into an `HtmlElement` would need to be pre-escaped. This is now done for you so be sure to remove any references to `Xml::escape()` when applied to attributes.
+
+This does not affect inner contents which may still need pre-escaping of untrusted user input.
+
+### Removed classes and interface methods
+
+The `getName()` method has been removed from several classes:
+
+ - `BlockParserInterface` and `AbstractBlockParser`
+ - `InlineParserInterface` and `AbstractInlineParser`
+
+This method was originally intended for supporting XML rendering, which was never implemented, and will likely define names a bit differently if/when we do add support.
+
+After doing this, the two abstract classes mentioned above had notthing left in them, so those were removed. Any parsers previously extending them should directly implement the corresponding interface instead.
+
+`InlineContainer` was also removed.
+
+`Xml::escape()` no longer accepts the deprecated `$preserveEntities` parameter.
+
+### Removed deprecated `RegexHelper` methods
+
+Several previously-deprecated methods inside of `RegexHelper` were finally removed. That functionality was made available with static methods and constants, so use those instead.
+
+### Parameter and return types
+
+Pretty much every method now uses parameter and return types, including several interfaces. Update your implementations accordingly.
+
+### Environment interfaces
+
+We have extracted two interfaces from the `Environment` class:
+
+ - `EnvironmentInterface` - contains all the getters; use this in your parsers, renderers, etc.
+ - `ConfigurableEnvironmentInterface` - contains all the `add` methods, as well as `setConfig()` and `mergeConfig`
+
+As a result, `EnvironmentAwareInterface` now requires an `EnvironmentInterface` instead of an `Environment`, so update your parsers/processors/renderers accordingly.
+
+### Block Elements
+
+A few methods from `AbstractBlock` have been extracted into a new `AbstractStringContainerBlock` class and corresponding `StringContainerInterface` interface:
+
+ - `addLine(string $line)`
+ - `getStringContent()`
+ - `handleRemainingContents(ContextInterface $context, Cursor $cursor)`
+
+These are used to represent a block which can contain strings of text inside (even if those strings do not contain "inline" elements but just plain text).
+
+To determine how to best upgrade your existing block element classes, look at the value returned by the `acceptsLines()` method:
+
+ - If `acceptsLines()` returns `false`, simply remove the three methods from the bulleted list above, along with `acceptsLines()` and any calls to `parent::__construct()`.
+ - If `acceptsLines()` returns `true`, change your base class from `AbstractBlock` to `AbstractStringContainerBlock` and remove `acceptsLines()`.
+
+Additionally, `StringContainerInterface` now extends this new `StringContainerInterface` interface. Just make sure you've implemented the change mentioned above and you should be fine.
+
+### Extensions
+
+Extensions work much differently now. In the past, you'd have functions returning an array of things that the `Environment` would register for you.
+
+The `ExtensionInterface` was changed to have a single `register(ConfigurableEnvironmentInterface $environment)` method. You must now manually `add()` all your parsers, processors, and renderers yourself directly within the environment you are provided. See the changes made to `CommonMarkCoreExtension` for a good example.
+
+The `Environment` will still automatically inject the `Environment` or `Configuration` for any parsers, processors, and renderers implementing the `EnvironmentAwareInterface` or `ConfigurationAwareInterface` - that behavior hasn't changed.
+
+### Adding renderers with short names
+
+`Environment::add___Renderer()` now requires the fully-qualified class name with namespace as its first argument. Providing just the class name without the namespace will no longer work.
+
+### Prioritization of parsers, processors, and renderers
+
+The execution order of these things no longer depends on the order you add them - you can now specific custom priorities when `add()`ing them to the `Environment`! The priority can be any integer you want. The default value is `0`. All CommonMark Core things will have a priority between -255 and 255. The higher the number, the earlier it will be executed.
+
+### Multiple block/inline renderers per class
+
+Thanks to the new prioritization system, we now support multiple renderers for the same block/inline class! The first renderer to return a non-null result will be considered the "winner" and no subsequent renderers will execute for that block/inline. No change should be required for most extensions unless you were using some weird workaround to support multiple renderers yourself.
+
+### `RegexHelper::isEscapable()` no longer accepts `null` values
+
+In cases where you may have previously passed a `null` value in, skip the call to this method. The previous behavior was to return `false` for `null` values, but `null` is never escapable so it's silly to make this call when we know what the result will be.
+
## 0.18.3
### Deprecated `Xml::escape()` argument
diff --git a/vendor/league/commonmark/composer.json b/vendor/league/commonmark/composer.json
index 48f496b666..8c6d8b71fc 100644
--- a/vendor/league/commonmark/composer.json
+++ b/vendor/league/commonmark/composer.json
@@ -3,9 +3,8 @@
"type": "library",
"description": "PHP Markdown parser based on the CommonMark spec",
"keywords": ["markdown","parser","commonmark"],
- "homepage": "https://github.com/thephpleague/commonmark",
+ "homepage": "https://commonmark.thephpleague.com",
"license": "BSD-3-Clause",
- "readme": "README.md",
"authors": [
{
"name": "Colin O'Dell",
@@ -24,18 +23,19 @@
"colinodell/commonmark-php": "*"
},
"require": {
- "php": ">=5.6.5",
+ "php": "^7.1",
"ext-mbstring": "*"
},
"require-dev": {
"cebe/markdown": "~1.0",
+ "commonmark/commonmark.js": "0.29.0",
"erusev/parsedown": "~1.0",
- "commonmark/commonmark.js": "0.28",
"michelf/php-markdown": "~1.4",
- "mikehaertl/php-shellcommand": "^1.2",
- "phpunit/phpunit": "^5.7.27|^6.5.14",
- "symfony/finder": "^3.0|^4.0",
- "scrutinizer/ocular": "^1.1"
+ "mikehaertl/php-shellcommand": "^1.4",
+ "phpstan/phpstan-shim": "^0.11.5",
+ "phpunit/phpunit": "^7.5",
+ "scrutinizer/ocular": "^1.5",
+ "symfony/finder": "^4.2"
},
"suggest": {
"league/commonmark-extras": "Library of useful extensions including smart punctuation"
@@ -45,9 +45,9 @@
"type": "package",
"package": {
"name": "commonmark/commonmark.js",
- "version": "0.28",
+ "version": "0.29.0",
"dist": {
- "url": "https://github.com/commonmark/commonmark.js/archive/0.28.0.zip",
+ "url": "https://github.com/commonmark/commonmark.js/archive/0.29.0.zip",
"type": "zip"
}
}
@@ -55,7 +55,7 @@
],
"autoload": {
"psr-4": {
- "League\\CommonMark\\": "src/"
+ "League\\CommonMark\\": "src"
}
},
"autoload-dev": {
@@ -65,9 +65,20 @@
}
},
"bin": ["bin/commonmark"],
+ "scripts": {
+ "phpstan": "phpstan analyse -l 4 src",
+ "phpunit": "phpunit --no-coverage",
+ "test": [
+ "@phpstan",
+ "@phpunit"
+ ]
+ },
"extra": {
"branch-alias": {
- "dev-master": "0.19-dev"
+ "dev-master": "0.20-dev"
}
+ },
+ "config": {
+ "sort-packages": true
}
}
diff --git a/vendor/league/commonmark/src/Block/Element/AbstractBlock.php b/vendor/league/commonmark/src/Block/Element/AbstractBlock.php
index 15da520d45..235dbfe13c 100644
--- a/vendor/league/commonmark/src/Block/Element/AbstractBlock.php
+++ b/vendor/league/commonmark/src/Block/Element/AbstractBlock.php
@@ -17,7 +17,6 @@ namespace League\CommonMark\Block\Element;
use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
use League\CommonMark\Node\Node;
-use League\CommonMark\Util\ArrayCollection;
/**
* Block-level element
@@ -32,16 +31,6 @@ abstract class AbstractBlock extends Node
public $data = [];
/**
- * @var ArrayCollection|string[]
- */
- protected $strings;
-
- /**
- * @var string
- */
- protected $finalStringContents = '';
-
- /**
* @var bool
*/
protected $open = true;
@@ -62,14 +51,6 @@ abstract class AbstractBlock extends Node
protected $endLine;
/**
- * Constructor
- */
- public function __construct()
- {
- $this->strings = new ArrayCollection();
- }
-
- /**
* @param Node|null $node
*/
protected function setParent(Node $node = null)
@@ -84,7 +65,7 @@ abstract class AbstractBlock extends Node
/**
* @return bool
*/
- public function isContainer()
+ public function isContainer(): bool
{
return true;
}
@@ -92,7 +73,7 @@ abstract class AbstractBlock extends Node
/**
* @return bool
*/
- public function hasChildren()
+ public function hasChildren(): bool
{
return $this->firstChild !== null;
}
@@ -104,47 +85,28 @@ abstract class AbstractBlock extends Node
*
* @return bool
*/
- abstract public function canContain(AbstractBlock $block);
-
- /**
- * Returns true if block type can accept lines of text
- *
- * @return bool
- */
- abstract public function acceptsLines();
+ abstract public function canContain(AbstractBlock $block): bool;
/**
* Whether this is a code block
*
* @return bool
*/
- abstract public function isCode();
+ abstract public function isCode(): bool;
/**
* @param Cursor $cursor
*
* @return bool
*/
- abstract public function matchesNextLine(Cursor $cursor);
-
- /**
- * @param ContextInterface $context
- * @param Cursor $cursor
- */
- public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
- {
- // create paragraph container for line
- $context->addBlock(new Paragraph());
- $cursor->advanceToNextNonSpaceOrTab();
- $context->getTip()->addLine($cursor->getRemainder());
- }
+ abstract public function matchesNextLine(Cursor $cursor): bool;
/**
* @param int $startLine
*
* @return $this
*/
- public function setStartLine($startLine)
+ public function setStartLine(int $startLine)
{
$this->startLine = $startLine;
if (empty($this->endLine)) {
@@ -157,12 +119,17 @@ abstract class AbstractBlock extends Node
/**
* @return int
*/
- public function getStartLine()
+ public function getStartLine(): int
{
return $this->startLine;
}
- public function setEndLine($endLine)
+ /**
+ * @param int $endLine
+ *
+ * @return $this
+ */
+ public function setEndLine(int $endLine)
{
$this->endLine = $endLine;
@@ -172,7 +139,7 @@ abstract class AbstractBlock extends Node
/**
* @return int
*/
- public function getEndLine()
+ public function getEndLine(): int
{
return $this->endLine;
}
@@ -182,7 +149,7 @@ abstract class AbstractBlock extends Node
*
* @return bool
*/
- public function endsWithBlankLine()
+ public function endsWithBlankLine(): bool
{
return $this->lastLineBlank;
}
@@ -190,7 +157,7 @@ abstract class AbstractBlock extends Node
/**
* @param bool $blank
*/
- public function setLastLineBlank($blank)
+ public function setLastLineBlank(bool $blank)
{
$this->lastLineBlank = $blank;
}
@@ -203,37 +170,17 @@ abstract class AbstractBlock extends Node
*
* @return bool
*/
- public function shouldLastLineBeBlank(Cursor $cursor, $currentLineNumber)
+ public function shouldLastLineBeBlank(Cursor $cursor, int $currentLineNumber): bool
{
return $cursor->isBlank();
}
/**
- * @return string[]
- */
- public function getStrings()
- {
- return $this->strings->toArray();
- }
-
- /**
- * @param string $line
- */
- public function addLine($line)
- {
- if (!$this->acceptsLines()) {
- throw new \LogicException('You cannot add lines to a block which cannot accept them');
- }
-
- $this->strings->add($line);
- }
-
- /**
* Whether the block is open for modifications
*
* @return bool
*/
- public function isOpen()
+ public function isOpen(): bool
{
return $this->open;
}
@@ -244,7 +191,7 @@ abstract class AbstractBlock extends Node
* @param ContextInterface $context
* @param int $endLineNumber
*/
- public function finalize(ContextInterface $context, $endLineNumber)
+ public function finalize(ContextInterface $context, int $endLineNumber)
{
if (!$this->open) {
return;
@@ -257,21 +204,13 @@ abstract class AbstractBlock extends Node
}
/**
- * @return string
- */
- public function getStringContent()
- {
- return $this->finalStringContents;
- }
-
- /**
* @param string $key
* @param mixed $default
*
* @return mixed
*/
- public function getData($key, $default = null)
+ public function getData(string $key, $default = null)
{
- return array_key_exists($key, $this->data) ? $this->data[$key] : $default;
+ return \array_key_exists($key, $this->data) ? $this->data[$key] : $default;
}
}
diff --git a/vendor/league/commonmark/src/Block/Element/AbstractStringContainerBlock.php b/vendor/league/commonmark/src/Block/Element/AbstractStringContainerBlock.php
new file mode 100644
index 0000000000..583c26b52f
--- /dev/null
+++ b/vendor/league/commonmark/src/Block/Element/AbstractStringContainerBlock.php
@@ -0,0 +1,59 @@
+<?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\Block\Element;
+
+use League\CommonMark\ContextInterface;
+use League\CommonMark\Cursor;
+use League\CommonMark\Util\ArrayCollection;
+
+abstract class AbstractStringContainerBlock extends AbstractBlock implements StringContainerInterface
+{
+ /**
+ * @var ArrayCollection|string[]
+ */
+ protected $strings;
+
+ /**
+ * @var string
+ */
+ protected $finalStringContents = '';
+
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ $this->strings = new ArrayCollection();
+ }
+
+ /**
+ * @param string $line
+ */
+ public function addLine(string $line)
+ {
+ $this->strings->add($line);
+ }
+
+ /**
+ * @param ContextInterface $context
+ * @param Cursor $cursor
+ */
+ abstract public function handleRemainingContents(ContextInterface $context, Cursor $cursor);
+
+ public function getStringContent(): string
+ {
+ return $this->finalStringContents;
+ }
+}
diff --git a/vendor/league/commonmark/src/Block/Element/BlockQuote.php b/vendor/league/commonmark/src/Block/Element/BlockQuote.php
index 1d39dfe6e8..569bf8ecd8 100644
--- a/vendor/league/commonmark/src/Block/Element/BlockQuote.php
+++ b/vendor/league/commonmark/src/Block/Element/BlockQuote.php
@@ -25,32 +25,22 @@ class BlockQuote extends AbstractBlock
*
* @return bool
*/
- public function canContain(AbstractBlock $block)
+ public function canContain(AbstractBlock $block): bool
{
return true;
}
/**
- * Returns true if block type can accept lines of text
- *
- * @return bool
- */
- public function acceptsLines()
- {
- return false;
- }
-
- /**
* Whether this is a code block
*
* @return bool
*/
- public function isCode()
+ public function isCode(): bool
{
return false;
}
- public function matchesNextLine(Cursor $cursor)
+ public function matchesNextLine(Cursor $cursor): bool
{
if (!$cursor->isIndented() && $cursor->getNextNonSpaceCharacter() === '>') {
$cursor->advanceToNextNonSpaceOrTab();
@@ -69,7 +59,7 @@ class BlockQuote extends AbstractBlock
*
* @return bool
*/
- public function shouldLastLineBeBlank(Cursor $cursor, $currentLineNumber)
+ public function shouldLastLineBeBlank(Cursor $cursor, int $currentLineNumber): bool
{
return false;
}
diff --git a/vendor/league/commonmark/src/Block/Element/Document.php b/vendor/league/commonmark/src/Block/Element/Document.php
index 27e2a9fab6..7ed806b33f 100644
--- a/vendor/league/commonmark/src/Block/Element/Document.php
+++ b/vendor/league/commonmark/src/Block/Element/Document.php
@@ -26,8 +26,6 @@ class Document extends AbstractBlock
public function __construct()
{
- parent::__construct();
-
$this->setStartLine(1);
$this->referenceMap = new ReferenceMap();
@@ -36,7 +34,7 @@ class Document extends AbstractBlock
/**
* @return ReferenceMap
*/
- public function getReferenceMap()
+ public function getReferenceMap(): ReferenceMap
{
return $this->referenceMap;
}
@@ -48,32 +46,22 @@ class Document extends AbstractBlock
*
* @return bool
*/
- public function canContain(AbstractBlock $block)
+ public function canContain(AbstractBlock $block): bool
{
return true;
}
/**
- * Returns true if block type can accept lines of text
- *
- * @return bool
- */
- public function acceptsLines()
- {
- return false;
- }
-
- /**
* Whether this is a code block
*
* @return bool
*/
- public function isCode()
+ public function isCode(): bool
{
return false;
}
- public function matchesNextLine(Cursor $cursor)
+ public function matchesNextLine(Cursor $cursor): bool
{
return true;
}
diff --git a/vendor/league/commonmark/src/Block/Element/FencedCode.php b/vendor/league/commonmark/src/Block/Element/FencedCode.php
index a52bee81ab..9ea4288bc7 100644
--- a/vendor/league/commonmark/src/Block/Element/FencedCode.php
+++ b/vendor/league/commonmark/src/Block/Element/FencedCode.php
@@ -18,7 +18,7 @@ use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
use League\CommonMark\Util\RegexHelper;
-class FencedCode extends AbstractBlock
+class FencedCode extends AbstractStringContainerBlock
{
/**
* @var string
@@ -45,7 +45,7 @@ class FencedCode extends AbstractBlock
* @param string $char
* @param int $offset
*/
- public function __construct($length, $char, $offset)
+ public function __construct(int $length, string $char, int $offset)
{
parent::__construct();
@@ -57,7 +57,7 @@ class FencedCode extends AbstractBlock
/**
* @return string
*/
- public function getInfo()
+ public function getInfo(): string
{
return $this->info;
}
@@ -65,15 +65,15 @@ class FencedCode extends AbstractBlock
/**
* @return string[]
*/
- public function getInfoWords()
+ public function getInfoWords(): array
{
- return preg_split('/\s+/', $this->info);
+ return \preg_split('/\s+/', $this->info);
}
/**
* @return string
*/
- public function getChar()
+ public function getChar(): string
{
return $this->char;
}
@@ -83,7 +83,7 @@ class FencedCode extends AbstractBlock
*
* @return $this
*/
- public function setChar($char)
+ public function setChar(string $char): self
{
$this->char = $char;
@@ -93,7 +93,7 @@ class FencedCode extends AbstractBlock
/**
* @return int
*/
- public function getLength()
+ public function getLength(): int
{
return $this->length;
}
@@ -103,7 +103,7 @@ class FencedCode extends AbstractBlock
*
* @return $this
*/
- public function setLength($length)
+ public function setLength(int $length): self
{
$this->length = $length;
@@ -113,7 +113,7 @@ class FencedCode extends AbstractBlock
/**
* @return int
*/
- public function getOffset()
+ public function getOffset(): int
{
return $this->offset;
}
@@ -123,7 +123,7 @@ class FencedCode extends AbstractBlock
*
* @return $this
*/
- public function setOffset($offset)
+ public function setOffset(int $offset): self
{
$this->offset = $offset;
@@ -137,32 +137,22 @@ class FencedCode extends AbstractBlock
*
* @return bool
*/
- public function canContain(AbstractBlock $block)
+ public function canContain(AbstractBlock $block): bool
{
return false;
}
/**
- * Returns true if block type can accept lines of text
- *
- * @return bool
- */
- public function acceptsLines()
- {
- return true;
- }
-
- /**
* Whether this is a code block
*
* @return bool
*/
- public function isCode()
+ public function isCode(): bool
{
return true;
}
- public function matchesNextLine(Cursor $cursor)
+ public function matchesNextLine(Cursor $cursor): bool
{
if ($this->length === -1) {
if ($cursor->isBlank()) {
@@ -178,7 +168,7 @@ class FencedCode extends AbstractBlock
return true;
}
- public function finalize(ContextInterface $context, $endLineNumber)
+ public function finalize(ContextInterface $context, int $endLineNumber)
{
parent::finalize($context, $endLineNumber);
@@ -188,7 +178,7 @@ class FencedCode extends AbstractBlock
if ($this->strings->count() === 1) {
$this->finalStringContents = '';
} else {
- $this->finalStringContents = implode("\n", $this->strings->slice(1)) . "\n";
+ $this->finalStringContents = \implode("\n", $this->strings->slice(1)) . "\n";
}
}
@@ -198,13 +188,13 @@ class FencedCode extends AbstractBlock
*/
public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
{
- /** @var FencedCode $container */
+ /** @var self $container */
$container = $context->getContainer();
// check for closing code fence
if ($cursor->getIndent() <= 3 && $cursor->getNextNonSpaceCharacter() === $container->getChar()) {
$match = RegexHelper::matchAll('/^(?:`{3,}|~{3,})(?= *$)/', $cursor->getLine(), $cursor->getNextNonSpacePosition());
- if (strlen($match[0]) >= $container->getLength()) {
+ 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
@@ -212,7 +202,7 @@ class FencedCode extends AbstractBlock
}
}
- $context->getTip()->addLine($cursor->getRemainder());
+ $container->addLine($cursor->getRemainder());
}
/**
@@ -221,7 +211,7 @@ class FencedCode extends AbstractBlock
*
* @return bool
*/
- public function shouldLastLineBeBlank(Cursor $cursor, $currentLineNumber)
+ public function shouldLastLineBeBlank(Cursor $cursor, int $currentLineNumber): bool
{
return false;
}
diff --git a/vendor/league/commonmark/src/Block/Element/Heading.php b/vendor/league/commonmark/src/Block/Element/Heading.php
index c70c4e31f7..f29f6d1876 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 InlineContainerInterface
+class Heading extends AbstractStringContainerBlock implements InlineContainerInterface
{
/**
* @var int
@@ -28,13 +28,13 @@ class Heading extends AbstractBlock implements InlineContainerInterface
* @param int $level
* @param string|string[] $contents
*/
- public function __construct($level, $contents)
+ public function __construct(int $level, $contents)
{
parent::__construct();
$this->level = $level;
- if (!is_array($contents)) {
+ if (!\is_array($contents)) {
$contents = [$contents];
}
@@ -46,16 +46,16 @@ class Heading extends AbstractBlock implements InlineContainerInterface
/**
* @return int
*/
- public function getLevel()
+ public function getLevel(): int
{
return $this->level;
}
- public function finalize(ContextInterface $context, $endLineNumber)
+ public function finalize(ContextInterface $context, int $endLineNumber)
{
parent::finalize($context, $endLineNumber);
- $this->finalStringContents = implode("\n", $this->getStrings());
+ $this->finalStringContents = \implode("\n", $this->strings->toArray());
}
/**
@@ -65,32 +65,22 @@ class Heading extends AbstractBlock implements InlineContainerInterface
*
* @return bool
*/
- public function canContain(AbstractBlock $block)
+ public function canContain(AbstractBlock $block): bool
{
return false;
}
/**
- * Returns true if block type can accept lines of text
- *
- * @return bool
- */
- public function acceptsLines()
- {
- return true;
- }
-
- /**
* Whether this is a code block
*
* @return bool
*/
- public function isCode()
+ public function isCode(): bool
{
return false;
}
- public function matchesNextLine(Cursor $cursor)
+ public function matchesNextLine(Cursor $cursor): bool
{
return false;
}
@@ -101,6 +91,6 @@ class Heading extends AbstractBlock implements InlineContainerInterface
*/
public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
{
- // nothing to do; we already added the contents.
+ // nothing to do; contents were already added via the constructor.
}
}
diff --git a/vendor/league/commonmark/src/Block/Element/HtmlBlock.php b/vendor/league/commonmark/src/Block/Element/HtmlBlock.php
index 51f778ec79..7a7bedfe08 100644
--- a/vendor/league/commonmark/src/Block/Element/HtmlBlock.php
+++ b/vendor/league/commonmark/src/Block/Element/HtmlBlock.php
@@ -18,8 +18,9 @@ use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
use League\CommonMark\Util\RegexHelper;
-class HtmlBlock extends AbstractBlock
+class HtmlBlock extends AbstractStringContainerBlock
{
+ // Any changes to these constants should be reflected in .phpstorm.meta.php
const TYPE_1_CODE_CONTAINER = 1;
const TYPE_2_COMMENT = 2;
const TYPE_3 = 3;
@@ -36,7 +37,7 @@ class HtmlBlock extends AbstractBlock
/**
* @param int $type
*/
- public function __construct($type)
+ public function __construct(int $type)
{
parent::__construct();
@@ -46,7 +47,7 @@ class HtmlBlock extends AbstractBlock
/**
* @return int
*/
- public function getType()
+ public function getType(): int
{
return $this->type;
}
@@ -54,7 +55,7 @@ class HtmlBlock extends AbstractBlock
/**
* @param int $type
*/
- public function setType($type)
+ public function setType(int $type)
{
$this->type = $type;
}
@@ -66,32 +67,22 @@ class HtmlBlock extends AbstractBlock
*
* @return bool
*/
- public function canContain(AbstractBlock $block)
+ public function canContain(AbstractBlock $block): bool
{
return false;
}
/**
- * Returns true if block type can accept lines of text
- *
- * @return bool
- */
- public function acceptsLines()
- {
- return true;
- }
-
- /**
* Whether this is a code block
*
* @return bool
*/
- public function isCode()
+ public function isCode(): bool
{
return true;
}
- public function matchesNextLine(Cursor $cursor)
+ public function matchesNextLine(Cursor $cursor): bool
{
if ($cursor->isBlank() && ($this->type === self::TYPE_6_BLOCK_ELEMENT || $this->type === self::TYPE_7_MISC_ELEMENT)) {
return false;
@@ -100,11 +91,11 @@ class HtmlBlock extends AbstractBlock
return true;
}
- public function finalize(ContextInterface $context, $endLineNumber)
+ public function finalize(ContextInterface $context, int $endLineNumber)
{
parent::finalize($context, $endLineNumber);
- $this->finalStringContents = implode("\n", $this->getStrings());
+ $this->finalStringContents = \implode("\n", $this->strings->toArray());
}
/**
@@ -113,7 +104,9 @@ class HtmlBlock extends AbstractBlock
*/
public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
{
- $context->getTip()->addLine($cursor->getRemainder());
+ /** @var self $tip */
+ $tip = $context->getTip();
+ $tip->addLine($cursor->getRemainder());
// Check for end condition
if ($this->type >= self::TYPE_1_CODE_CONTAINER && $this->type <= self::TYPE_5_CDATA) {
diff --git a/vendor/league/commonmark/src/Block/Element/IndentedCode.php b/vendor/league/commonmark/src/Block/Element/IndentedCode.php
index 23d996addf..d1c03d4175 100644
--- a/vendor/league/commonmark/src/Block/Element/IndentedCode.php
+++ b/vendor/league/commonmark/src/Block/Element/IndentedCode.php
@@ -17,7 +17,7 @@ namespace League\CommonMark\Block\Element;
use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
-class IndentedCode extends AbstractBlock
+class IndentedCode extends AbstractStringContainerBlock
{
/**
* Returns true if this block can contain the given block as a child node
@@ -26,32 +26,22 @@ class IndentedCode extends AbstractBlock
*
* @return bool
*/
- public function canContain(AbstractBlock $block)
+ public function canContain(AbstractBlock $block): bool
{
return false;
}
/**
- * Returns true if block type can accept lines of text
- *
- * @return bool
- */
- public function acceptsLines()
- {
- return true;
- }
-
- /**
* Whether this is a code block
*
* @return bool
*/
- public function isCode()
+ public function isCode(): bool
{
return true;
}
- public function matchesNextLine(Cursor $cursor)
+ public function matchesNextLine(Cursor $cursor): bool
{
if ($cursor->isIndented()) {
$cursor->advanceBy(Cursor::INDENT_LEVEL, true);
@@ -64,21 +54,21 @@ class IndentedCode extends AbstractBlock
return true;
}
- public function finalize(ContextInterface $context, $endLineNumber)
+ public function finalize(ContextInterface $context, int $endLineNumber)
{
parent::finalize($context, $endLineNumber);
- $reversed = array_reverse($this->getStrings(), true);
+ $reversed = \array_reverse($this->strings->toArray(), true);
foreach ($reversed as $index => $line) {
- if ($line === '' || $line === "\n" || preg_match('/^(\n *)$/', $line)) {
+ if ($line === '' || $line === "\n" || \preg_match('/^(\n *)$/', $line)) {
unset($reversed[$index]);
} else {
break;
}
}
- $fixed = array_reverse($reversed);
- $tmp = implode("\n", $fixed);
- if (substr($tmp, -1) !== "\n") {
+ $fixed = \array_reverse($reversed);
+ $tmp = \implode("\n", $fixed);
+ if (\substr($tmp, -1) !== "\n") {
$tmp .= "\n";
}
@@ -91,6 +81,8 @@ class IndentedCode extends AbstractBlock
*/
public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
{
- $context->getTip()->addLine($cursor->getRemainder());
+ /** @var self $tip */
+ $tip = $context->getTip();
+ $tip->addLine($cursor->getRemainder());
}
}
diff --git a/vendor/league/commonmark/src/Block/Element/InlineContainer.php b/vendor/league/commonmark/src/Block/Element/InlineContainer.php
deleted file mode 100644
index 2b863d4924..0000000000
--- a/vendor/league/commonmark/src/Block/Element/InlineContainer.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-namespace League\CommonMark\Block\Element;
-
-/**
- * @deprecated Use InlineContainerInterface instead
- */
-interface InlineContainer extends InlineContainerInterface
-{
-}
diff --git a/vendor/league/commonmark/src/Block/Element/InlineContainerInterface.php b/vendor/league/commonmark/src/Block/Element/InlineContainerInterface.php
index cd58782115..d2d114a5b9 100644
--- a/vendor/league/commonmark/src/Block/Element/InlineContainerInterface.php
+++ b/vendor/league/commonmark/src/Block/Element/InlineContainerInterface.php
@@ -1,8 +1,20 @@
<?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\Block\Element;
-interface InlineContainerInterface
+interface InlineContainerInterface extends StringContainerInterface
{
- public function getStringContent();
+ public function getStringContent(): string;
}
diff --git a/vendor/league/commonmark/src/Block/Element/ListBlock.php b/vendor/league/commonmark/src/Block/Element/ListBlock.php
index 28b82b538f..dd710d18ea 100644
--- a/vendor/league/commonmark/src/Block/Element/ListBlock.php
+++ b/vendor/league/commonmark/src/Block/Element/ListBlock.php
@@ -34,15 +34,13 @@ class ListBlock extends AbstractBlock
public function __construct(ListData $listData)
{
- parent::__construct();
-
$this->listData = $listData;
}
/**
* @return ListData
*/
- public function getListData()
+ public function getListData(): ListData
{
return $this->listData;
}
@@ -50,7 +48,7 @@ class ListBlock extends AbstractBlock
/**
* @return bool
*/
- public function endsWithBlankLine()
+ public function endsWithBlankLine(): bool
{
if ($this->lastLineBlank) {
return true;
@@ -70,37 +68,27 @@ class ListBlock extends AbstractBlock
*
* @return bool
*/
- public function canContain(AbstractBlock $block)
+ public function canContain(AbstractBlock $block): bool
{
return $block instanceof ListItem;
}
/**
- * Returns true if block type can accept lines of text
- *
- * @return bool
- */
- public function acceptsLines()
- {
- return false;
- }
-
- /**
* Whether this is a code block
*
* @return bool
*/
- public function isCode()
+ public function isCode(): bool
{
return false;
}
- public function matchesNextLine(Cursor $cursor)
+ public function matchesNextLine(Cursor $cursor): bool
{
return true;
}
- public function finalize(ContextInterface $context, $endLineNumber)
+ public function finalize(ContextInterface $context, int $endLineNumber)
{
parent::finalize($context, $endLineNumber);
@@ -131,7 +119,7 @@ class ListBlock extends AbstractBlock
/**
* @return bool
*/
- public function isTight()
+ public function isTight(): bool
{
return $this->tight;
}
@@ -141,7 +129,7 @@ class ListBlock extends AbstractBlock
*
* @return $this
*/
- public function setTight($tight)
+ public function setTight(bool $tight): self
{
$this->tight = $tight;
diff --git a/vendor/league/commonmark/src/Block/Element/ListData.php b/vendor/league/commonmark/src/Block/Element/ListData.php
index 3555d09651..8f86889f39 100644
--- a/vendor/league/commonmark/src/Block/Element/ListData.php
+++ b/vendor/league/commonmark/src/Block/Element/ListData.php
@@ -32,12 +32,12 @@ class ListData
public $type;
/**
- * @var string
+ * @var string|null
*/
public $delimiter;
/**
- * @var string
+ * @var string|null
*/
public $bulletChar;
diff --git a/vendor/league/commonmark/src/Block/Element/ListItem.php b/vendor/league/commonmark/src/Block/Element/ListItem.php
index a455a8a444..e557d40f3a 100644
--- a/vendor/league/commonmark/src/Block/Element/ListItem.php
+++ b/vendor/league/commonmark/src/Block/Element/ListItem.php
@@ -25,15 +25,13 @@ class ListItem extends AbstractBlock
public function __construct(ListData $listData)
{
- parent::__construct();
-
$this->listData = $listData;
}
/**
* @return ListData
*/
- public function getListData()
+ public function getListData(): ListData
{
return $this->listData;
}
@@ -45,32 +43,22 @@ class ListItem extends AbstractBlock
*
* @return bool
*/
- public function canContain(AbstractBlock $block)
+ public function canContain(AbstractBlock $block): bool
{
return true;
}
/**
- * Returns true if block type can accept lines of text
- *
- * @return bool
- */
- public function acceptsLines()
- {
- return false;
- }
-
- /**
* Whether this is a code block
*
* @return bool
*/
- public function isCode()
+ public function isCode(): bool
{
return false;
}
- public function matchesNextLine(Cursor $cursor)
+ public function matchesNextLine(Cursor $cursor): bool
{
if ($cursor->isBlank()) {
if ($this->firstChild === null) {
@@ -93,7 +81,7 @@ class ListItem extends AbstractBlock
*
* @return bool
*/
- public function shouldLastLineBeBlank(Cursor $cursor, $currentLineNumber)
+ public function shouldLastLineBeBlank(Cursor $cursor, int $currentLineNumber): bool
{
return $cursor->isBlank() && $this->startLine < $currentLineNumber;
}
diff --git a/vendor/league/commonmark/src/Block/Element/Paragraph.php b/vendor/league/commonmark/src/Block/Element/Paragraph.php
index c5b84c9a66..8f8a1ffbfd 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 InlineContainerInterface
+class Paragraph extends AbstractStringContainerBlock implements InlineContainerInterface
{
/**
* Returns true if this block can contain the given block as a child node
@@ -26,32 +26,22 @@ class Paragraph extends AbstractBlock implements InlineContainerInterface
*
* @return bool
*/
- public function canContain(AbstractBlock $block)
+ public function canContain(AbstractBlock $block): bool
{
return false;
}
/**
- * Returns true if block type can accept lines of text
- *
- * @return bool
- */
- public function acceptsLines()
- {
- return true;
- }
-
- /**
* Whether this is a code block
*
* @return bool
*/
- public function isCode()
+ public function isCode(): bool
{
return false;
}
- public function matchesNextLine(Cursor $cursor)
+ public function matchesNextLine(Cursor $cursor): bool
{
if ($cursor->isBlank()) {
$this->lastLineBlank = true;
@@ -62,11 +52,11 @@ class Paragraph extends AbstractBlock implements InlineContainerInterface
return true;
}
- public function finalize(ContextInterface $context, $endLineNumber)
+ public function finalize(ContextInterface $context, int $endLineNumber)
{
parent::finalize($context, $endLineNumber);
- $this->finalStringContents = preg_replace('/^ */m', '', implode("\n", $this->getStrings()));
+ $this->finalStringContents = \preg_replace('/^ */m', '', \implode("\n", $this->getStrings()));
// Short-circuit
if ($this->finalStringContents === '' || $this->finalStringContents[0] !== '[') {
@@ -108,6 +98,17 @@ class Paragraph extends AbstractBlock implements InlineContainerInterface
public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
{
$cursor->advanceToNextNonSpaceOrTab();
- $context->getTip()->addLine($cursor->getRemainder());
+
+ /** @var self $tip */
+ $tip = $context->getTip();
+ $tip->addLine($cursor->getRemainder());
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getStrings(): array
+ {
+ return $this->strings->toArray();
}
}
diff --git a/vendor/league/commonmark/src/Block/Element/StringContainerInterface.php b/vendor/league/commonmark/src/Block/Element/StringContainerInterface.php
new file mode 100644
index 0000000000..54d1865b59
--- /dev/null
+++ b/vendor/league/commonmark/src/Block/Element/StringContainerInterface.php
@@ -0,0 +1,40 @@
+<?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\Block\Element;
+
+use League\CommonMark\ContextInterface;
+use League\CommonMark\Cursor;
+
+/**
+ * Interface for a block which can contain line(s) of strings
+ */
+interface StringContainerInterface
+{
+ /**
+ * @param string $line
+ */
+ public function addLine(string $line);
+
+ /**
+ * @return string
+ */
+ public function getStringContent(): string;
+
+ /**
+ * @param ContextInterface $context
+ * @param Cursor $cursor
+ */
+ public function handleRemainingContents(ContextInterface $context, Cursor $cursor);
+}
diff --git a/vendor/league/commonmark/src/Block/Element/ThematicBreak.php b/vendor/league/commonmark/src/Block/Element/ThematicBreak.php
index 1e88317e5e..341e67f0e2 100644
--- a/vendor/league/commonmark/src/Block/Element/ThematicBreak.php
+++ b/vendor/league/commonmark/src/Block/Element/ThematicBreak.php
@@ -25,17 +25,7 @@ class ThematicBreak extends AbstractBlock
*
* @return bool
*/
- public function canContain(AbstractBlock $block)
- {
- return false;
- }
-
- /**
- * Returns true if block type can accept lines of text
- *
- * @return bool
- */
- public function acceptsLines()
+ public function canContain(AbstractBlock $block): bool
{
return false;
}
@@ -45,12 +35,12 @@ class ThematicBreak extends AbstractBlock
*
* @return bool
*/
- public function isCode()
+ public function isCode(): bool
{
return false;
}
- public function matchesNextLine(Cursor $cursor)
+ public function matchesNextLine(Cursor $cursor): bool
{
return false;
}
diff --git a/vendor/league/commonmark/src/Block/Parser/ATXHeadingParser.php b/vendor/league/commonmark/src/Block/Parser/ATXHeadingParser.php
index 4e26804d0e..dfabf7f72a 100644
--- a/vendor/league/commonmark/src/Block/Parser/ATXHeadingParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/ATXHeadingParser.php
@@ -19,7 +19,7 @@ use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
use League\CommonMark\Util\RegexHelper;
-class ATXHeadingParser extends AbstractBlockParser
+class ATXHeadingParser implements BlockParserInterface
{
/**
* @param ContextInterface $context
@@ -27,7 +27,7 @@ class ATXHeadingParser extends AbstractBlockParser
*
* @return bool
*/
- public function parse(ContextInterface $context, Cursor $cursor)
+ public function parse(ContextInterface $context, Cursor $cursor): bool
{
if ($cursor->isIndented()) {
return false;
@@ -40,12 +40,12 @@ class ATXHeadingParser extends AbstractBlockParser
$cursor->advanceToNextNonSpaceOrTab();
- $cursor->advanceBy(strlen($match[0]));
+ $cursor->advanceBy(\strlen($match[0]));
- $level = strlen(trim($match[0]));
+ $level = \strlen(\trim($match[0]));
$str = $cursor->getRemainder();
- $str = preg_replace('/^[ \t]*#+[ \t]*$/', '', $str);
- $str = preg_replace('/[ \t]+#+[ \t]*$/', '', $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/AbstractBlockParser.php b/vendor/league/commonmark/src/Block/Parser/AbstractBlockParser.php
deleted file mode 100644
index 913706a755..0000000000
--- a/vendor/league/commonmark/src/Block/Parser/AbstractBlockParser.php
+++ /dev/null
@@ -1,25 +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\Block\Parser;
-
-abstract class AbstractBlockParser implements BlockParserInterface
-{
- /**
- * @return string
- */
- public function getName()
- {
- $reflection = new \ReflectionClass($this);
-
- return $reflection->getShortName();
- }
-}
diff --git a/vendor/league/commonmark/src/Block/Parser/BlockParserInterface.php b/vendor/league/commonmark/src/Block/Parser/BlockParserInterface.php
index 1f171d9795..6e5753a83c 100644
--- a/vendor/league/commonmark/src/Block/Parser/BlockParserInterface.php
+++ b/vendor/league/commonmark/src/Block/Parser/BlockParserInterface.php
@@ -20,15 +20,10 @@ use League\CommonMark\Cursor;
interface BlockParserInterface
{
/**
- * @return string
- */
- public function getName();
-
- /**
* @param ContextInterface $context
* @param Cursor $cursor
*
* @return bool
*/
- public function parse(ContextInterface $context, Cursor $cursor);
+ public function parse(ContextInterface $context, Cursor $cursor): bool;
}
diff --git a/vendor/league/commonmark/src/Block/Parser/BlockQuoteParser.php b/vendor/league/commonmark/src/Block/Parser/BlockQuoteParser.php
index 62342246ab..4c4ab61532 100644
--- a/vendor/league/commonmark/src/Block/Parser/BlockQuoteParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/BlockQuoteParser.php
@@ -18,7 +18,7 @@ use League\CommonMark\Block\Element\BlockQuote;
use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
-class BlockQuoteParser extends AbstractBlockParser
+class BlockQuoteParser implements BlockParserInterface
{
/**
* @param ContextInterface $context
@@ -26,7 +26,7 @@ class BlockQuoteParser extends AbstractBlockParser
*
* @return bool
*/
- public function parse(ContextInterface $context, Cursor $cursor)
+ public function parse(ContextInterface $context, Cursor $cursor): bool
{
if ($cursor->isIndented()) {
return false;
diff --git a/vendor/league/commonmark/src/Block/Parser/FencedCodeParser.php b/vendor/league/commonmark/src/Block/Parser/FencedCodeParser.php
index b35cf81025..dc279640c2 100644
--- a/vendor/league/commonmark/src/Block/Parser/FencedCodeParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/FencedCodeParser.php
@@ -18,7 +18,7 @@ use League\CommonMark\Block\Element\FencedCode;
use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
-class FencedCodeParser extends AbstractBlockParser
+class FencedCodeParser implements BlockParserInterface
{
/**
* @param ContextInterface $context
@@ -26,21 +26,21 @@ class FencedCodeParser extends AbstractBlockParser
*
* @return bool
*/
- public function parse(ContextInterface $context, Cursor $cursor)
+ public function parse(ContextInterface $context, Cursor $cursor): bool
{
if ($cursor->isIndented()) {
return false;
}
$indent = $cursor->getIndent();
- $fence = $cursor->match('/^[ \t]*(?:`{3,}(?!.*`)|^~{3,}(?!.*~))/');
+ $fence = $cursor->match('/^[ \t]*(?:`{3,}(?!.*`)|^~{3,})/');
if ($fence === null) {
return false;
}
// fenced code block
- $fence = ltrim($fence, " \t");
- $fenceLength = strlen($fence);
+ $fence = \ltrim($fence, " \t");
+ $fenceLength = \strlen($fence);
$context->addBlock(new FencedCode($fenceLength, $fence[0], $indent));
return true;
diff --git a/vendor/league/commonmark/src/Block/Parser/HtmlBlockParser.php b/vendor/league/commonmark/src/Block/Parser/HtmlBlockParser.php
index 4ac9b50c91..107ce1a297 100644
--- a/vendor/league/commonmark/src/Block/Parser/HtmlBlockParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/HtmlBlockParser.php
@@ -20,7 +20,7 @@ use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
use League\CommonMark\Util\RegexHelper;
-class HtmlBlockParser extends AbstractBlockParser
+class HtmlBlockParser implements BlockParserInterface
{
/**
* @param ContextInterface $context
@@ -28,7 +28,7 @@ class HtmlBlockParser extends AbstractBlockParser
*
* @return bool
*/
- public function parse(ContextInterface $context, Cursor $cursor)
+ public function parse(ContextInterface $context, Cursor $cursor): bool
{
if ($cursor->isIndented()) {
return false;
diff --git a/vendor/league/commonmark/src/Block/Parser/IndentedCodeParser.php b/vendor/league/commonmark/src/Block/Parser/IndentedCodeParser.php
index ad45bd48cf..8e7ed0562c 100644
--- a/vendor/league/commonmark/src/Block/Parser/IndentedCodeParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/IndentedCodeParser.php
@@ -19,7 +19,7 @@ use League\CommonMark\Block\Element\Paragraph;
use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
-class IndentedCodeParser extends AbstractBlockParser
+class IndentedCodeParser implements BlockParserInterface
{
/**
* @param ContextInterface $context
@@ -27,7 +27,7 @@ class IndentedCodeParser extends AbstractBlockParser
*
* @return bool
*/
- public function parse(ContextInterface $context, Cursor $cursor)
+ public function parse(ContextInterface $context, Cursor $cursor): bool
{
if (!$cursor->isIndented()) {
return false;
diff --git a/vendor/league/commonmark/src/Block/Parser/LazyParagraphParser.php b/vendor/league/commonmark/src/Block/Parser/LazyParagraphParser.php
index bf05196cad..eaa245028a 100644
--- a/vendor/league/commonmark/src/Block/Parser/LazyParagraphParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/LazyParagraphParser.php
@@ -17,7 +17,7 @@ namespace League\CommonMark\Block\Parser;
use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
-class LazyParagraphParser extends AbstractBlockParser
+class LazyParagraphParser implements BlockParserInterface
{
/**
* @param ContextInterface $context
@@ -25,7 +25,7 @@ class LazyParagraphParser extends AbstractBlockParser
*
* @return bool
*/
- public function parse(ContextInterface $context, Cursor $cursor)
+ public function parse(ContextInterface $context, Cursor $cursor): bool
{
if (!$cursor->isIndented()) {
return false;
diff --git a/vendor/league/commonmark/src/Block/Parser/ListParser.php b/vendor/league/commonmark/src/Block/Parser/ListParser.php
index 131699837a..e12a42fb70 100644
--- a/vendor/league/commonmark/src/Block/Parser/ListParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/ListParser.php
@@ -22,7 +22,7 @@ use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
use League\CommonMark\Util\RegexHelper;
-class ListParser extends AbstractBlockParser
+class ListParser implements BlockParserInterface
{
/**
* @param ContextInterface $context
@@ -30,30 +30,36 @@ class ListParser extends AbstractBlockParser
*
* @return bool
*/
- public function parse(ContextInterface $context, Cursor $cursor)
+ public function parse(ContextInterface $context, Cursor $cursor): bool
{
if ($cursor->isIndented() && !($context->getContainer() instanceof ListBlock)) {
return false;
}
+ $indent = $cursor->getIndent();
+ if ($indent >= 4) {
+ return false;
+ }
+
$tmpCursor = clone $cursor;
$tmpCursor->advanceToNextNonSpaceOrTab();
$rest = $tmpCursor->getRemainder();
- $data = new ListData();
- $data->markerOffset = $cursor->getIndent();
-
- if (preg_match('/^[*+-]/', $rest) === 1) {
+ if (\preg_match('/^[*+-]/', $rest) === 1) {
+ $data = new ListData();
+ $data->markerOffset = $indent;
$data->type = ListBlock::TYPE_UNORDERED;
$data->delimiter = null;
$data->bulletChar = $rest[0];
$markerLength = 1;
} elseif (($matches = RegexHelper::matchAll('/^(\d{1,9})([.)])/', $rest)) && (!($context->getContainer() instanceof Paragraph) || $matches[1] === '1')) {
+ $data = new ListData();
+ $data->markerOffset = $indent;
$data->type = ListBlock::TYPE_ORDERED;
$data->start = (int) $matches[1];
$data->delimiter = $matches[2];
$data->bulletChar = null;
- $markerLength = strlen($matches[0]);
+ $markerLength = \strlen($matches[0]);
} else {
return false;
}
@@ -76,7 +82,7 @@ class ListParser extends AbstractBlockParser
$data->padding = $this->calculateListMarkerPadding($cursor, $markerLength);
// add the list if needed
- if (!$container || !($container instanceof ListBlock) || !$data->equals($container->getListData())) {
+ if (!($container instanceof ListBlock) || !$data->equals($container->getListData())) {
$context->addBlock(new ListBlock($data));
}
@@ -92,7 +98,7 @@ class ListParser extends AbstractBlockParser
*
* @return int
*/
- private function calculateListMarkerPadding(Cursor $cursor, $markerLength)
+ private function calculateListMarkerPadding(Cursor $cursor, int $markerLength): int
{
$start = $cursor->saveState();
$spacesStartCol = $cursor->getColumn();
diff --git a/vendor/league/commonmark/src/Block/Parser/SetExtHeadingParser.php b/vendor/league/commonmark/src/Block/Parser/SetExtHeadingParser.php
index 56ad1fd765..c69e2dcab6 100644
--- a/vendor/league/commonmark/src/Block/Parser/SetExtHeadingParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/SetExtHeadingParser.php
@@ -18,9 +18,10 @@ use League\CommonMark\Block\Element\Heading;
use League\CommonMark\Block\Element\Paragraph;
use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
+use League\CommonMark\ReferenceParser;
use League\CommonMark\Util\RegexHelper;
-class SetExtHeadingParser extends AbstractBlockParser
+class SetExtHeadingParser implements BlockParserInterface
{
/**
* @param ContextInterface $context
@@ -28,7 +29,7 @@ class SetExtHeadingParser extends AbstractBlockParser
*
* @return bool
*/
- public function parse(ContextInterface $context, Cursor $cursor)
+ public function parse(ContextInterface $context, Cursor $cursor): bool
{
if ($cursor->isIndented()) {
return false;
@@ -46,8 +47,42 @@ class SetExtHeadingParser extends AbstractBlockParser
$level = $match[0][0] === '=' ? 1 : 2;
$strings = $context->getContainer()->getStrings();
+ $strings = $this->resolveReferenceLinkDefinitions($strings, $cursor->getEncoding(), $context->getReferenceParser());
+ if (empty($strings)) {
+ return false;
+ }
+
$context->replaceContainerBlock(new Heading($level, $strings));
return true;
}
+
+ /**
+ * Resolve reference link definition
+ *
+ * @see https://github.com/commonmark/commonmark.js/commit/993bbe335931af847460effa99b2411eb643577d
+ *
+ * @param string[] $strings
+ * @param string $encoding
+ * @param ReferenceParser $referenceParser
+ *
+ * @return string[]
+ */
+ private function resolveReferenceLinkDefinitions(array $strings, string $encoding, ReferenceParser $referenceParser): array
+ {
+ foreach ($strings as &$string) {
+ $cursor = new Cursor($string, $encoding);
+ while ($cursor->getCharacter() === '[' && $referenceParser->parse($cursor)) {
+ $string = $cursor->getRemainder();
+ }
+
+ if ($string !== '') {
+ break;
+ }
+ }
+
+ return \array_filter($strings, function ($s) {
+ return $s !== '';
+ });
+ }
}
diff --git a/vendor/league/commonmark/src/Block/Parser/ThematicBreakParser.php b/vendor/league/commonmark/src/Block/Parser/ThematicBreakParser.php
index 09ad7dcdf0..be008316b1 100644
--- a/vendor/league/commonmark/src/Block/Parser/ThematicBreakParser.php
+++ b/vendor/league/commonmark/src/Block/Parser/ThematicBreakParser.php
@@ -19,7 +19,7 @@ use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
use League\CommonMark\Util\RegexHelper;
-class ThematicBreakParser extends AbstractBlockParser
+class ThematicBreakParser implements BlockParserInterface
{
/**
* @param ContextInterface $context
@@ -27,7 +27,7 @@ class ThematicBreakParser extends AbstractBlockParser
*
* @return bool
*/
- public function parse(ContextInterface $context, Cursor $cursor)
+ public function parse(ContextInterface $context, Cursor $cursor): bool
{
if ($cursor->isIndented()) {
return false;
diff --git a/vendor/league/commonmark/src/Block/Renderer/BlockQuoteRenderer.php b/vendor/league/commonmark/src/Block/Renderer/BlockQuoteRenderer.php
index 238fb098a5..9a2a572133 100644
--- a/vendor/league/commonmark/src/Block/Renderer/BlockQuoteRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/BlockQuoteRenderer.php
@@ -18,7 +18,6 @@ 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
{
@@ -29,16 +28,13 @@ class BlockQuoteRenderer implements BlockRendererInterface
*
* @return HtmlElement
*/
- public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
+ public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, bool $inTightList = false)
{
if (!($block instanceof BlockQuote)) {
- throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
+ throw new \InvalidArgumentException('Incompatible block type: ' . \get_class($block));
}
- $attrs = [];
- foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = Xml::escape($value);
- }
+ $attrs = $block->getData('attributes', []);
$filling = $htmlRenderer->renderBlocks($block->children());
if ($filling === '') {
diff --git a/vendor/league/commonmark/src/Block/Renderer/BlockRendererInterface.php b/vendor/league/commonmark/src/Block/Renderer/BlockRendererInterface.php
index 3f07f33d7a..dd339da9c2 100644
--- a/vendor/league/commonmark/src/Block/Renderer/BlockRendererInterface.php
+++ b/vendor/league/commonmark/src/Block/Renderer/BlockRendererInterface.php
@@ -25,7 +25,7 @@ interface BlockRendererInterface
* @param ElementRendererInterface $htmlRenderer
* @param bool $inTightList
*
- * @return HtmlElement|string
+ * @return HtmlElement|string|null
*/
- public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false);
+ public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, bool $inTightList = false);
}
diff --git a/vendor/league/commonmark/src/Block/Renderer/DocumentRenderer.php b/vendor/league/commonmark/src/Block/Renderer/DocumentRenderer.php
index fe0a453732..7300cb43f1 100644
--- a/vendor/league/commonmark/src/Block/Renderer/DocumentRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/DocumentRenderer.php
@@ -27,10 +27,10 @@ class DocumentRenderer implements BlockRendererInterface
*
* @return string
*/
- public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
+ public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, bool $inTightList = false)
{
if (!($block instanceof Document)) {
- throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
+ throw new \InvalidArgumentException('Incompatible block type: ' . \get_class($block));
}
$wholeDoc = $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 c78de52478..29577d6fd9 100644
--- a/vendor/league/commonmark/src/Block/Renderer/FencedCodeRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/FencedCodeRenderer.php
@@ -29,21 +29,18 @@ class FencedCodeRenderer implements BlockRendererInterface
*
* @return HtmlElement
*/
- public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
+ public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, bool $inTightList = false)
{
if (!($block instanceof FencedCode)) {
- throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
+ throw new \InvalidArgumentException('Incompatible block type: ' . \get_class($block));
}
- $attrs = [];
- foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = Xml::escape($value);
- }
+ $attrs = $block->getData('attributes', []);
$infoWords = $block->getInfoWords();
- if (count($infoWords) !== 0 && strlen($infoWords[0]) !== 0) {
+ if (count($infoWords) !== 0 && \strlen($infoWords[0]) !== 0) {
$attrs['class'] = isset($attrs['class']) ? $attrs['class'] . ' ' : '';
- $attrs['class'] .= 'language-' . Xml::escape($infoWords[0]);
+ $attrs['class'] .= 'language-' . $infoWords[0];
}
return new HtmlElement(
diff --git a/vendor/league/commonmark/src/Block/Renderer/HeadingRenderer.php b/vendor/league/commonmark/src/Block/Renderer/HeadingRenderer.php
index e1a8e9ad1f..05d35cbb14 100644
--- a/vendor/league/commonmark/src/Block/Renderer/HeadingRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/HeadingRenderer.php
@@ -18,7 +18,6 @@ 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
{
@@ -29,18 +28,15 @@ class HeadingRenderer implements BlockRendererInterface
*
* @return HtmlElement
*/
- public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
+ public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, bool $inTightList = false)
{
if (!($block instanceof Heading)) {
- throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
+ throw new \InvalidArgumentException('Incompatible block type: ' . \get_class($block));
}
$tag = 'h' . $block->getLevel();
- $attrs = [];
- foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = Xml::escape($value);
- }
+ $attrs = $block->getData('attributes', []);
return new HtmlElement($tag, $attrs, $htmlRenderer->renderInlines($block->children()));
}
diff --git a/vendor/league/commonmark/src/Block/Renderer/HtmlBlockRenderer.php b/vendor/league/commonmark/src/Block/Renderer/HtmlBlockRenderer.php
index 0f4e437060..53f106189b 100644
--- a/vendor/league/commonmark/src/Block/Renderer/HtmlBlockRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/HtmlBlockRenderer.php
@@ -17,7 +17,7 @@ namespace League\CommonMark\Block\Renderer;
use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\Block\Element\HtmlBlock;
use League\CommonMark\ElementRendererInterface;
-use League\CommonMark\Environment;
+use League\CommonMark\EnvironmentInterface;
use League\CommonMark\Util\Configuration;
use League\CommonMark\Util\ConfigurationAwareInterface;
@@ -35,10 +35,10 @@ class HtmlBlockRenderer implements BlockRendererInterface, ConfigurationAwareInt
*
* @return string
*/
- public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
+ public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, bool $inTightList = false)
{
if (!($block instanceof HtmlBlock)) {
- throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
+ throw new \InvalidArgumentException('Incompatible block type: ' . \get_class($block));
}
// Kept for BC reasons
@@ -46,12 +46,12 @@ class HtmlBlockRenderer implements BlockRendererInterface, ConfigurationAwareInt
return '';
}
- if ($this->config->getConfig('html_input') === Environment::HTML_INPUT_STRIP) {
+ if ($this->config->getConfig('html_input') === EnvironmentInterface::HTML_INPUT_STRIP) {
return '';
}
- if ($this->config->getConfig('html_input') === Environment::HTML_INPUT_ESCAPE) {
- return htmlspecialchars($block->getStringContent(), ENT_NOQUOTES);
+ if ($this->config->getConfig('html_input') === EnvironmentInterface::HTML_INPUT_ESCAPE) {
+ return \htmlspecialchars($block->getStringContent(), ENT_NOQUOTES);
}
return $block->getStringContent();
diff --git a/vendor/league/commonmark/src/Block/Renderer/IndentedCodeRenderer.php b/vendor/league/commonmark/src/Block/Renderer/IndentedCodeRenderer.php
index 7aa649d060..b4de15e1a0 100644
--- a/vendor/league/commonmark/src/Block/Renderer/IndentedCodeRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/IndentedCodeRenderer.php
@@ -29,16 +29,13 @@ class IndentedCodeRenderer implements BlockRendererInterface
*
* @return HtmlElement
*/
- public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
+ public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, bool $inTightList = false)
{
if (!($block instanceof IndentedCode)) {
- throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
+ throw new \InvalidArgumentException('Incompatible block type: ' . \get_class($block));
}
- $attrs = [];
- foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = Xml::escape($value);
- }
+ $attrs = $block->getData('attributes', []);
return new HtmlElement(
'pre',
diff --git a/vendor/league/commonmark/src/Block/Renderer/ListBlockRenderer.php b/vendor/league/commonmark/src/Block/Renderer/ListBlockRenderer.php
index e90c8f5c90..755eec7b3e 100644
--- a/vendor/league/commonmark/src/Block/Renderer/ListBlockRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/ListBlockRenderer.php
@@ -18,7 +18,6 @@ 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
{
@@ -29,20 +28,17 @@ class ListBlockRenderer implements BlockRendererInterface
*
* @return HtmlElement
*/
- public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
+ public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, bool $inTightList = false)
{
if (!($block instanceof ListBlock)) {
- throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
+ throw new \InvalidArgumentException('Incompatible block type: ' . \get_class($block));
}
$listData = $block->getListData();
$tag = $listData->type === ListBlock::TYPE_UNORDERED ? 'ul' : 'ol';
- $attrs = [];
- foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = Xml::escape($value);
- }
+ $attrs = $block->getData('attributes', []);
if ($listData->start !== null && $listData->start !== 1) {
$attrs['start'] = (string) $listData->start;
diff --git a/vendor/league/commonmark/src/Block/Renderer/ListItemRenderer.php b/vendor/league/commonmark/src/Block/Renderer/ListItemRenderer.php
index cbd7496285..0a66060fcc 100644
--- a/vendor/league/commonmark/src/Block/Renderer/ListItemRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/ListItemRenderer.php
@@ -18,7 +18,6 @@ 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
{
@@ -29,24 +28,21 @@ class ListItemRenderer implements BlockRendererInterface
*
* @return string
*/
- public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
+ public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, bool $inTightList = false)
{
if (!($block instanceof ListItem)) {
- throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
+ throw new \InvalidArgumentException('Incompatible block type: ' . \get_class($block));
}
$contents = $htmlRenderer->renderBlocks($block->children(), $inTightList);
- if (substr($contents, 0, 1) === '<') {
+ if (\substr($contents, 0, 1) === '<') {
$contents = "\n" . $contents;
}
- if (substr($contents, -1, 1) === '>') {
+ if (\substr($contents, -1, 1) === '>') {
$contents .= "\n";
}
- $attrs = [];
- foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = Xml::escape($value);
- }
+ $attrs = $block->getData('attributes', []);
$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 985c903415..4c56bab41d 100644
--- a/vendor/league/commonmark/src/Block/Renderer/ParagraphRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/ParagraphRenderer.php
@@ -18,7 +18,6 @@ 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
{
@@ -29,20 +28,17 @@ class ParagraphRenderer implements BlockRendererInterface
*
* @return HtmlElement|string
*/
- public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
+ public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, bool $inTightList = false)
{
if (!($block instanceof Paragraph)) {
- throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
+ throw new \InvalidArgumentException('Incompatible block type: ' . \get_class($block));
}
if ($inTightList) {
return $htmlRenderer->renderInlines($block->children());
}
- $attrs = [];
- foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = Xml::escape($value);
- }
+ $attrs = $block->getData('attributes', []);
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 ce0488a78d..2ae9f07925 100644
--- a/vendor/league/commonmark/src/Block/Renderer/ThematicBreakRenderer.php
+++ b/vendor/league/commonmark/src/Block/Renderer/ThematicBreakRenderer.php
@@ -18,7 +18,6 @@ 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
{
@@ -29,16 +28,13 @@ class ThematicBreakRenderer implements BlockRendererInterface
*
* @return HtmlElement
*/
- public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
+ public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, bool $inTightList = false)
{
if (!($block instanceof ThematicBreak)) {
- throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
+ throw new \InvalidArgumentException('Incompatible block type: ' . \get_class($block));
}
- $attrs = [];
- foreach ($block->getData('attributes', []) as $key => $value) {
- $attrs[$key] = Xml::escape($value);
- }
+ $attrs = $block->getData('attributes', []);
return new HtmlElement('hr', $attrs, '', true);
}
diff --git a/vendor/league/commonmark/src/CommonMarkConverter.php b/vendor/league/commonmark/src/CommonMarkConverter.php
index 1de5987cba..a47b825c2a 100644
--- a/vendor/league/commonmark/src/CommonMarkConverter.php
+++ b/vendor/league/commonmark/src/CommonMarkConverter.php
@@ -26,21 +26,24 @@ class CommonMarkConverter extends Converter
*
* @deprecated This will be removed in 1.0.0
*/
- const VERSION = '0.18.5';
+ const VERSION = '0.19.3';
/**
* Create a new commonmark converter instance.
*
- * @param array $config
- * @param Environment|null $environment
+ * @param array $config
+ * @param EnvironmentInterface|null $environment
*/
- public function __construct(array $config = [], Environment $environment = null)
+ public function __construct(array $config = [], EnvironmentInterface $environment = null)
{
if ($environment === null) {
$environment = Environment::createCommonMarkEnvironment();
}
- $environment->mergeConfig($config);
+ if ($environment instanceof ConfigurableEnvironmentInterface) {
+ $environment->mergeConfig($config);
+ }
+
parent::__construct(new DocParser($environment), new HtmlRenderer($environment));
}
}
diff --git a/vendor/league/commonmark/src/ConfigurableEnvironmentInterface.php b/vendor/league/commonmark/src/ConfigurableEnvironmentInterface.php
new file mode 100644
index 0000000000..d9f0fa3d13
--- /dev/null
+++ b/vendor/league/commonmark/src/ConfigurableEnvironmentInterface.php
@@ -0,0 +1,104 @@
+<?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;
+
+use League\CommonMark\Block\Parser\BlockParserInterface;
+use League\CommonMark\Block\Renderer\BlockRendererInterface;
+use League\CommonMark\Extension\ExtensionInterface;
+use League\CommonMark\Inline\Parser\InlineParserInterface;
+use League\CommonMark\Inline\Processor\InlineProcessorInterface;
+use League\CommonMark\Inline\Renderer\InlineRendererInterface;
+
+/**
+ * Interface for an Environment which can be configured with config settings, parsers, processors, and renderers
+ */
+interface ConfigurableEnvironmentInterface extends EnvironmentInterface
+{
+ /**
+ * @param array $config
+ */
+ public function mergeConfig(array $config = []);
+
+ /**
+ * @param array $config
+ */
+ public function setConfig(array $config = []);
+
+ /**
+ * Registers the given extension with the Environment
+ *
+ * @param ExtensionInterface $extension
+ *
+ * @return ConfigurableEnvironmentInterface
+ */
+ public function addExtension(ExtensionInterface $extension): ConfigurableEnvironmentInterface;
+
+ /**
+ * Registers the given block parser with the Environment
+ *
+ * @param BlockParserInterface $parser Block parser instance
+ * @param int $priority Priority (a higher number will be executed earlier)
+ *
+ * @return self
+ */
+ public function addBlockParser(BlockParserInterface $parser, int $priority = 0): ConfigurableEnvironmentInterface;
+
+ /**
+ * Registers the given inline parser with the Environment
+ *
+ * @param InlineParserInterface $parser Inline parser instance
+ * @param int $priority Priority (a higher number will be executed earlier)
+ *
+ * @return self
+ */
+ public function addInlineParser(InlineParserInterface $parser, int $priority = 0): ConfigurableEnvironmentInterface;
+
+ /**
+ * Registers the given inline processor with the Environment
+ *
+ * @param InlineProcessorInterface $processor Inline processor instance
+ * @param int $priority Priority (a higher number will be executed earlier)
+ *
+ * @return self
+ */
+ public function addInlineProcessor(InlineProcessorInterface $processor, int $priority = 0): ConfigurableEnvironmentInterface;
+
+ /**
+ * Registers the given document processor with the Environment
+ *
+ * @param DocumentProcessorInterface $processor Document processor instance
+ * @param int $priority Priority (a higher number will be executed earlier)
+ *
+ * @return self
+ */
+ public function addDocumentProcessor(DocumentProcessorInterface $processor, int $priority = 0): ConfigurableEnvironmentInterface;
+
+ /**
+ * @param string $blockClass The fully-qualified block element class name the renderer below should handle
+ * @param BlockRendererInterface $blockRenderer The renderer responsible for rendering the type of element given above
+ * @param int $priority Priority (a higher number will be executed earlier)
+ *
+ * @return self
+ */
+ public function addBlockRenderer($blockClass, BlockRendererInterface $blockRenderer, int $priority = 0): ConfigurableEnvironmentInterface;
+
+ /**
+ * Registers the given inline renderer with the Environment
+ *
+ * @param string $inlineClass The fully-qualified inline element class name the renderer below should handle
+ * @param InlineRendererInterface $renderer The renderer responsible for rendering the type of element given above
+ * @param int $priority Priority (a higher number will be executed earlier)
+ *
+ * @return self
+ */
+ public function addInlineRenderer(string $inlineClass, InlineRendererInterface $renderer, int $priority = 0): ConfigurableEnvironmentInterface;
+}
diff --git a/vendor/league/commonmark/src/Context.php b/vendor/league/commonmark/src/Context.php
index 67d542bedc..476a73f480 100644
--- a/vendor/league/commonmark/src/Context.php
+++ b/vendor/league/commonmark/src/Context.php
@@ -18,17 +18,17 @@ use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\Block\Element\Document;
/**
- * Parses Markdown into an AST
+ * Maintains the current state of the Markdown parser engine
*/
class Context implements ContextInterface
{
/**
- * @var Environment
+ * @var EnvironmentInterface
*/
protected $environment;
/**
- * @var AbstractBlock
+ * @var Document
*/
protected $doc;
@@ -62,11 +62,17 @@ class Context implements ContextInterface
*/
protected $blocksParsed = false;
+ /**
+ * @var string
+ */
protected $encoding = 'UTF-8';
+ /**
+ * @var ReferenceParser
+ */
protected $referenceParser;
- public function __construct(Document $document, Environment $environment)
+ public function __construct(Document $document, EnvironmentInterface $environment)
{
$this->doc = $document;
$this->tip = $this->doc;
@@ -82,7 +88,7 @@ class Context implements ContextInterface
/**
* @param string $line
*/
- public function setNextLine($line)
+ public function setNextLine(string $line)
{
++$this->lineNumber;
$this->line = $line;
@@ -91,7 +97,7 @@ class Context implements ContextInterface
/**
* @return Document
*/
- public function getDocument()
+ public function getDocument(): Document
{
return $this->doc;
}
@@ -99,7 +105,7 @@ class Context implements ContextInterface
/**
* @return AbstractBlock|null
*/
- public function getTip()
+ public function getTip(): ?AbstractBlock
{
return $this->tip;
}
@@ -109,7 +115,7 @@ class Context implements ContextInterface
*
* @return $this
*/
- public function setTip(AbstractBlock $block = null)
+ public function setTip(?AbstractBlock $block)
{
$this->tip = $block;
@@ -119,7 +125,7 @@ class Context implements ContextInterface
/**
* @return int
*/
- public function getLineNumber()
+ public function getLineNumber(): int
{
return $this->lineNumber;
}
@@ -127,7 +133,7 @@ class Context implements ContextInterface
/**
* @return string
*/
- public function getLine()
+ public function getLine(): string
{
return $this->line;
}
@@ -137,7 +143,7 @@ class Context implements ContextInterface
*
* @return UnmatchedBlockCloser
*/
- public function getBlockCloser()
+ public function getBlockCloser(): UnmatchedBlockCloser
{
return $this->blockCloser;
}
@@ -145,7 +151,7 @@ class Context implements ContextInterface
/**
* @return AbstractBlock
*/
- public function getContainer()
+ public function getContainer(): AbstractBlock
{
return $this->container;
}
@@ -155,7 +161,7 @@ class Context implements ContextInterface
*
* @return $this
*/
- public function setContainer($container)
+ public function setContainer(AbstractBlock $container)
{
$this->container = $container;
@@ -164,8 +170,6 @@ class Context implements ContextInterface
/**
* @param AbstractBlock $block
- *
- * @return AbstractBlock
*/
public function addBlock(AbstractBlock $block)
{
@@ -178,8 +182,6 @@ class Context implements ContextInterface
$this->tip->appendChild($block);
$this->tip = $block;
$this->container = $block;
-
- return $block;
}
/**
@@ -200,7 +202,7 @@ class Context implements ContextInterface
/**
* @return bool
*/
- public function getBlocksParsed()
+ public function getBlocksParsed(): bool
{
return $this->blocksParsed;
}
@@ -210,7 +212,7 @@ class Context implements ContextInterface
*
* @return $this
*/
- public function setBlocksParsed($bool)
+ public function setBlocksParsed(bool $bool)
{
$this->blocksParsed = $bool;
@@ -220,7 +222,7 @@ class Context implements ContextInterface
/**
* @return ReferenceParser
*/
- public function getReferenceParser()
+ public function getReferenceParser(): ReferenceParser
{
return $this->referenceParser;
}
@@ -228,7 +230,7 @@ class Context implements ContextInterface
/**
* @return string
*/
- public function getEncoding()
+ public function getEncoding(): string
{
return $this->encoding;
}
@@ -238,7 +240,7 @@ class Context implements ContextInterface
*
* @return $this
*/
- public function setEncoding($encoding)
+ public function setEncoding(string $encoding): self
{
$this->encoding = $encoding;
diff --git a/vendor/league/commonmark/src/ContextInterface.php b/vendor/league/commonmark/src/ContextInterface.php
index 351b280a63..c0902acc5e 100644
--- a/vendor/league/commonmark/src/ContextInterface.php
+++ b/vendor/league/commonmark/src/ContextInterface.php
@@ -22,82 +22,74 @@ interface ContextInterface
/**
* @return Document
*/
- public function getDocument();
+ public function getDocument(): Document;
/**
- * @return AbstractBlock
+ * @return AbstractBlock|null
*/
- public function getTip();
+ public function getTip(): ?AbstractBlock;
/**
- * @param AbstractBlock $block
- *
- * @return $this
+ * @param AbstractBlock|null $block
*/
- public function setTip(AbstractBlock $block);
+ public function setTip(?AbstractBlock $block);
/**
* @return int
*/
- public function getLineNumber();
+ public function getLineNumber(): int;
/**
* @return string
*/
- public function getLine();
+ public function getLine(): string;
/**
* Finalize and close any unmatched blocks
*
* @return UnmatchedBlockCloser
*/
- public function getBlockCloser();
+ public function getBlockCloser(): UnmatchedBlockCloser;
/**
* @return AbstractBlock
*/
- public function getContainer();
+ public function getContainer(): AbstractBlock;
/**
- * @param AbstractBlock $getDocument
- *
- * @return $this
+ * @param AbstractBlock $container
*/
- public function setContainer($getDocument);
+ public function setContainer(AbstractBlock $container);
/**
* @param AbstractBlock $block
- *
- * @return AbstractBlock
*/
public function addBlock(AbstractBlock $block);
/**
* @param AbstractBlock $replacement
- *
- * @return void
*/
public function replaceContainerBlock(AbstractBlock $replacement);
/**
* @return bool
*/
- public function getBlocksParsed();
+ public function getBlocksParsed(): bool;
/**
* @param bool $bool
*
* @return $this
*/
- public function setBlocksParsed($bool);
+ public function setBlocksParsed(bool $bool);
/**
* @return ReferenceParser
*/
- public function getReferenceParser();
+ public function getReferenceParser(): ReferenceParser;
/**
* @return string
*/
- public function getEncoding();
+ public function getEncoding(): string;
}
diff --git a/vendor/league/commonmark/src/Converter.php b/vendor/league/commonmark/src/Converter.php
index e2e8a1b6c8..20a6a7b046 100644
--- a/vendor/league/commonmark/src/Converter.php
+++ b/vendor/league/commonmark/src/Converter.php
@@ -54,7 +54,7 @@ class Converter implements ConverterInterface
*
* @api
*/
- public function convertToHtml($commonMark)
+ public function convertToHtml(string $commonMark): string
{
$documentAST = $this->docParser->parse($commonMark);
@@ -70,7 +70,7 @@ class Converter implements ConverterInterface
*
* @return string
*/
- public function __invoke($commonMark)
+ public function __invoke(string $commonMark): string
{
return $this->convertToHtml($commonMark);
}
diff --git a/vendor/league/commonmark/src/ConverterInterface.php b/vendor/league/commonmark/src/ConverterInterface.php
index 3d47a275d1..20d7edcc70 100644
--- a/vendor/league/commonmark/src/ConverterInterface.php
+++ b/vendor/league/commonmark/src/ConverterInterface.php
@@ -25,5 +25,5 @@ interface ConverterInterface
*
* @api
*/
- public function convertToHtml($commonMark);
+ public function convertToHtml(string $commonMark): string;
}
diff --git a/vendor/league/commonmark/src/Cursor.php b/vendor/league/commonmark/src/Cursor.php
index 91af05d6f1..d0dd8e7aca 100644
--- a/vendor/league/commonmark/src/Cursor.php
+++ b/vendor/league/commonmark/src/Cursor.php
@@ -74,20 +74,26 @@ class Cursor
private $isMultibyte;
/**
- * @var int
+ * @var array<int, string>
*/
private $charCache = [];
/**
- * @param string $line
+ * @param string $line The line being parsed
+ * @param string $encoding The encoding of that line
*/
- public function __construct($line, $encoding = 'UTF-8')
+ public function __construct(string $line, string $encoding = 'UTF-8')
{
$this->line = $line;
$this->encoding = $encoding;
- $this->length = mb_strlen($line, $this->encoding);
- $this->isMultibyte = $this->length !== strlen($line);
- $this->lineContainsTabs = preg_match('/\t/', $line) > 0;
+ $this->length = \mb_strlen($line, $this->encoding);
+ $this->isMultibyte = $this->length !== \strlen($line);
+ $this->lineContainsTabs = \preg_match('/\t/', $line) > 0;
+ }
+
+ public function getEncoding(): string
+ {
+ return $this->encoding;
}
/**
@@ -95,7 +101,7 @@ class Cursor
*
* @return int
*/
- public function getNextNonSpacePosition()
+ public function getNextNonSpacePosition(): int
{
if ($this->nextNonSpaceCache !== null) {
return $this->nextNonSpaceCache;
@@ -127,7 +133,7 @@ class Cursor
*
* @return string
*/
- public function getNextNonSpaceCharacter()
+ public function getNextNonSpaceCharacter(): ?string
{
return $this->getCharacter($this->getNextNonSpacePosition());
}
@@ -137,7 +143,7 @@ class Cursor
*
* @return int
*/
- public function getIndent()
+ public function getIndent(): int
{
if ($this->nextNonSpaceCache === null) {
$this->getNextNonSpacePosition();
@@ -151,7 +157,7 @@ class Cursor
*
* @return bool
*/
- public function isIndented()
+ public function isIndented(): bool
{
return $this->getIndent() >= self::INDENT_LEVEL;
}
@@ -161,7 +167,7 @@ class Cursor
*
* @return string|null
*/
- public function getCharacter($index = null)
+ public function getCharacter(?int $index = null): ?string
{
if ($index === null) {
$index = $this->currentPosition;
@@ -173,10 +179,10 @@ class Cursor
// Index out-of-bounds, or we're at the end
if ($index < 0 || $index >= $this->length) {
- return;
+ return null;
}
- return $this->charCache[$index] = mb_substr($this->line, $index, 1, $this->encoding);
+ return $this->charCache[$index] = \mb_substr($this->line, $index, 1, $this->encoding);
}
/**
@@ -186,7 +192,7 @@ class Cursor
*
* @return string|null
*/
- public function peek($offset = 1)
+ public function peek(int $offset = 1): ?string
{
return $this->getCharacter($this->currentPosition + $offset);
}
@@ -196,7 +202,7 @@ class Cursor
*
* @return bool
*/
- public function isBlank()
+ public function isBlank(): bool
{
return $this->nextNonSpaceCache === $this->length || $this->getNextNonSpacePosition() === $this->length;
}
@@ -215,7 +221,7 @@ class Cursor
* @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)
+ public function advanceBy(int $characters, bool $advanceByColumns = false)
{
if ($characters === 0) {
$this->previousPosition = $this->currentPosition;
@@ -227,8 +233,8 @@ class Cursor
$this->nextNonSpaceCache = null;
// Optimization to avoid tab handling logic if we have no tabs
- if (!$this->lineContainsTabs || preg_match('/\t/', $nextFewChars = mb_substr($this->line, $this->currentPosition, $characters, $this->encoding)) === 0) {
- $length = min($characters, $this->length - $this->currentPosition);
+ if (!$this->lineContainsTabs || \preg_match('/\t/', $nextFewChars = mb_substr($this->line, $this->currentPosition, $characters, $this->encoding)) === 0) {
+ $length = \min($characters, $this->length - $this->currentPosition);
$this->partiallyConsumedTab = false;
$this->currentPosition += $length;
$this->column += $length;
@@ -239,7 +245,7 @@ class Cursor
if ($characters === 1 && !empty($nextFewChars)) {
$asArray = [$nextFewChars];
} else {
- $asArray = preg_split('//u', $nextFewChars, null, PREG_SPLIT_NO_EMPTY);
+ $asArray = \preg_split('//u', $nextFewChars, null, PREG_SPLIT_NO_EMPTY);
}
foreach ($asArray as $relPos => $c) {
@@ -275,7 +281,7 @@ class Cursor
*
* @return bool
*/
- public function advanceBySpaceOrTab()
+ public function advanceBySpaceOrTab(): bool
{
$character = $this->getCharacter();
@@ -293,7 +299,7 @@ class Cursor
*
* @return int Number of positions moved
*/
- public function advanceToNextNonSpaceOrTab()
+ public function advanceToNextNonSpaceOrTab(): int
{
$newPosition = $this->getNextNonSpacePosition();
$this->advanceBy($newPosition - $this->currentPosition);
@@ -309,14 +315,14 @@ class Cursor
*
* @return int Number of positions moved
*/
- public function advanceToNextNonSpaceOrNewline()
+ public function advanceToNextNonSpaceOrNewline(): int
{
$matches = [];
- preg_match('/^ *(?:\n *)?/', $this->getRemainder(), $matches, PREG_OFFSET_CAPTURE);
+ \preg_match('/^ *(?:\n *)?/', $this->getRemainder(), $matches, PREG_OFFSET_CAPTURE);
// [0][0] contains the matched text
// [0][1] contains the index of that match
- $increment = $matches[0][1] + strlen($matches[0][0]);
+ $increment = $matches[0][1] + \strlen($matches[0][0]);
if ($increment === 0) {
return 0;
@@ -332,7 +338,7 @@ class Cursor
*
* @return int The number of characters moved
*/
- public function advanceToEnd()
+ public function advanceToEnd(): int
{
$this->previousPosition = $this->currentPosition;
$this->nextNonSpaceCache = null;
@@ -345,7 +351,7 @@ class Cursor
/**
* @return string
*/
- public function getRemainder()
+ public function getRemainder(): string
{
if ($this->currentPosition >= $this->length) {
return '';
@@ -356,16 +362,16 @@ class Cursor
if ($this->partiallyConsumedTab) {
$position++;
$charsToTab = 4 - ($this->column % 4);
- $prefix = str_repeat(' ', $charsToTab);
+ $prefix = \str_repeat(' ', $charsToTab);
}
- return $prefix . mb_substr($this->line, $position, null, $this->encoding);
+ return $prefix . \mb_substr($this->line, $position, null, $this->encoding);
}
/**
* @return string
*/
- public function getLine()
+ public function getLine(): string
{
return $this->line;
}
@@ -373,7 +379,7 @@ class Cursor
/**
* @return bool
*/
- public function isAtEnd()
+ public function isAtEnd(): bool
{
return $this->currentPosition >= $this->length;
}
@@ -387,12 +393,12 @@ class Cursor
*
* @return string|null
*/
- public function match($regex)
+ public function match(string $regex): ?string
{
$subject = $this->getRemainder();
- if (!preg_match($regex, $subject, $matches, PREG_OFFSET_CAPTURE)) {
- return;
+ if (!\preg_match($regex, $subject, $matches, PREG_OFFSET_CAPTURE)) {
+ return null;
}
// $matches[0][0] contains the matched text
@@ -400,11 +406,11 @@ class Cursor
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);
- $matchLength = mb_strlen($matches[0][0], $this->encoding);
+ $offset = \mb_strlen(\mb_strcut($subject, 0, $matches[0][1], $this->encoding), $this->encoding);
+ $matchLength = \mb_strlen($matches[0][0], $this->encoding);
} else {
$offset = $matches[0][1];
- $matchLength = strlen($matches[0][0]);
+ $matchLength = \strlen($matches[0][0]);
}
// [0][0] contains the matched text
@@ -457,7 +463,7 @@ class Cursor
/**
* @return int
*/
- public function getPosition()
+ public function getPosition(): int
{
return $this->currentPosition;
}
@@ -465,15 +471,15 @@ class Cursor
/**
* @return string
*/
- public function getPreviousText()
+ public function getPreviousText(): string
{
- return mb_substr($this->line, $this->previousPosition, $this->currentPosition - $this->previousPosition, $this->encoding);
+ return \mb_substr($this->line, $this->previousPosition, $this->currentPosition - $this->previousPosition, $this->encoding);
}
/**
* @return int
*/
- public function getColumn()
+ public function getColumn(): int
{
return $this->column;
}
diff --git a/vendor/league/commonmark/src/Delimiter/Delimiter.php b/vendor/league/commonmark/src/Delimiter/Delimiter.php
index b58a9d2657..0777547540 100644
--- a/vendor/league/commonmark/src/Delimiter/Delimiter.php
+++ b/vendor/league/commonmark/src/Delimiter/Delimiter.php
@@ -56,7 +56,7 @@ class Delimiter
* @param bool $canClose
* @param int|null $index
*/
- public function __construct($char, $numDelims, Node $node, $canOpen, $canClose, $index = null)
+ public function __construct(string $char, int $numDelims, Node $node, bool $canOpen, bool $canClose, ?int $index = null)
{
$this->char = $char;
$this->numDelims = $numDelims;
@@ -71,7 +71,7 @@ class Delimiter
/**
* @return bool
*/
- public function canClose()
+ public function canClose(): bool
{
return $this->canClose;
}
@@ -81,7 +81,7 @@ class Delimiter
*
* @return $this
*/
- public function setCanClose($canClose)
+ public function setCanClose(bool $canClose)
{
$this->canClose = $canClose;
@@ -91,7 +91,7 @@ class Delimiter
/**
* @return bool
*/
- public function canOpen()
+ public function canOpen(): bool
{
return $this->canOpen;
}
@@ -101,7 +101,7 @@ class Delimiter
*
* @return $this
*/
- public function setCanOpen($canOpen)
+ public function setCanOpen(bool $canOpen)
{
$this->canOpen = $canOpen;
@@ -111,7 +111,7 @@ class Delimiter
/**
* @return bool
*/
- public function isActive()
+ public function isActive(): bool
{
return $this->active;
}
@@ -121,7 +121,7 @@ class Delimiter
*
* @return $this
*/
- public function setActive($active)
+ public function setActive(bool $active)
{
$this->active = $active;
@@ -131,7 +131,7 @@ class Delimiter
/**
* @return string
*/
- public function getChar()
+ public function getChar(): string
{
return $this->char;
}
@@ -141,7 +141,7 @@ class Delimiter
*
* @return $this
*/
- public function setChar($char)
+ public function setChar(string $char)
{
$this->char = $char;
@@ -151,7 +151,7 @@ class Delimiter
/**
* @return int|null
*/
- public function getIndex()
+ public function getIndex(): ?int
{
return $this->index;
}
@@ -161,7 +161,7 @@ class Delimiter
*
* @return $this
*/
- public function setIndex($index)
+ public function setIndex(?int $index)
{
$this->index = $index;
@@ -171,7 +171,7 @@ class Delimiter
/**
* @return Delimiter|null
*/
- public function getNext()
+ public function getNext(): ?self
{
return $this->next;
}
@@ -181,7 +181,7 @@ class Delimiter
*
* @return $this
*/
- public function setNext($next)
+ public function setNext(?self $next)
{
$this->next = $next;
@@ -191,7 +191,7 @@ class Delimiter
/**
* @return int
*/
- public function getNumDelims()
+ public function getNumDelims(): int
{
return $this->numDelims;
}
@@ -201,7 +201,7 @@ class Delimiter
*
* @return $this
*/
- public function setNumDelims($numDelims)
+ public function setNumDelims(int $numDelims)
{
$this->numDelims = $numDelims;
@@ -211,7 +211,7 @@ class Delimiter
/**
* @return int
*/
- public function getOrigDelims()
+ public function getOrigDelims(): int
{
return $this->origDelims;
}
@@ -219,7 +219,7 @@ class Delimiter
/**
* @return Node
*/
- public function getInlineNode()
+ public function getInlineNode(): Node
{
return $this->inlineNode;
}
@@ -239,7 +239,7 @@ class Delimiter
/**
* @return Delimiter|null
*/
- public function getPrevious()
+ public function getPrevious(): ?self
{
return $this->previous;
}
@@ -249,7 +249,7 @@ class Delimiter
*
* @return $this
*/
- public function setPrevious($previous)
+ public function setPrevious(?self $previous)
{
$this->previous = $previous;
diff --git a/vendor/league/commonmark/src/Delimiter/DelimiterStack.php b/vendor/league/commonmark/src/Delimiter/DelimiterStack.php
index c7e06ede10..04bc1f65f3 100644
--- a/vendor/league/commonmark/src/Delimiter/DelimiterStack.php
+++ b/vendor/league/commonmark/src/Delimiter/DelimiterStack.php
@@ -21,7 +21,7 @@ class DelimiterStack
*/
protected $top;
- public function getTop()
+ public function getTop(): ?Delimiter
{
return $this->top;
}
@@ -42,7 +42,7 @@ class DelimiterStack
*
* @return Delimiter|null
*/
- public function findEarliest(Delimiter $stackBottom = null)
+ public function findEarliest(Delimiter $stackBottom = null): ?Delimiter
{
$delimiter = $this->top;
while ($delimiter !== null && $delimiter->getPrevious() !== $stackBottom) {
@@ -82,7 +82,7 @@ class DelimiterStack
/**
* @param string $character
*/
- public function removeEarlierMatches($character)
+ public function removeEarlierMatches(string $character)
{
$opener = $this->top;
while ($opener !== null) {
@@ -99,15 +99,15 @@ class DelimiterStack
*
* @return Delimiter|null
*/
- public function searchByCharacter($characters)
+ public function searchByCharacter($characters): ?Delimiter
{
- if (!is_array($characters)) {
+ if (!\is_array($characters)) {
$characters = [$characters];
}
$opener = $this->top;
while ($opener !== null) {
- if (in_array($opener->getChar(), $characters)) {
+ if (\in_array($opener->getChar(), $characters)) {
break;
}
$opener = $opener->getPrevious();
@@ -121,13 +121,13 @@ class DelimiterStack
* @param callable $callback
* @param Delimiter $stackBottom
*/
- public function iterateByCharacters($characters, $callback, Delimiter $stackBottom = null)
+ public function iterateByCharacters($characters, callable $callback, Delimiter $stackBottom = null)
{
- if (!is_array($characters)) {
+ if (!\is_array($characters)) {
$characters = [$characters];
}
- $openersBottom = array_fill_keys($characters, $stackBottom);
+ $openersBottom = \array_fill_keys($characters, $stackBottom);
// Find first closer above stackBottom
$closer = $this->findEarliest($stackBottom);
@@ -135,7 +135,7 @@ class DelimiterStack
while ($closer !== null) {
$closerChar = $closer->getChar();
- if (!$closer->canClose() || !in_array($closerChar, $characters)) {
+ if (!$closer->canClose() || !\in_array($closerChar, $characters)) {
$closer = $closer->getNext();
continue;
}
@@ -169,18 +169,20 @@ class DelimiterStack
*
* @return Delimiter|null
*/
- protected function findMatchingOpener(Delimiter $closer, $openersBottom, Delimiter $stackBottom = null, &$oddMatch = false)
+ protected function findMatchingOpener(Delimiter $closer, array $openersBottom, Delimiter $stackBottom = null, bool &$oddMatch = false): ?Delimiter
{
$closerChar = $closer->getChar();
$opener = $closer->getPrevious();
while ($opener !== null && $opener !== $stackBottom && $opener !== $openersBottom[$closerChar]) {
- $oddMatch = ($closer->canOpen() || $opener->canClose()) && ($opener->getOrigDelims() + $closer->getOrigDelims()) % 3 === 0;
+ $oddMatch = ($closer->canOpen() || $opener->canClose()) && $closer->getOrigDelims() % 3 !== 0 && ($opener->getOrigDelims() + $closer->getOrigDelims()) % 3 === 0;
if ($opener->getChar() === $closerChar && $opener->canOpen() && !$oddMatch) {
return $opener;
}
$opener = $opener->getPrevious();
}
+
+ return null;
}
}
diff --git a/vendor/league/commonmark/src/DocParser.php b/vendor/league/commonmark/src/DocParser.php
index 305ffcaffe..457efee115 100644
--- a/vendor/league/commonmark/src/DocParser.php
+++ b/vendor/league/commonmark/src/DocParser.php
@@ -18,11 +18,12 @@ use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\Block\Element\Document;
use League\CommonMark\Block\Element\InlineContainerInterface;
use League\CommonMark\Block\Element\Paragraph;
+use League\CommonMark\Block\Element\StringContainerInterface;
class DocParser
{
/**
- * @var Environment
+ * @var EnvironmentInterface
*/
protected $environment;
@@ -37,9 +38,9 @@ class DocParser
private $maxNestingLevel;
/**
- * @param Environment $environment
+ * @param EnvironmentInterface $environment
*/
- public function __construct(Environment $environment)
+ public function __construct(EnvironmentInterface $environment)
{
$this->environment = $environment;
$this->inlineParserEngine = new InlineParserEngine($environment);
@@ -47,9 +48,9 @@ class DocParser
}
/**
- * @return Environment
+ * @return EnvironmentInterface
*/
- public function getEnvironment()
+ public function getEnvironment(): EnvironmentInterface
{
return $this->environment;
}
@@ -59,15 +60,15 @@ class DocParser
*
* @return string[]
*/
- private function preProcessInput($input)
+ private function preProcessInput(string $input): array
{
- $lines = preg_split('/\r\n|\n|\r/', $input);
+ $lines = \preg_split('/\r\n|\n|\r/', $input);
// Remove any newline which appears at the very end of the string.
// We've already split the document by newlines, so we can simply drop
// any empty element which appears on the end.
- if (end($lines) === '') {
- array_pop($lines);
+ if (\end($lines) === '') {
+ \array_pop($lines);
}
return $lines;
@@ -78,10 +79,10 @@ class DocParser
*
* @return Document
*/
- public function parse($input)
+ public function parse(string $input): Document
{
$context = new Context(new Document(), $this->getEnvironment());
- $context->setEncoding(mb_detect_encoding($input, 'ASCII,UTF-8', true) ?: 'ISO-8859-1');
+ $context->setEncoding(\mb_detect_encoding($input, 'ASCII,UTF-8', true) ?: 'ISO-8859-1');
$lines = $this->preProcessInput($input);
foreach ($lines as $line) {
@@ -89,7 +90,7 @@ class DocParser
$this->incorporateLine($context);
}
- $lineCount = count($lines);
+ $lineCount = \count($lines);
while ($tip = $context->getTip()) {
$tip->finalize($context, $lineCount);
}
@@ -115,10 +116,7 @@ class DocParser
// What remains at the offset is a text line. Add the text to the appropriate container.
// First check for a lazy paragraph continuation:
- if ($this->isLazyParagraphContinuation($context, $cursor)) {
- // lazy paragraph continuation
- $context->getTip()->addLine($cursor->getRemainder());
-
+ if ($this->handleLazyParagraphContinuation($context, $cursor)) {
return;
}
@@ -130,13 +128,14 @@ class DocParser
$this->setAndPropagateLastLineBlank($context, $cursor);
// Handle any remaining cursor contents
- if ($context->getContainer()->acceptsLines()) {
+ if ($context->getContainer() instanceof StringContainerInterface) {
$context->getContainer()->handleRemainingContents($context, $cursor);
} elseif (!$cursor->isBlank()) {
// Create paragraph container for line
- $context->addBlock(new Paragraph());
+ $p = new Paragraph();
+ $context->addBlock($p);
$cursor->advanceToNextNonSpaceOrTab();
- $context->getTip()->addLine($cursor->getRemainder());
+ $p->addLine($cursor->getRemainder());
}
}
@@ -209,7 +208,7 @@ class DocParser
}
}
- if (!$parsed || $context->getContainer()->acceptsLines() || $context->getTip()->getDepth() >= $this->maxNestingLevel) {
+ if (!$parsed || $context->getContainer() instanceof StringContainerInterface || $context->getTip()->getDepth() >= $this->maxNestingLevel) {
$context->setBlocksParsed(true);
break;
}
@@ -222,12 +221,22 @@ class DocParser
*
* @return bool
*/
- private function isLazyParagraphContinuation(ContextInterface $context, Cursor $cursor)
+ private function handleLazyParagraphContinuation(ContextInterface $context, Cursor $cursor): bool
{
- return $context->getTip() instanceof Paragraph &&
+ $tip = $context->getTip();
+
+ if ($tip instanceof Paragraph &&
!$context->getBlockCloser()->areAllClosed() &&
!$cursor->isBlank() &&
- count($context->getTip()->getStrings()) > 0;
+ \count($tip->getStrings()) > 0) {
+
+ // lazy paragraph continuation
+ $tip->addLine($cursor->getRemainder());
+
+ return true;
+ }
+
+ return false;
}
/**
diff --git a/vendor/league/commonmark/src/ElementRendererInterface.php b/vendor/league/commonmark/src/ElementRendererInterface.php
index 54e577acbd..46c8a8dd1b 100644
--- a/vendor/league/commonmark/src/ElementRendererInterface.php
+++ b/vendor/league/commonmark/src/ElementRendererInterface.php
@@ -26,16 +26,16 @@ interface ElementRendererInterface
* @param string $option
* @param mixed $default
*
- * @return mixed
+ * @return mixed|null
*/
- public function getOption($option, $default = null);
+ public function getOption(string $option, $default = null);
/**
* @param AbstractInline[] $inlines
*
* @return string
*/
- public function renderInlines($inlines);
+ public function renderInlines(iterable $inlines): string;
/**
* @param AbstractBlock $block
@@ -45,7 +45,7 @@ interface ElementRendererInterface
*
* @return string
*/
- public function renderBlock(AbstractBlock $block, $inTightList = false);
+ public function renderBlock(AbstractBlock $block, bool $inTightList = false): string;
/**
* @param AbstractBlock[] $blocks
@@ -53,5 +53,5 @@ interface ElementRendererInterface
*
* @return string
*/
- public function renderBlocks($blocks, $inTightList = false);
+ public function renderBlocks(iterable $blocks, bool $inTightList = false): string;
}
diff --git a/vendor/league/commonmark/src/Environment.php b/vendor/league/commonmark/src/Environment.php
index c5ca1a1355..0a8dca3f81 100644
--- a/vendor/league/commonmark/src/Environment.php
+++ b/vendor/league/commonmark/src/Environment.php
@@ -18,81 +18,87 @@ use League\CommonMark\Block\Parser\BlockParserInterface;
use League\CommonMark\Block\Renderer\BlockRendererInterface;
use League\CommonMark\Extension\CommonMarkCoreExtension;
use League\CommonMark\Extension\ExtensionInterface;
-use League\CommonMark\Extension\MiscExtension;
use League\CommonMark\Inline\Parser\InlineParserInterface;
use League\CommonMark\Inline\Processor\InlineProcessorInterface;
use League\CommonMark\Inline\Renderer\InlineRendererInterface;
use League\CommonMark\Util\Configuration;
use League\CommonMark\Util\ConfigurationAwareInterface;
+use League\CommonMark\Util\PrioritizedList;
-class Environment
+final class Environment implements EnvironmentInterface, ConfigurableEnvironmentInterface
{
- const HTML_INPUT_STRIP = 'strip';
- const HTML_INPUT_ESCAPE = 'escape';
- const HTML_INPUT_ALLOW = 'allow';
+ /**
+ * @var ExtensionInterface[]
+ */
+ private $extensions = [];
/**
* @var ExtensionInterface[]
*/
- protected $extensions = [];
+ private $uninitializedExtensions = [];
/**
* @var bool
*/
- protected $extensionsInitialized = false;
+ private $extensionsInitialized = false;
/**
- * @var BlockParserInterface[]
+ * @var PrioritizedList<BlockParserInterface>
*/
- protected $blockParsers = [];
+ private $blockParsers;
/**
- * @var InlineParserInterface[]
+ * @var PrioritizedList<InlineParserInterface>
*/
- protected $inlineParsers = [];
+ private $inlineParsers;
/**
- * @var array
+ * @var array<string, PrioritizedList<InlineParserInterface>>
*/
- protected $inlineParsersByCharacter = [];
+ private $inlineParsersByCharacter = [];
/**
- * @var DocumentProcessorInterface[]
+ * @var PrioritizedList<DocumentProcessorInterface>
*/
- protected $documentProcessors = [];
+ private $documentProcessors;
/**
- * @var InlineProcessorInterface[]
+ * @var PrioritizedList<InlineProcessorInterface>
*/
- protected $inlineProcessors = [];
+ private $inlineProcessors;
/**
- * @var BlockRendererInterface[]
+ * @var array<string, PrioritizedList<BlockRendererInterface>>
*/
- protected $blockRenderersByClass = [];
+ private $blockRenderersByClass = [];
/**
- * @var InlineRendererInterface[]
+ * @var array<string, PrioritizedList<InlineRendererInterface>>
*/
- protected $inlineRenderersByClass = [];
+ private $inlineRenderersByClass = [];
/**
* @var Configuration
*/
- protected $config;
+ private $config;
/**
* @var string
*/
- protected $inlineParserCharacterRegex;
+ private $inlineParserCharacterRegex;
public function __construct(array $config = [])
{
$this->config = new Configuration($config);
+
+ $this->blockParsers = new PrioritizedList();
+ $this->inlineParsers = new PrioritizedList();
+ $this->documentProcessors = new PrioritizedList();
+ $this->inlineProcessors = new PrioritizedList();
}
/**
- * @param array $config
+ * {@inheritdoc}
*/
public function mergeConfig(array $config = [])
{
@@ -102,7 +108,7 @@ class Environment
}
/**
- * @param array $config
+ * {@inheritdoc}
*/
public function setConfig(array $config = [])
{
@@ -112,10 +118,7 @@ class Environment
}
/**
- * @param string|null $key
- * @param mixed $default
- *
- * @return mixed
+ * {@inheritdoc}
*/
public function getConfig($key = null, $default = null)
{
@@ -123,129 +126,113 @@ class Environment
}
/**
- * @param BlockParserInterface $parser
- *
- * @return $this
+ * {@inheritdoc}
*/
- public function addBlockParser(BlockParserInterface $parser)
+ public function addBlockParser(BlockParserInterface $parser, int $priority = 0): ConfigurableEnvironmentInterface
{
$this->assertUninitialized('Failed to add block parser.');
- $this->getMiscExtension()->addBlockParser($parser);
+ $this->blockParsers->add($parser, $priority);
+ $this->injectEnvironmentAndConfigurationIfNeeded($parser);
return $this;
}
/**
- * @param InlineParserInterface $parser
- *
- * @return $this
+ * {@inheritdoc}
*/
- public function addInlineParser(InlineParserInterface $parser)
+ public function addInlineParser(InlineParserInterface $parser, int $priority = 0): ConfigurableEnvironmentInterface
{
$this->assertUninitialized('Failed to add inline parser.');
- $this->getMiscExtension()->addInlineParser($parser);
+ $this->inlineParsers->add($parser, $priority);
+ $this->injectEnvironmentAndConfigurationIfNeeded($parser);
+
+ foreach ($parser->getCharacters() as $character) {
+ if (!isset($this->inlineParsersByCharacter[$character])) {
+ $this->inlineParsersByCharacter[$character] = new PrioritizedList();
+ }
+
+ $this->inlineParsersByCharacter[$character]->add($parser, $priority);
+ }
return $this;
}
/**
- * @param InlineProcessorInterface $processor
- *
- * @return $this
+ * {@inheritdoc}
*/
- public function addInlineProcessor(InlineProcessorInterface $processor)
+ public function addInlineProcessor(InlineProcessorInterface $processor, int $priority = 0): ConfigurableEnvironmentInterface
{
$this->assertUninitialized('Failed to add inline processor.');
- $this->getMiscExtension()->addInlineProcessor($processor);
+ $this->inlineProcessors->add($processor, $priority);
+ $this->injectEnvironmentAndConfigurationIfNeeded($processor);
return $this;
}
/**
- * @param DocumentProcessorInterface $processor
- *
- * @return $this
+ * {@inheritdoc}
*/
- public function addDocumentProcessor(DocumentProcessorInterface $processor)
+ public function addDocumentProcessor(DocumentProcessorInterface $processor, int $priority = 0): ConfigurableEnvironmentInterface
{
$this->assertUninitialized('Failed to add document processor.');
- $this->getMiscExtension()->addDocumentProcessor($processor);
+ $this->documentProcessors->add($processor, $priority);
+ $this->injectEnvironmentAndConfigurationIfNeeded($processor);
return $this;
}
/**
- * @param string $blockClass
- * @param BlockRendererInterface $blockRenderer
- *
- * @return $this
+ * {@inheritdoc}
*/
- public function addBlockRenderer($blockClass, BlockRendererInterface $blockRenderer)
+ public function addBlockRenderer($blockClass, BlockRendererInterface $blockRenderer, int $priority = 0): ConfigurableEnvironmentInterface
{
$this->assertUninitialized('Failed to add block renderer.');
- $this->getMiscExtension()->addBlockRenderer($blockClass, $blockRenderer);
-
- return $this;
- }
-
- /**
- * @param string $inlineClass
- * @param InlineRendererInterface $renderer
- *
- * @return $this
- */
- public function addInlineRenderer($inlineClass, InlineRendererInterface $renderer)
- {
- $this->assertUninitialized('Failed to add inline renderer.');
+ if (!isset($this->blockRenderersByClass[$blockClass])) {
+ $this->blockRenderersByClass[$blockClass] = new PrioritizedList();
+ }
- $this->getMiscExtension()->addInlineRenderer($inlineClass, $renderer);
+ $this->blockRenderersByClass[$blockClass]->add($blockRenderer, $priority);
+ $this->injectEnvironmentAndConfigurationIfNeeded($blockRenderer);
return $this;
}
/**
- * @return BlockParserInterface[]
+ * {@inheritdoc}
*/
- public function getBlockParsers()
+ public function addInlineRenderer(string $inlineClass, InlineRendererInterface $renderer, int $priority = 0): ConfigurableEnvironmentInterface
{
- $this->initializeExtensions();
+ $this->assertUninitialized('Failed to add inline renderer.');
- return $this->blockParsers;
- }
+ if (!isset($this->inlineRenderersByClass[$inlineClass])) {
+ $this->inlineRenderersByClass[$inlineClass] = new PrioritizedList();
+ }
- /**
- * @param string $name
- *
- * @return InlineParserInterface
- */
- public function getInlineParser($name)
- {
- $this->initializeExtensions();
+ $this->inlineRenderersByClass[$inlineClass]->add($renderer, $priority);
+ $this->injectEnvironmentAndConfigurationIfNeeded($renderer);
- return $this->inlineParsers[$name];
+ return $this;
}
/**
- * @return InlineParserInterface[]
+ * {@inheritdoc}
*/
- public function getInlineParsers()
+ public function getBlockParsers(): iterable
{
$this->initializeExtensions();
- return $this->inlineParsers;
+ return $this->blockParsers->getIterator();
}
/**
- * @param string $character
- *
- * @return InlineParserInterface[]
+ * {@inheritdoc}
*/
- public function getInlineParsersForCharacter($character)
+ public function getInlineParsersForCharacter(string $character): iterable
{
$this->initializeExtensions();
@@ -253,66 +240,55 @@ class Environment
return [];
}
- return $this->inlineParsersByCharacter[$character];
+ return $this->inlineParsersByCharacter[$character]->getIterator();
}
/**
- * @return InlineProcessorInterface[]
+ * {@inheritdoc}
*/
- public function getInlineProcessors()
+ public function getInlineProcessors(): iterable
{
$this->initializeExtensions();
- return $this->inlineProcessors;
+ return $this->inlineProcessors->getIterator();
}
/**
- * @return DocumentProcessorInterface[]
+ * {@inheritdoc}
*/
- public function getDocumentProcessors()
+ public function getDocumentProcessors(): iterable
{
$this->initializeExtensions();
- return $this->documentProcessors;
+ return $this->documentProcessors->getIterator();
}
/**
- * @param string $blockClass
- *
- * @return BlockRendererInterface|null
+ * {@inheritdoc}
*/
- public function getBlockRendererForClass($blockClass)
+ public function getBlockRenderersForClass(string $blockClass): iterable
{
$this->initializeExtensions();
if (!isset($this->blockRenderersByClass[$blockClass])) {
- return;
+ return [];
}
- return $this->blockRenderersByClass[$blockClass];
+ return $this->blockRenderersByClass[$blockClass]->getIterator();
}
/**
- * @param string $inlineClass
- *
- * @return InlineRendererInterface|null
+ * {@inheritdoc}
*/
- public function getInlineRendererForClass($inlineClass)
+ public function getInlineRenderersForClass(string $inlineClass): iterable
{
$this->initializeExtensions();
if (!isset($this->inlineRenderersByClass[$inlineClass])) {
- return;
+ return [];
}
- return $this->inlineRenderersByClass[$inlineClass];
- }
-
- public function createInlineParserEngine()
- {
- $this->initializeExtensions();
-
- return new InlineParserEngine($this);
+ return $this->inlineRenderersByClass[$inlineClass]->getIterator();
}
/**
@@ -320,7 +296,7 @@ class Environment
*
* @return ExtensionInterface[]
*/
- public function getExtensions()
+ public function getExtensions(): iterable
{
return $this->extensions;
}
@@ -332,147 +308,53 @@ class Environment
*
* @return $this
*/
- public function addExtension(ExtensionInterface $extension)
+ public function addExtension(ExtensionInterface $extension): ConfigurableEnvironmentInterface
{
$this->assertUninitialized('Failed to add extension.');
$this->extensions[] = $extension;
+ $this->uninitializedExtensions[] = $extension;
return $this;
}
- protected function initializeExtensions()
+ private function initializeExtensions()
{
// Only initialize them once
if ($this->extensionsInitialized) {
return;
}
- $this->extensionsInitialized = true;
-
- // Initialize all the registered extensions
- foreach ($this->extensions as $extension) {
- $this->initializeExtension($extension);
+ // Ask all extensions to register their components
+ while (!empty($this->uninitializedExtensions)) {
+ foreach ($this->uninitializedExtensions as $i => $extension) {
+ $extension->register($this);
+ unset($this->uninitializedExtensions[$i]);
+ }
}
+ $this->extensionsInitialized = true;
+
// Lastly, let's build a regex which matches non-inline characters
// This will enable a huge performance boost with inline parsing
$this->buildInlineParserCharacterRegex();
}
- /**
- * @param ExtensionInterface $extension
- */
- protected function initializeExtension(ExtensionInterface $extension)
+ private function injectEnvironmentAndConfigurationIfNeeded($object)
{
- $this->initalizeBlockParsers($extension->getBlockParsers());
- $this->initializeInlineParsers($extension->getInlineParsers());
- $this->initializeInlineProcessors($extension->getInlineProcessors());
- $this->initializeDocumentProcessors($extension->getDocumentProcessors());
- $this->initializeBlockRenderers($extension->getBlockRenderers());
- $this->initializeInlineRenderers($extension->getInlineRenderers());
- }
-
- /**
- * @param BlockParserInterface[] $blockParsers
- */
- private function initalizeBlockParsers($blockParsers)
- {
- foreach ($blockParsers as $blockParser) {
- if ($blockParser instanceof EnvironmentAwareInterface) {
- $blockParser->setEnvironment($this);
- }
-
- if ($blockParser instanceof ConfigurationAwareInterface) {
- $blockParser->setConfiguration($this->config);
- }
-
- $this->blockParsers[$blockParser->getName()] = $blockParser;
+ if ($object instanceof EnvironmentAwareInterface) {
+ $object->setEnvironment($this);
}
- }
-
- /**
- * @param InlineParserInterface[] $inlineParsers
- */
- private function initializeInlineParsers($inlineParsers)
- {
- foreach ($inlineParsers as $inlineParser) {
- if ($inlineParser instanceof EnvironmentAwareInterface) {
- $inlineParser->setEnvironment($this);
- }
- if ($inlineParser instanceof ConfigurationAwareInterface) {
- $inlineParser->setConfiguration($this->config);
- }
-
- $this->inlineParsers[$inlineParser->getName()] = $inlineParser;
-
- foreach ($inlineParser->getCharacters() as $character) {
- $this->inlineParsersByCharacter[$character][] = $inlineParser;
- }
- }
- }
-
- /**
- * @param InlineProcessorInterface[] $inlineProcessors
- */
- private function initializeInlineProcessors($inlineProcessors)
- {
- foreach ($inlineProcessors as $inlineProcessor) {
- $this->inlineProcessors[] = $inlineProcessor;
-
- if ($inlineProcessor instanceof ConfigurationAwareInterface) {
- $inlineProcessor->setConfiguration($this->config);
- }
- }
- }
-
- /**
- * @param DocumentProcessorInterface[] $documentProcessors
- */
- private function initializeDocumentProcessors($documentProcessors)
- {
- foreach ($documentProcessors as $documentProcessor) {
- $this->documentProcessors[] = $documentProcessor;
-
- if ($documentProcessor instanceof ConfigurationAwareInterface) {
- $documentProcessor->setConfiguration($this->config);
- }
- }
- }
-
- /**
- * @param BlockRendererInterface[] $blockRenderers
- */
- private function initializeBlockRenderers($blockRenderers)
- {
- foreach ($blockRenderers as $class => $blockRenderer) {
- $this->blockRenderersByClass[$class] = $blockRenderer;
-
- if ($blockRenderer instanceof ConfigurationAwareInterface) {
- $blockRenderer->setConfiguration($this->config);
- }
- }
- }
-
- /**
- * @param InlineRendererInterface[] $inlineRenderers
- */
- private function initializeInlineRenderers($inlineRenderers)
- {
- foreach ($inlineRenderers as $class => $inlineRenderer) {
- $this->inlineRenderersByClass[$class] = $inlineRenderer;
-
- if ($inlineRenderer instanceof ConfigurationAwareInterface) {
- $inlineRenderer->setConfiguration($this->config);
- }
+ if ($object instanceof ConfigurationAwareInterface) {
+ $object->setConfiguration($this->config);
}
}
/**
* @return Environment
*/
- public static function createCommonMarkEnvironment()
+ public static function createCommonMarkEnvironment(): Environment
{
$environment = new static();
$environment->addExtension(new CommonMarkCoreExtension());
@@ -492,27 +374,23 @@ class Environment
}
/**
- * Regex which matches any character which doesn't indicate an inline element
- *
- * This allows us to parse multiple non-special characters at once
- *
- * @return string
+ * {@inheritdoc}
*/
- public function getInlineParserCharacterRegex()
+ public function getInlineParserCharacterRegex(): string
{
return $this->inlineParserCharacterRegex;
}
private function buildInlineParserCharacterRegex()
{
- $chars = array_keys($this->inlineParsersByCharacter);
+ $chars = \array_keys($this->inlineParsersByCharacter);
if (empty($chars)) {
// If no special inline characters exist then parse the whole line
$this->inlineParserCharacterRegex = '/^.+$/u';
} else {
// Match any character which inline parsers are not interested in
- $this->inlineParserCharacterRegex = '/^[^' . preg_quote(implode('', $chars), '/') . ']+/u';
+ $this->inlineParserCharacterRegex = '/^[^' . \preg_quote(\implode('', $chars), '/') . ']+/u';
}
}
@@ -521,26 +399,10 @@ class Environment
*
* @throws \RuntimeException
*/
- private function assertUninitialized($message)
+ private function assertUninitialized(string $message)
{
if ($this->extensionsInitialized) {
throw new \RuntimeException($message . ' Extensions have already been initialized.');
}
}
-
- /**
- * @return MiscExtension
- */
- private function getMiscExtension()
- {
- $lastExtension = end($this->extensions);
- if ($lastExtension instanceof MiscExtension) {
- return $lastExtension;
- }
-
- $miscExtension = new MiscExtension();
- $this->addExtension($miscExtension);
-
- return $miscExtension;
- }
}
diff --git a/vendor/league/commonmark/src/EnvironmentAwareInterface.php b/vendor/league/commonmark/src/EnvironmentAwareInterface.php
index f62bc3c976..dfe3978d3f 100644
--- a/vendor/league/commonmark/src/EnvironmentAwareInterface.php
+++ b/vendor/league/commonmark/src/EnvironmentAwareInterface.php
@@ -14,9 +14,9 @@ namespace League\CommonMark;
interface EnvironmentAwareInterface
{
/**
- * @param Environment $environment
+ * @param EnvironmentInterface $environment
*
* @return void
*/
- public function setEnvironment(Environment $environment);
+ public function setEnvironment(EnvironmentInterface $environment);
}
diff --git a/vendor/league/commonmark/src/EnvironmentInterface.php b/vendor/league/commonmark/src/EnvironmentInterface.php
new file mode 100644
index 0000000000..5f1c5af121
--- /dev/null
+++ b/vendor/league/commonmark/src/EnvironmentInterface.php
@@ -0,0 +1,78 @@
+<?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;
+
+use League\CommonMark\Block\Parser\BlockParserInterface;
+use League\CommonMark\Block\Renderer\BlockRendererInterface;
+use League\CommonMark\Inline\Parser\InlineParserInterface;
+use League\CommonMark\Inline\Processor\InlineProcessorInterface;
+use League\CommonMark\Inline\Renderer\InlineRendererInterface;
+
+interface EnvironmentInterface
+{
+ const HTML_INPUT_STRIP = 'strip';
+ const HTML_INPUT_ALLOW = 'allow';
+ const HTML_INPUT_ESCAPE = 'escape';
+
+ /**
+ * @param string|null $key
+ * @param mixed $default
+ *
+ * @return mixed
+ */
+ public function getConfig($key = null, $default = null);
+
+ /**
+ * @return iterable<BlockParserInterface>
+ */
+ public function getBlockParsers(): iterable;
+
+ /**
+ * @param string $character
+ *
+ * @return iterable<InlineParserInterface>
+ */
+ public function getInlineParsersForCharacter(string $character): iterable;
+
+ /**
+ * @return iterable<InlineProcessorInterface>
+ */
+ public function getInlineProcessors(): iterable;
+
+ /**
+ * @return iterable<DocumentProcessorInterface>
+ */
+ public function getDocumentProcessors(): iterable;
+
+ /**
+ * @param string $blockClass
+ *
+ * @return iterable<BlockRendererInterface>
+ */
+ public function getBlockRenderersForClass(string $blockClass): iterable;
+
+ /**
+ * @param string $inlineClass
+ *
+ * @return iterable<InlineRendererInterface>
+ */
+ public function getInlineRenderersForClass(string $inlineClass): iterable;
+
+ /**
+ * Regex which matches any character which doesn't indicate an inline element
+ *
+ * This allows us to parse multiple non-special characters at once
+ *
+ * @return string
+ */
+ public function getInlineParserCharacterRegex(): string;
+}
diff --git a/vendor/league/commonmark/src/Extension/CommonMarkCoreExtension.php b/vendor/league/commonmark/src/Extension/CommonMarkCoreExtension.php
index 6a95023999..3c3f7c11c4 100644
--- a/vendor/league/commonmark/src/Extension/CommonMarkCoreExtension.php
+++ b/vendor/league/commonmark/src/Extension/CommonMarkCoreExtension.php
@@ -14,95 +14,62 @@
namespace League\CommonMark\Extension;
+use League\CommonMark\Block\Element as BlockElement;
use League\CommonMark\Block\Parser as BlockParser;
use League\CommonMark\Block\Renderer as BlockRenderer;
+use League\CommonMark\ConfigurableEnvironmentInterface;
+use League\CommonMark\Inline\Element as InlineElement;
use League\CommonMark\Inline\Parser as InlineParser;
use League\CommonMark\Inline\Processor as InlineProcessor;
use League\CommonMark\Inline\Renderer as InlineRenderer;
-class CommonMarkCoreExtension extends Extension
+final class CommonMarkCoreExtension implements ExtensionInterface
{
- /**
- * @return BlockParser\BlockParserInterface[]
- */
- public function getBlockParsers()
+ public function register(ConfigurableEnvironmentInterface $environment)
{
- return [
- // This order is important
- new BlockParser\BlockQuoteParser(),
- new BlockParser\ATXHeadingParser(),
- new BlockParser\FencedCodeParser(),
- new BlockParser\HtmlBlockParser(),
- new BlockParser\SetExtHeadingParser(),
- new BlockParser\ThematicBreakParser(),
- new BlockParser\ListParser(),
- new BlockParser\IndentedCodeParser(),
- new BlockParser\LazyParagraphParser(),
- ];
- }
+ $environment
+ ->addBlockParser(new BlockParser\BlockQuoteParser(), 70)
+ ->addBlockParser(new BlockParser\ATXHeadingParser(), 60)
+ ->addBlockParser(new BlockParser\FencedCodeParser(), 50)
+ ->addBlockParser(new BlockParser\HtmlBlockParser(), 40)
+ ->addBlockParser(new BlockParser\SetExtHeadingParser(), 30)
+ ->addBlockParser(new BlockParser\ThematicBreakParser(), 20)
+ ->addBlockParser(new BlockParser\ListParser(), 10)
+ ->addBlockParser(new BlockParser\IndentedCodeParser(), -100)
+ ->addBlockParser(new BlockParser\LazyParagraphParser(), -200)
- /**
- * @return InlineParser\InlineParserInterface[]
- */
- public function getInlineParsers()
- {
- return [
- new InlineParser\NewlineParser(),
- new InlineParser\BacktickParser(),
- new InlineParser\EscapableParser(),
- new InlineParser\EntityParser(),
- new InlineParser\EmphasisParser(),
- new InlineParser\AutolinkParser(),
- new InlineParser\HtmlInlineParser(),
- new InlineParser\CloseBracketParser(),
- new InlineParser\OpenBracketParser(),
- new InlineParser\BangParser(),
- ];
- }
+ ->addInlineParser(new InlineParser\NewlineParser(), 200)
+ ->addInlineParser(new InlineParser\BacktickParser(), 150)
+ ->addInlineParser(new InlineParser\EscapableParser(), 80)
+ ->addInlineParser(new InlineParser\EntityParser(), 70)
+ ->addInlineParser(new InlineParser\EmphasisParser(), 60)
+ ->addInlineParser(new InlineParser\AutolinkParser(), 50)
+ ->addInlineParser(new InlineParser\HtmlInlineParser(), 40)
+ ->addInlineParser(new InlineParser\CloseBracketParser(), 30)
+ ->addInlineParser(new InlineParser\OpenBracketParser(), 20)
+ ->addInlineParser(new InlineParser\BangParser(), 10)
- /**
- * @return InlineProcessor\InlineProcessorInterface[]
- */
- public function getInlineProcessors()
- {
- return [
- new InlineProcessor\EmphasisProcessor(),
- ];
- }
+ ->addInlineProcessor(new InlineProcessor\EmphasisProcessor(), 0)
- /**
- * @return BlockRenderer\BlockRendererInterface[]
- */
- 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(),
- ];
- }
+ ->addBlockRenderer(BlockElement\BlockQuote::class, new BlockRenderer\BlockQuoteRenderer(), 0)
+ ->addBlockRenderer(BlockElement\Document::class, new BlockRenderer\DocumentRenderer(), 0)
+ ->addBlockRenderer(BlockElement\FencedCode::class, new BlockRenderer\FencedCodeRenderer(), 0)
+ ->addBlockRenderer(BlockElement\Heading::class, new BlockRenderer\HeadingRenderer(), 0)
+ ->addBlockRenderer(BlockElement\HtmlBlock::class, new BlockRenderer\HtmlBlockRenderer(), 0)
+ ->addBlockRenderer(BlockElement\IndentedCode::class, new BlockRenderer\IndentedCodeRenderer(), 0)
+ ->addBlockRenderer(BlockElement\ListBlock::class, new BlockRenderer\ListBlockRenderer(), 0)
+ ->addBlockRenderer(BlockElement\ListItem::class, new BlockRenderer\ListItemRenderer(), 0)
+ ->addBlockRenderer(BlockElement\Paragraph::class, new BlockRenderer\ParagraphRenderer(), 0)
+ ->addBlockRenderer(BlockElement\ThematicBreak::class, new BlockRenderer\ThematicBreakRenderer(), 0)
- /**
- * @return InlineRenderer\InlineRendererInterface[]
- */
- public function getInlineRenderers()
- {
- return [
- 'League\CommonMark\Inline\Element\Code' => new InlineRenderer\CodeRenderer(),
- 'League\CommonMark\Inline\Element\Emphasis' => new InlineRenderer\EmphasisRenderer(),
- 'League\CommonMark\Inline\Element\HtmlInline' => new InlineRenderer\HtmlInlineRenderer(),
- 'League\CommonMark\Inline\Element\Image' => new InlineRenderer\ImageRenderer(),
- 'League\CommonMark\Inline\Element\Link' => new InlineRenderer\LinkRenderer(),
- 'League\CommonMark\Inline\Element\Newline' => new InlineRenderer\NewlineRenderer(),
- 'League\CommonMark\Inline\Element\Strong' => new InlineRenderer\StrongRenderer(),
- 'League\CommonMark\Inline\Element\Text' => new InlineRenderer\TextRenderer(),
- ];
+ ->addInlineRenderer(InlineElement\Code::class, new InlineRenderer\CodeRenderer(), 0)
+ ->addInlineRenderer(InlineElement\Emphasis::class, new InlineRenderer\EmphasisRenderer(), 0)
+ ->addInlineRenderer(InlineElement\HtmlInline::class, new InlineRenderer\HtmlInlineRenderer(), 0)
+ ->addInlineRenderer(InlineElement\Image::class, new InlineRenderer\ImageRenderer(), 0)
+ ->addInlineRenderer(InlineElement\Link::class, new InlineRenderer\LinkRenderer(), 0)
+ ->addInlineRenderer(InlineElement\Newline::class, new InlineRenderer\NewlineRenderer(), 0)
+ ->addInlineRenderer(InlineElement\Strong::class, new InlineRenderer\StrongRenderer(), 0)
+ ->addInlineRenderer(InlineElement\Text::class, new InlineRenderer\TextRenderer(), 0)
+ ;
}
}
diff --git a/vendor/league/commonmark/src/Extension/Extension.php b/vendor/league/commonmark/src/Extension/Extension.php
deleted file mode 100644
index d52249234b..0000000000
--- a/vendor/league/commonmark/src/Extension/Extension.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?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\Extension;
-
-use League\CommonMark\Block\Parser\BlockParserInterface;
-use League\CommonMark\Block\Renderer\BlockRendererInterface;
-use League\CommonMark\DocumentProcessorInterface;
-use League\CommonMark\Inline\Parser\InlineParserInterface;
-use League\CommonMark\Inline\Processor\InlineProcessorInterface;
-use League\CommonMark\Inline\Renderer\InlineRendererInterface;
-
-abstract class Extension implements ExtensionInterface
-{
- /**
- * @return BlockParserInterface[]
- */
- public function getBlockParsers()
- {
- return [];
- }
-
- /**
- * @return InlineParserInterface[]
- */
- public function getInlineParsers()
- {
- return [];
- }
-
- /**
- * @return InlineProcessorInterface[]
- */
- public function getInlineProcessors()
- {
- return [];
- }
-
- /**
- * @return DocumentProcessorInterface[]
- */
- public function getDocumentProcessors()
- {
- return [];
- }
-
- /**
- * @return BlockRendererInterface[]
- */
- public function getBlockRenderers()
- {
- return [];
- }
-
- /**
- * @return InlineRendererInterface[]
- */
- public function getInlineRenderers()
- {
- return [];
- }
-}
diff --git a/vendor/league/commonmark/src/Extension/ExtensionInterface.php b/vendor/league/commonmark/src/Extension/ExtensionInterface.php
index bdfcf8d622..b2e1166138 100644
--- a/vendor/league/commonmark/src/Extension/ExtensionInterface.php
+++ b/vendor/league/commonmark/src/Extension/ExtensionInterface.php
@@ -14,58 +14,9 @@
namespace League\CommonMark\Extension;
-use League\CommonMark\Block\Parser\BlockParserInterface;
-use League\CommonMark\Block\Renderer\BlockRendererInterface;
-use League\CommonMark\DocumentProcessorInterface;
-use League\CommonMark\Inline\Parser\InlineParserInterface;
-use League\CommonMark\Inline\Processor\InlineProcessorInterface;
-use League\CommonMark\Inline\Renderer\InlineRendererInterface;
+use League\CommonMark\ConfigurableEnvironmentInterface;
interface ExtensionInterface
{
- /**
- * Returns a list of block parsers to add to the existing list
- *
- * @return BlockParserInterface[]
- */
- public function getBlockParsers();
-
- /**
- * Returns a list of inline parsers to add to the existing list
- *
- * @return InlineParserInterface[]
- */
- public function getInlineParsers();
-
- /**
- * Returns a list of inline processors to add to the existing list
- *
- * @return InlineProcessorInterface[]
- */
- public function getInlineProcessors();
-
- /**
- * Returns a list of document processors to add to the existing list
- *
- * @return DocumentProcessorInterface[]
- */
- public function getDocumentProcessors();
-
- /**
- * Returns a list of block renderers to add to the existing list
- *
- * The list keys are the block class names which the corresponding value (renderer) will handle.
- *
- * @return BlockRendererInterface[]
- */
- public function getBlockRenderers();
-
- /**
- * Returns a list of inline renderers to add to the existing list
- *
- * The list keys are the inline class names which the corresponding value (renderer) will handle.
- *
- * @return InlineRendererInterface[]
- */
- public function getInlineRenderers();
+ public function register(ConfigurableEnvironmentInterface $environment);
}
diff --git a/vendor/league/commonmark/src/Extension/MiscExtension.php b/vendor/league/commonmark/src/Extension/MiscExtension.php
deleted file mode 100644
index 3feb791423..0000000000
--- a/vendor/league/commonmark/src/Extension/MiscExtension.php
+++ /dev/null
@@ -1,199 +0,0 @@
-<?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\Extension;
-
-use League\CommonMark\Block\Parser\BlockParserInterface;
-use League\CommonMark\Block\Renderer\BlockRendererInterface;
-use League\CommonMark\DocumentProcessorInterface;
-use League\CommonMark\Inline\Parser\InlineParserInterface;
-use League\CommonMark\Inline\Processor\InlineProcessorInterface;
-use League\CommonMark\Inline\Renderer\InlineRendererInterface;
-
-class MiscExtension implements ExtensionInterface
-{
- /**
- * @var BlockParserInterface[]
- */
- protected $blockParsers = [];
-
- /**
- * @var InlineParserInterface[]
- */
- protected $inlineParsers = [];
-
- /**
- * @var InlineProcessorInterface[]
- */
- protected $inlineProcessers = [];
-
- /**
- * @var DocumentProcessorInterface[]
- */
- protected $documentProcessors = [];
-
- /**
- * @var BlockRendererInterface[]
- */
- protected $blockRenderers = [];
-
- /**
- * @var InlineRendererInterface[]
- */
- protected $inlineRenderers = [];
-
- /**
- * Returns a list of block parsers to add to the existing list
- *
- * @return BlockParserInterface[]
- */
- public function getBlockParsers()
- {
- return $this->blockParsers;
- }
-
- /**
- * @param BlockParserInterface $blockParser
- *
- * @return $this
- */
- public function addBlockParser(BlockParserInterface $blockParser)
- {
- $this->blockParsers[] = $blockParser;
-
- return $this;
- }
-
- /**
- * Returns a list of inline parsers to add to the existing list
- *
- * @return InlineParserInterface[]
- */
- public function getInlineParsers()
- {
- return $this->inlineParsers;
- }
-
- /**
- * @param InlineParserInterface $inlineParser
- *
- * @return $this
- */
- public function addInlineParser(InlineParserInterface $inlineParser)
- {
- $this->inlineParsers[] = $inlineParser;
-
- return $this;
- }
-
- /**
- * Returns a list of inline processors to add to the existing list
- *
- * @return InlineProcessorInterface[]
- */
- public function getInlineProcessors()
- {
- return $this->inlineProcessers;
- }
-
- /**
- * @param InlineProcessorInterface $inlineProcessor
- *
- * @return $this
- */
- public function addInlineProcessor(InlineProcessorInterface $inlineProcessor)
- {
- $this->inlineProcessers[] = $inlineProcessor;
-
- return $this;
- }
-
- /**
- * @return DocumentProcessorInterface[]
- */
- public function getDocumentProcessors()
- {
- return $this->documentProcessors;
- }
-
- /**
- * @param DocumentProcessorInterface $documentProcessor
- *
- * @return $this
- */
- public function addDocumentProcessor(DocumentProcessorInterface $documentProcessor)
- {
- $this->documentProcessors[] = $documentProcessor;
-
- return $this;
- }
-
- /**
- * Returns a list of block renderers to add to the existing list
- *
- * The list keys are the block class names which the corresponding value (renderer) will handle.
- *
- * @return BlockRendererInterface[]
- */
- public function getBlockRenderers()
- {
- return $this->blockRenderers;
- }
-
- /**
- * @param string $blockClass
- * @param BlockRendererInterface $blockRenderer
- *
- * @return $this
- */
- public function addBlockRenderer($blockClass, BlockRendererInterface $blockRenderer)
- {
- if (class_exists('League\CommonMark\Block\Element\\' . $blockClass)) {
- $blockClass = 'League\CommonMark\Block\Element\\' . $blockClass;
- }
-
- $this->blockRenderers[$blockClass] = $blockRenderer;
-
- return $this;
- }
-
- /**
- * Returns a list of inline renderers to add to the existing list
- *
- * The list keys are the inline class names which the corresponding value (renderer) will handle.
- *
- * @return InlineRendererInterface[]
- */
- public function getInlineRenderers()
- {
- return $this->inlineRenderers;
- }
-
- /**
- * @param string $inlineClass
- * @param InlineRendererInterface $inlineRenderer
- *
- * @return $this
- */
- public function addInlineRenderer($inlineClass, InlineRendererInterface $inlineRenderer)
- {
- if (class_exists('League\CommonMark\Inline\Element\\' . $inlineClass)) {
- $inlineClass = 'League\CommonMark\Inline\Element\\' . $inlineClass;
- }
-
- $this->inlineRenderers[$inlineClass] = $inlineRenderer;
-
- return $this;
- }
-}
diff --git a/vendor/league/commonmark/src/HtmlElement.php b/vendor/league/commonmark/src/HtmlElement.php
index fee0e44059..c099bb44be 100644
--- a/vendor/league/commonmark/src/HtmlElement.php
+++ b/vendor/league/commonmark/src/HtmlElement.php
@@ -2,6 +2,8 @@
namespace League\CommonMark;
+use League\CommonMark\Util\Xml;
+
class HtmlElement
{
/**
@@ -25,24 +27,24 @@ class HtmlElement
protected $selfClosing = false;
/**
- * @param string $tagName
- * @param string[] $attributes
- * @param HtmlElement|HtmlElement[]|string $contents
- * @param bool $selfClosing
+ * @param string $tagName Name of the HTML tag
+ * @param string[] $attributes Array of attributes (values should be unescaped)
+ * @param HtmlElement|HtmlElement[]|string|null $contents Inner contents, pre-escaped if needed
+ * @param bool $selfClosing Whether the tag is self-closing
*/
- public function __construct($tagName, $attributes = [], $contents = '', $selfClosing = false)
+ public function __construct(string $tagName, array $attributes = [], $contents = '', bool $selfClosing = false)
{
$this->tagName = $tagName;
$this->attributes = $attributes;
$this->selfClosing = $selfClosing;
- $this->setContents($contents);
+ $this->setContents($contents ?? '');
}
/**
* @return string
*/
- public function getTagName()
+ public function getTagName(): string
{
return $this->tagName;
}
@@ -50,7 +52,7 @@ class HtmlElement
/**
* @return string[]
*/
- public function getAllAttributes()
+ public function getAllAttributes(): array
{
return $this->attributes;
}
@@ -60,10 +62,10 @@ class HtmlElement
*
* @return string|null
*/
- public function getAttribute($key)
+ public function getAttribute(string $key): ?string
{
if (!isset($this->attributes[$key])) {
- return;
+ return null;
}
return $this->attributes[$key];
@@ -75,7 +77,7 @@ class HtmlElement
*
* @return $this
*/
- public function setAttribute($key, $value)
+ public function setAttribute(string $key, string $value): self
{
$this->attributes[$key] = $value;
@@ -87,27 +89,29 @@ class HtmlElement
*
* @return HtmlElement|HtmlElement[]|string
*/
- public function getContents($asString = true)
+ public function getContents(bool $asString = true)
{
- if (!$asString || is_string($this->contents)) {
+ if (!$asString || \is_string($this->contents)) {
return $this->contents;
}
- if (is_array($this->contents)) {
- return implode('', $this->contents);
+ if (\is_array($this->contents)) {
+ return \implode('', $this->contents);
}
return (string) $this->contents;
}
/**
+ * Sets the inner contents of the tag (must be pre-escaped if needed)
+ *
* @param HtmlElement|HtmlElement[]|string $contents
*
* @return $this
*/
- public function setContents($contents)
+ public function setContents($contents): self
{
- $this->contents = $contents !== null ? $contents : '';
+ $this->contents = $contents ?? '';
return $this;
}
@@ -115,12 +119,12 @@ class HtmlElement
/**
* @return string
*/
- public function __toString()
+ public function __toString(): string
{
$result = '<' . $this->tagName;
foreach ($this->attributes as $key => $value) {
- $result .= ' ' . $key . '="' . $value . '"';
+ $result .= ' ' . $key . '="' . Xml::escape($value) . '"';
}
if ($this->contents !== '') {
diff --git a/vendor/league/commonmark/src/HtmlRenderer.php b/vendor/league/commonmark/src/HtmlRenderer.php
index 28bcdfe7e2..aba9877061 100644
--- a/vendor/league/commonmark/src/HtmlRenderer.php
+++ b/vendor/league/commonmark/src/HtmlRenderer.php
@@ -15,7 +15,9 @@
namespace League\CommonMark;
use League\CommonMark\Block\Element\AbstractBlock;
+use League\CommonMark\Block\Renderer\BlockRendererInterface;
use League\CommonMark\Inline\Element\AbstractInline;
+use League\CommonMark\Inline\Renderer\InlineRendererInterface;
/**
* Renders a parsed AST to HTML
@@ -23,14 +25,14 @@ use League\CommonMark\Inline\Element\AbstractInline;
class HtmlRenderer implements ElementRendererInterface
{
/**
- * @var Environment
+ * @var EnvironmentInterface
*/
protected $environment;
/**
- * @param Environment $environment
+ * @param EnvironmentInterface $environment
*/
- public function __construct(Environment $environment)
+ public function __construct(EnvironmentInterface $environment)
{
$this->environment = $environment;
}
@@ -39,9 +41,9 @@ class HtmlRenderer implements ElementRendererInterface
* @param string $option
* @param mixed $default
*
- * @return mixed
+ * @return mixed|null
*/
- public function getOption($option, $default = null)
+ public function getOption(string $option, $default = null)
{
return $this->environment->getConfig('renderer/' . $option, $default);
}
@@ -53,14 +55,18 @@ class HtmlRenderer implements ElementRendererInterface
*
* @return string
*/
- protected function renderInline(AbstractInline $inline)
+ protected function renderInline(AbstractInline $inline): string
{
- $renderer = $this->environment->getInlineRendererForClass(get_class($inline));
- if (!$renderer) {
- throw new \RuntimeException('Unable to find corresponding renderer for inline type ' . get_class($inline));
+ $renderers = $this->environment->getInlineRenderersForClass(get_class($inline));
+
+ /** @var InlineRendererInterface $renderer */
+ foreach ($renderers as $renderer) {
+ if (($result = $renderer->render($inline, $this)) !== null) {
+ return $result;
+ }
}
- return $renderer->render($inline, $this);
+ throw new \RuntimeException('Unable to find corresponding renderer for inline type ' . \get_class($inline));
}
/**
@@ -68,14 +74,14 @@ class HtmlRenderer implements ElementRendererInterface
*
* @return string
*/
- public function renderInlines($inlines)
+ public function renderInlines(iterable $inlines): string
{
$result = [];
foreach ($inlines as $inline) {
$result[] = $this->renderInline($inline);
}
- return implode('', $result);
+ return \implode('', $result);
}
/**
@@ -86,14 +92,18 @@ class HtmlRenderer implements ElementRendererInterface
*
* @return string
*/
- public function renderBlock(AbstractBlock $block, $inTightList = false)
+ public function renderBlock(AbstractBlock $block, bool $inTightList = false): string
{
- $renderer = $this->environment->getBlockRendererForClass(get_class($block));
- if (!$renderer) {
- throw new \RuntimeException('Unable to find corresponding renderer for block type ' . get_class($block));
+ $renderers = $this->environment->getBlockRenderersForClass(\get_class($block));
+
+ /** @var BlockRendererInterface $renderer */
+ foreach ($renderers as $renderer) {
+ if (($result = $renderer->render($block, $this, $inTightList)) !== null) {
+ return $result;
+ }
}
- return $renderer->render($block, $this, $inTightList);
+ throw new \RuntimeException('Unable to find corresponding renderer for block type ' . \get_class($block));
}
/**
@@ -102,7 +112,7 @@ class HtmlRenderer implements ElementRendererInterface
*
* @return string
*/
- public function renderBlocks($blocks, $inTightList = false)
+ public function renderBlocks(iterable $blocks, bool $inTightList = false): string
{
$result = [];
foreach ($blocks as $block) {
@@ -111,6 +121,6 @@ class HtmlRenderer implements ElementRendererInterface
$separator = $this->getOption('block_separator', "\n");
- return implode($separator, $result);
+ return \implode($separator, $result);
}
}
diff --git a/vendor/league/commonmark/src/Inline/Element/AbstractInline.php b/vendor/league/commonmark/src/Inline/Element/AbstractInline.php
index 6d6b43410e..2406148dfe 100644
--- a/vendor/league/commonmark/src/Inline/Element/AbstractInline.php
+++ b/vendor/league/commonmark/src/Inline/Element/AbstractInline.php
@@ -28,7 +28,7 @@ abstract class AbstractInline extends Node
/**
* @return bool
*/
- public function isContainer()
+ public function isContainer(): bool
{
return false;
}
@@ -39,7 +39,7 @@ abstract class AbstractInline extends Node
*
* @return mixed
*/
- public function getData($key, $default = null)
+ public function getData(string $key, $default = null)
{
return isset($this->data[$key]) ? $this->data[$key] : $default;
}
diff --git a/vendor/league/commonmark/src/Inline/Element/AbstractInlineContainer.php b/vendor/league/commonmark/src/Inline/Element/AbstractInlineContainer.php
index 00dbacce1f..a80bd8981e 100644
--- a/vendor/league/commonmark/src/Inline/Element/AbstractInlineContainer.php
+++ b/vendor/league/commonmark/src/Inline/Element/AbstractInlineContainer.php
@@ -19,7 +19,7 @@ abstract class AbstractInlineContainer extends AbstractInline
/**
* @return bool
*/
- public function isContainer()
+ public function isContainer(): bool
{
return true;
}
diff --git a/vendor/league/commonmark/src/Inline/Element/AbstractStringContainer.php b/vendor/league/commonmark/src/Inline/Element/AbstractStringContainer.php
index edb26561af..4cc5221274 100644
--- a/vendor/league/commonmark/src/Inline/Element/AbstractStringContainer.php
+++ b/vendor/league/commonmark/src/Inline/Element/AbstractStringContainer.php
@@ -25,7 +25,7 @@ class AbstractStringContainer extends AbstractInline
* @param string $contents
* @param array $data
*/
- public function __construct($contents = '', array $data = [])
+ public function __construct(string $contents = '', array $data = [])
{
$this->content = $contents;
$this->data = $data;
@@ -34,7 +34,7 @@ class AbstractStringContainer extends AbstractInline
/**
* @return string
*/
- public function getContent()
+ public function getContent(): string
{
return $this->content;
}
@@ -44,7 +44,7 @@ class AbstractStringContainer extends AbstractInline
*
* @return $this
*/
- public function setContent($contents)
+ public function setContent(string $contents)
{
$this->content = $contents;
diff --git a/vendor/league/commonmark/src/Inline/Element/AbstractWebResource.php b/vendor/league/commonmark/src/Inline/Element/AbstractWebResource.php
index 1662fc0d06..b39044fa74 100644
--- a/vendor/league/commonmark/src/Inline/Element/AbstractWebResource.php
+++ b/vendor/league/commonmark/src/Inline/Element/AbstractWebResource.php
@@ -21,7 +21,7 @@ abstract class AbstractWebResource extends AbstractInlineContainer
*/
protected $url;
- public function __construct($url)
+ public function __construct(string $url)
{
$this->url = $url;
}
@@ -29,7 +29,7 @@ abstract class AbstractWebResource extends AbstractInlineContainer
/**
* @return string
*/
- public function getUrl()
+ public function getUrl(): string
{
return $this->url;
}
@@ -39,7 +39,7 @@ abstract class AbstractWebResource extends AbstractInlineContainer
*
* @return $this
*/
- public function setUrl($url)
+ public function setUrl(string $url)
{
$this->url = $url;
diff --git a/vendor/league/commonmark/src/Inline/Element/Image.php b/vendor/league/commonmark/src/Inline/Element/Image.php
index c05efb7da3..250f930c58 100644
--- a/vendor/league/commonmark/src/Inline/Element/Image.php
+++ b/vendor/league/commonmark/src/Inline/Element/Image.php
@@ -17,15 +17,15 @@ namespace League\CommonMark\Inline\Element;
class Image extends AbstractWebResource
{
/**
- * @param string $url
- * @param string $label
- * @param string $title
+ * @param string $url
+ * @param string|null $label
+ * @param string|null $title
*/
- public function __construct($url, $label = '', $title = '')
+ public function __construct(string $url, ?string $label = null, ?string $title = null)
{
parent::__construct($url);
- if (is_string($label)) {
+ if (!empty($label)) {
$this->appendChild(new Text($label));
}
diff --git a/vendor/league/commonmark/src/Inline/Element/Link.php b/vendor/league/commonmark/src/Inline/Element/Link.php
index 571798be46..4967c2611a 100644
--- a/vendor/league/commonmark/src/Inline/Element/Link.php
+++ b/vendor/league/commonmark/src/Inline/Element/Link.php
@@ -19,13 +19,13 @@ class Link extends AbstractWebResource
/**
* @param string $url
* @param string|null $label
- * @param string $title
+ * @param string|null $title
*/
- public function __construct($url, $label = null, $title = '')
+ public function __construct(string $url, ?string $label = null, ?string $title = null)
{
parent::__construct($url);
- if (is_string($label)) {
+ if (!empty($label)) {
$this->appendChild(new Text($label));
}
diff --git a/vendor/league/commonmark/src/Inline/Element/Newline.php b/vendor/league/commonmark/src/Inline/Element/Newline.php
index 1d7cc7e219..dc86d2dcce 100644
--- a/vendor/league/commonmark/src/Inline/Element/Newline.php
+++ b/vendor/league/commonmark/src/Inline/Element/Newline.php
@@ -16,6 +16,7 @@ namespace League\CommonMark\Inline\Element;
class Newline extends AbstractInline
{
+ // Any changes to these constants should be reflected in .phpstorm.meta.php
const HARDBREAK = 0;
const SOFTBREAK = 1;
@@ -24,7 +25,7 @@ class Newline extends AbstractInline
/**
* @param int $breakType
*/
- public function __construct($breakType = self::HARDBREAK)
+ public function __construct(int $breakType = self::HARDBREAK)
{
$this->type = $breakType;
}
@@ -32,7 +33,7 @@ class Newline extends AbstractInline
/**
* @return int
*/
- public function getType()
+ public function getType(): int
{
return $this->type;
}
diff --git a/vendor/league/commonmark/src/Inline/Element/Text.php b/vendor/league/commonmark/src/Inline/Element/Text.php
index 4e851bd6ad..6afbe36d88 100644
--- a/vendor/league/commonmark/src/Inline/Element/Text.php
+++ b/vendor/league/commonmark/src/Inline/Element/Text.php
@@ -19,7 +19,7 @@ class Text extends AbstractStringContainer
/**
* @param string $character
*/
- public function append($character)
+ public function append(string $character)
{
$this->content .= $character;
}
diff --git a/vendor/league/commonmark/src/Inline/Parser/AbstractInlineParser.php b/vendor/league/commonmark/src/Inline/Parser/AbstractInlineParser.php
deleted file mode 100644
index 1c819f333a..0000000000
--- a/vendor/league/commonmark/src/Inline/Parser/AbstractInlineParser.php
+++ /dev/null
@@ -1,32 +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\Inline\Parser;
-
-/**
- * Class AbstractInlineParser
- */
-abstract class AbstractInlineParser implements InlineParserInterface
-{
- /**
- * Get the name of the parser
- *
- * Note that this must be unique with its block type.
- *
- * @return string
- */
- public function getName()
- {
- $reflection = new \ReflectionClass($this);
-
- return $reflection->getShortName();
- }
-}
diff --git a/vendor/league/commonmark/src/Inline/Parser/AutolinkParser.php b/vendor/league/commonmark/src/Inline/Parser/AutolinkParser.php
index ec5a08c1ff..b61dc963f0 100644
--- a/vendor/league/commonmark/src/Inline/Parser/AutolinkParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/AutolinkParser.php
@@ -18,7 +18,7 @@ use League\CommonMark\Inline\Element\Link;
use League\CommonMark\InlineParserContext;
use League\CommonMark\Util\UrlEncoder;
-class AutolinkParser extends AbstractInlineParser
+class AutolinkParser implements InlineParserInterface
{
const EMAIL_REGEX = '/^<([a-zA-Z0-9.!#$%&\'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/';
const OTHER_LINK_REGEX = '/^<[A-Za-z][A-Za-z0-9.+-]{1,31}:[^<>\x00-\x20]*>/i';
@@ -26,7 +26,7 @@ class AutolinkParser extends AbstractInlineParser
/**
* @return string[]
*/
- public function getCharacters()
+ public function getCharacters(): array
{
return ['<'];
}
@@ -36,16 +36,16 @@ class AutolinkParser extends AbstractInlineParser
*
* @return bool
*/
- public function parse(InlineParserContext $inlineContext)
+ public function parse(InlineParserContext $inlineContext): bool
{
$cursor = $inlineContext->getCursor();
if ($m = $cursor->match(self::EMAIL_REGEX)) {
- $email = substr($m, 1, -1);
+ $email = \substr($m, 1, -1);
$inlineContext->getContainer()->appendChild(new Link('mailto:' . UrlEncoder::unescapeAndEncode($email), $email));
return true;
} elseif ($m = $cursor->match(self::OTHER_LINK_REGEX)) {
- $dest = substr($m, 1, -1);
+ $dest = \substr($m, 1, -1);
$inlineContext->getContainer()->appendChild(new Link(UrlEncoder::unescapeAndEncode($dest), $dest));
return true;
diff --git a/vendor/league/commonmark/src/Inline/Parser/BacktickParser.php b/vendor/league/commonmark/src/Inline/Parser/BacktickParser.php
index 6a16703ca5..f74e5413ed 100644
--- a/vendor/league/commonmark/src/Inline/Parser/BacktickParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/BacktickParser.php
@@ -17,14 +17,13 @@ namespace League\CommonMark\Inline\Parser;
use League\CommonMark\Inline\Element\Code;
use League\CommonMark\Inline\Element\Text;
use League\CommonMark\InlineParserContext;
-use League\CommonMark\Util\RegexHelper;
-class BacktickParser extends AbstractInlineParser
+class BacktickParser implements InlineParserInterface
{
/**
* @return string[]
*/
- public function getCharacters()
+ public function getCharacters(): array
{
return ['`'];
}
@@ -34,7 +33,7 @@ class BacktickParser extends AbstractInlineParser
*
* @return bool
*/
- public function parse(InlineParserContext $inlineContext)
+ public function parse(InlineParserContext $inlineContext): bool
{
$cursor = $inlineContext->getCursor();
@@ -48,9 +47,14 @@ class BacktickParser extends AbstractInlineParser
while ($matchingTicks = $cursor->match('/`+/m')) {
if ($matchingTicks === $ticks) {
- $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)));
+ $code = \mb_substr($cursor->getLine(), $currentPosition, $cursor->getPosition() - $currentPosition - \strlen($ticks), 'utf-8');
+ $c = \preg_replace('/\n/m', ' ', $code);
+
+ if ($c !== '' && \preg_match('/[^ ]/', $c) && \mb_substr($c, 0, 1) === ' ' && \mb_substr($c, -1, 1) === ' ') {
+ $c = \mb_substr($c, 1, -1);
+ }
+
+ $inlineContext->getContainer()->appendChild(new Code($c));
return true;
}
diff --git a/vendor/league/commonmark/src/Inline/Parser/BangParser.php b/vendor/league/commonmark/src/Inline/Parser/BangParser.php
index 02d8ddd630..59740263d5 100644
--- a/vendor/league/commonmark/src/Inline/Parser/BangParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/BangParser.php
@@ -18,12 +18,12 @@ use League\CommonMark\Delimiter\Delimiter;
use League\CommonMark\Inline\Element\Text;
use League\CommonMark\InlineParserContext;
-class BangParser extends AbstractInlineParser
+class BangParser implements InlineParserInterface
{
/**
* @return string[]
*/
- public function getCharacters()
+ public function getCharacters(): array
{
return ['!'];
}
@@ -33,7 +33,7 @@ class BangParser extends AbstractInlineParser
*
* @return bool
*/
- public function parse(InlineParserContext $inlineContext)
+ public function parse(InlineParserContext $inlineContext): bool
{
$cursor = $inlineContext->getCursor();
if ($cursor->peek() === '[') {
diff --git a/vendor/league/commonmark/src/Inline/Parser/CloseBracketParser.php b/vendor/league/commonmark/src/Inline/Parser/CloseBracketParser.php
index 70388d6e54..71ca2e8ddb 100644
--- a/vendor/league/commonmark/src/Inline/Parser/CloseBracketParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/CloseBracketParser.php
@@ -17,8 +17,8 @@ namespace League\CommonMark\Inline\Parser;
use League\CommonMark\Cursor;
use League\CommonMark\Delimiter\Delimiter;
use League\CommonMark\Delimiter\DelimiterStack;
-use League\CommonMark\Environment;
use League\CommonMark\EnvironmentAwareInterface;
+use League\CommonMark\EnvironmentInterface;
use League\CommonMark\Inline\Element\AbstractWebResource;
use League\CommonMark\Inline\Element\Image;
use League\CommonMark\Inline\Element\Link;
@@ -28,17 +28,17 @@ use League\CommonMark\Reference\ReferenceMap;
use League\CommonMark\Util\LinkParserHelper;
use League\CommonMark\Util\RegexHelper;
-class CloseBracketParser extends AbstractInlineParser implements EnvironmentAwareInterface
+class CloseBracketParser implements InlineParserInterface, EnvironmentAwareInterface
{
/**
- * @var Environment
+ * @var EnvironmentInterface
*/
protected $environment;
/**
* @return string[]
*/
- public function getCharacters()
+ public function getCharacters(): array
{
return [']'];
}
@@ -48,7 +48,7 @@ class CloseBracketParser extends AbstractInlineParser implements EnvironmentAwar
*
* @return bool
*/
- public function parse(InlineParserContext $inlineContext)
+ public function parse(InlineParserContext $inlineContext): bool
{
// Look through stack of delimiters for a [ or !
$opener = $inlineContext->getDelimiterStack()->searchByCharacter(['[', '!']);
@@ -106,9 +106,9 @@ class CloseBracketParser extends AbstractInlineParser implements EnvironmentAwar
}
/**
- * @param Environment $environment
+ * @param EnvironmentInterface $environment
*/
- public function setEnvironment(Environment $environment)
+ public function setEnvironment(EnvironmentInterface $environment)
{
$this->environment = $environment;
}
@@ -121,7 +121,7 @@ class CloseBracketParser extends AbstractInlineParser implements EnvironmentAwar
*
* @return array|bool
*/
- protected function tryParseLink(Cursor $cursor, ReferenceMap $referenceMap, Delimiter $opener, $startPos)
+ protected function tryParseLink(Cursor $cursor, ReferenceMap $referenceMap, Delimiter $opener, int $startPos)
{
// Check to see if we have a link/image
// Inline link?
@@ -159,10 +159,10 @@ class CloseBracketParser extends AbstractInlineParser implements EnvironmentAwar
$cursor->advanceToNextNonSpaceOrNewline();
- $title = null;
+ $title = '';
// make sure there's a space before the title:
- if (preg_match(RegexHelper::REGEX_WHITESPACE_CHAR, $cursor->peek(-1))) {
- $title = LinkParserHelper::parseLinkTitle($cursor) ?: '';
+ if (\preg_match(RegexHelper::REGEX_WHITESPACE_CHAR, $cursor->peek(-1))) {
+ $title = LinkParserHelper::parseLinkTitle($cursor) ?? '';
}
$cursor->advanceToNextNonSpaceOrNewline();
@@ -184,16 +184,16 @@ class CloseBracketParser extends AbstractInlineParser implements EnvironmentAwar
*
* @return Reference|null
*/
- protected function tryParseReference(Cursor $cursor, ReferenceMap $referenceMap, Delimiter $opener, $startPos)
+ protected function tryParseReference(Cursor $cursor, ReferenceMap $referenceMap, Delimiter $opener, int $startPos): ?Reference
{
$savePos = $cursor->saveState();
$beforeLabel = $cursor->getPosition();
$n = LinkParserHelper::parseLinkLabel($cursor);
if ($n === 0 || $n === 2) {
// Empty or missing second label
- $reflabel = mb_substr($cursor->getLine(), $opener->getIndex(), $startPos - $opener->getIndex(), 'utf-8');
+ $reflabel = \mb_substr($cursor->getLine(), $opener->getIndex(), $startPos - $opener->getIndex(), 'utf-8');
} else {
- $reflabel = mb_substr($cursor->getLine(), $beforeLabel + 1, $n - 2, 'utf-8');
+ $reflabel = \mb_substr($cursor->getLine(), $beforeLabel + 1, $n - 2, 'utf-8');
}
if ($n === 0) {
@@ -211,7 +211,7 @@ class CloseBracketParser extends AbstractInlineParser implements EnvironmentAwar
*
* @return AbstractWebResource
*/
- protected function createInline($url, $title, $isImage)
+ protected function createInline(string $url, string $title, bool $isImage)
{
if ($isImage) {
return new Image($url, null, $title);
diff --git a/vendor/league/commonmark/src/Inline/Parser/EmphasisParser.php b/vendor/league/commonmark/src/Inline/Parser/EmphasisParser.php
index 72993e9457..f58022b869 100644
--- a/vendor/league/commonmark/src/Inline/Parser/EmphasisParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/EmphasisParser.php
@@ -15,14 +15,14 @@
namespace League\CommonMark\Inline\Parser;
use League\CommonMark\Delimiter\Delimiter;
-use League\CommonMark\Environment;
use League\CommonMark\EnvironmentAwareInterface;
+use League\CommonMark\EnvironmentInterface;
use League\CommonMark\Inline\Element\Text;
use League\CommonMark\InlineParserContext;
use League\CommonMark\Util\Configuration;
use League\CommonMark\Util\RegexHelper;
-class EmphasisParser extends AbstractInlineParser implements EnvironmentAwareInterface
+class EmphasisParser implements InlineParserInterface, EnvironmentAwareInterface
{
protected $config;
@@ -37,7 +37,7 @@ class EmphasisParser extends AbstractInlineParser implements EnvironmentAwareInt
$this->config->mergeConfig($newConfig);
}
- public function setEnvironment(Environment $environment)
+ public function setEnvironment(EnvironmentInterface $environment)
{
$this->config->mergeConfig($environment->getConfig());
}
@@ -45,7 +45,7 @@ class EmphasisParser extends AbstractInlineParser implements EnvironmentAwareInt
/**
* @return string[]
*/
- public function getCharacters()
+ public function getCharacters(): array
{
if (!$this->config->getConfig('enable_em') && !$this->config->getConfig('enable_strong')) {
return [];
@@ -67,10 +67,10 @@ class EmphasisParser extends AbstractInlineParser implements EnvironmentAwareInt
*
* @return bool
*/
- public function parse(InlineParserContext $inlineContext)
+ public function parse(InlineParserContext $inlineContext): bool
{
$character = $inlineContext->getCursor()->getCharacter();
- if (!in_array($character, $this->getCharacters())) {
+ if (!\in_array($character, $this->getCharacters())) {
return false;
}
@@ -124,12 +124,12 @@ class EmphasisParser extends AbstractInlineParser implements EnvironmentAwareInt
*
* @return bool[]
*/
- private function determineCanOpenOrClose($charBefore, $charAfter, $character)
+ private function determineCanOpenOrClose(string $charBefore, string $charAfter, string $character)
{
- $afterIsWhitespace = preg_match(RegexHelper::REGEX_UNICODE_WHITESPACE_CHAR, $charAfter);
- $afterIsPunctuation = preg_match(RegexHelper::REGEX_PUNCTUATION, $charAfter);
- $beforeIsWhitespace = preg_match(RegexHelper::REGEX_UNICODE_WHITESPACE_CHAR, $charBefore);
- $beforeIsPunctuation = preg_match(RegexHelper::REGEX_PUNCTUATION, $charBefore);
+ $afterIsWhitespace = \preg_match(RegexHelper::REGEX_UNICODE_WHITESPACE_CHAR, $charAfter);
+ $afterIsPunctuation = \preg_match(RegexHelper::REGEX_PUNCTUATION, $charAfter);
+ $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);
diff --git a/vendor/league/commonmark/src/Inline/Parser/EntityParser.php b/vendor/league/commonmark/src/Inline/Parser/EntityParser.php
index 242f9ab516..83a207f7f8 100644
--- a/vendor/league/commonmark/src/Inline/Parser/EntityParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/EntityParser.php
@@ -19,12 +19,12 @@ use League\CommonMark\InlineParserContext;
use League\CommonMark\Util\Html5Entities;
use League\CommonMark\Util\RegexHelper;
-class EntityParser extends AbstractInlineParser
+class EntityParser implements InlineParserInterface
{
/**
* @return string[]
*/
- public function getCharacters()
+ public function getCharacters(): array
{
return ['&'];
}
@@ -34,7 +34,7 @@ class EntityParser extends AbstractInlineParser
*
* @return bool
*/
- public function parse(InlineParserContext $inlineContext)
+ public function parse(InlineParserContext $inlineContext): bool
{
if ($m = $inlineContext->getCursor()->match('/^' . RegexHelper::PARTIAL_ENTITY . '/i')) {
$inlineContext->getContainer()->appendChild(new Text(Html5Entities::decodeEntity($m)));
diff --git a/vendor/league/commonmark/src/Inline/Parser/EscapableParser.php b/vendor/league/commonmark/src/Inline/Parser/EscapableParser.php
index 3f18b04e6e..d96400ab77 100644
--- a/vendor/league/commonmark/src/Inline/Parser/EscapableParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/EscapableParser.php
@@ -19,12 +19,12 @@ use League\CommonMark\Inline\Element\Text;
use League\CommonMark\InlineParserContext;
use League\CommonMark\Util\RegexHelper;
-class EscapableParser extends AbstractInlineParser
+class EscapableParser implements InlineParserInterface
{
/**
* @return string[]
*/
- public function getCharacters()
+ public function getCharacters(): array
{
return ['\\'];
}
@@ -34,7 +34,7 @@ class EscapableParser extends AbstractInlineParser
*
* @return bool
*/
- public function parse(InlineParserContext $inlineContext)
+ public function parse(InlineParserContext $inlineContext): bool
{
$cursor = $inlineContext->getCursor();
if ($cursor->getCharacter() !== '\\') {
@@ -48,7 +48,7 @@ class EscapableParser extends AbstractInlineParser
$inlineContext->getContainer()->appendChild(new Newline(Newline::HARDBREAK));
return true;
- } elseif (RegexHelper::isEscapable($nextChar)) {
+ } elseif ($nextChar !== null && RegexHelper::isEscapable($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 c6db4f44d7..297f088842 100644
--- a/vendor/league/commonmark/src/Inline/Parser/HtmlInlineParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/HtmlInlineParser.php
@@ -18,12 +18,12 @@ use League\CommonMark\Inline\Element\HtmlInline;
use League\CommonMark\InlineParserContext;
use League\CommonMark\Util\RegexHelper;
-class HtmlInlineParser extends AbstractInlineParser
+class HtmlInlineParser implements InlineParserInterface
{
/**
* @return string[]
*/
- public function getCharacters()
+ public function getCharacters(): array
{
return ['<'];
}
@@ -33,7 +33,7 @@ class HtmlInlineParser extends AbstractInlineParser
*
* @return bool
*/
- public function parse(InlineParserContext $inlineContext)
+ public function parse(InlineParserContext $inlineContext): bool
{
$cursor = $inlineContext->getCursor();
if ($m = $cursor->match('/^' . RegexHelper::PARTIAL_HTMLTAG . '/i')) {
diff --git a/vendor/league/commonmark/src/Inline/Parser/InlineParserInterface.php b/vendor/league/commonmark/src/Inline/Parser/InlineParserInterface.php
index 4c8a6aebd7..4971ec3d2d 100644
--- a/vendor/league/commonmark/src/Inline/Parser/InlineParserInterface.php
+++ b/vendor/league/commonmark/src/Inline/Parser/InlineParserInterface.php
@@ -16,23 +16,14 @@ use League\CommonMark\InlineParserContext;
interface InlineParserInterface
{
/**
- * Get the name of the parser
- *
- * Note that this must be unique with its block type.
- *
- * @return string
- */
- public function getName();
-
- /**
* @return string[]
*/
- public function getCharacters();
+ public function getCharacters(): array;
/**
* @param InlineParserContext $inlineContext
*
* @return bool
*/
- public function parse(InlineParserContext $inlineContext);
+ public function parse(InlineParserContext $inlineContext): bool;
}
diff --git a/vendor/league/commonmark/src/Inline/Parser/NewlineParser.php b/vendor/league/commonmark/src/Inline/Parser/NewlineParser.php
index 36e470f133..1ca8c01f52 100644
--- a/vendor/league/commonmark/src/Inline/Parser/NewlineParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/NewlineParser.php
@@ -18,12 +18,12 @@ use League\CommonMark\Inline\Element\Newline;
use League\CommonMark\Inline\Element\Text;
use League\CommonMark\InlineParserContext;
-class NewlineParser extends AbstractInlineParser
+class NewlineParser implements InlineParserInterface
{
/**
* @return string[]
*/
- public function getCharacters()
+ public function getCharacters(): array
{
return ["\n"];
}
@@ -33,7 +33,7 @@ class NewlineParser extends AbstractInlineParser
*
* @return bool
*/
- public function parse(InlineParserContext $inlineContext)
+ public function parse(InlineParserContext $inlineContext): bool
{
$inlineContext->getCursor()->advance();
@@ -41,8 +41,8 @@ class NewlineParser extends AbstractInlineParser
$spaces = 0;
$lastInline = $inlineContext->getContainer()->lastChild();
if ($lastInline && $lastInline instanceof Text) {
- $trimmed = rtrim($lastInline->getContent(), ' ');
- $spaces = strlen($lastInline->getContent()) - strlen($trimmed);
+ $trimmed = \rtrim($lastInline->getContent(), ' ');
+ $spaces = \strlen($lastInline->getContent()) - \strlen($trimmed);
if ($spaces) {
$lastInline->setContent($trimmed);
}
diff --git a/vendor/league/commonmark/src/Inline/Parser/OpenBracketParser.php b/vendor/league/commonmark/src/Inline/Parser/OpenBracketParser.php
index cfa04090a5..81c453d918 100644
--- a/vendor/league/commonmark/src/Inline/Parser/OpenBracketParser.php
+++ b/vendor/league/commonmark/src/Inline/Parser/OpenBracketParser.php
@@ -18,12 +18,12 @@ use League\CommonMark\Delimiter\Delimiter;
use League\CommonMark\Inline\Element\Text;
use League\CommonMark\InlineParserContext;
-class OpenBracketParser extends AbstractInlineParser
+class OpenBracketParser implements InlineParserInterface
{
/**
* @return string[]
*/
- public function getCharacters()
+ public function getCharacters(): array
{
return ['['];
}
@@ -33,7 +33,7 @@ class OpenBracketParser extends AbstractInlineParser
*
* @return bool
*/
- public function parse(InlineParserContext $inlineContext)
+ public function parse(InlineParserContext $inlineContext): bool
{
if ($inlineContext->getCursor()->getCharacter() !== '[') {
return false;
diff --git a/vendor/league/commonmark/src/Inline/Processor/EmphasisProcessor.php b/vendor/league/commonmark/src/Inline/Processor/EmphasisProcessor.php
index b6c6f9cb98..1bc96162ec 100644
--- a/vendor/league/commonmark/src/Inline/Processor/EmphasisProcessor.php
+++ b/vendor/league/commonmark/src/Inline/Processor/EmphasisProcessor.php
@@ -35,8 +35,8 @@ class EmphasisProcessor implements InlineProcessorInterface
// Remove used delimiters from stack elts and inlines
$opener->setNumDelims($opener->getNumDelims() - $useDelims);
$closer->setNumDelims($closer->getNumDelims() - $useDelims);
- $openerInline->setContent(substr($openerInline->getContent(), 0, -$useDelims));
- $closerInline->setContent(substr($closerInline->getContent(), 0, -$useDelims));
+ $openerInline->setContent(\substr($openerInline->getContent(), 0, -$useDelims));
+ $closerInline->setContent(\substr($closerInline->getContent(), 0, -$useDelims));
// Build contents for new emph element
if ($useDelims === 1 && $openerInline->data['emphasis_config']->getConfig('enable_em')) {
diff --git a/vendor/league/commonmark/src/Inline/Renderer/CodeRenderer.php b/vendor/league/commonmark/src/Inline/Renderer/CodeRenderer.php
index b76fb5568d..d629b16d6f 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/CodeRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/CodeRenderer.php
@@ -31,13 +31,10 @@ class CodeRenderer implements InlineRendererInterface
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
{
if (!($inline instanceof Code)) {
- throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
+ throw new \InvalidArgumentException('Incompatible inline type: ' . \get_class($inline));
}
- $attrs = [];
- foreach ($inline->getData('attributes', []) as $key => $value) {
- $attrs[$key] = Xml::escape($value);
- }
+ $attrs = $inline->getData('attributes', []);
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 715ea966b1..ac06590a66 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/EmphasisRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/EmphasisRenderer.php
@@ -18,7 +18,6 @@ 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
{
@@ -31,13 +30,10 @@ class EmphasisRenderer implements InlineRendererInterface
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
{
if (!($inline instanceof Emphasis)) {
- throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
+ throw new \InvalidArgumentException('Incompatible inline type: ' . \get_class($inline));
}
- $attrs = [];
- foreach ($inline->getData('attributes', []) as $key => $value) {
- $attrs[$key] = Xml::escape($value);
- }
+ $attrs = $inline->getData('attributes', []);
return new HtmlElement('em', $attrs, $htmlRenderer->renderInlines($inline->children()));
}
diff --git a/vendor/league/commonmark/src/Inline/Renderer/HtmlInlineRenderer.php b/vendor/league/commonmark/src/Inline/Renderer/HtmlInlineRenderer.php
index fac12063d3..720a8c6c19 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/HtmlInlineRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/HtmlInlineRenderer.php
@@ -15,7 +15,7 @@
namespace League\CommonMark\Inline\Renderer;
use League\CommonMark\ElementRendererInterface;
-use League\CommonMark\Environment;
+use League\CommonMark\EnvironmentInterface;
use League\CommonMark\Inline\Element\AbstractInline;
use League\CommonMark\Inline\Element\HtmlInline;
use League\CommonMark\Util\Configuration;
@@ -37,7 +37,7 @@ class HtmlInlineRenderer implements InlineRendererInterface, ConfigurationAwareI
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
{
if (!($inline instanceof HtmlInline)) {
- throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
+ throw new \InvalidArgumentException('Incompatible inline type: ' . \get_class($inline));
}
// Kept for BC reasons
@@ -45,11 +45,11 @@ class HtmlInlineRenderer implements InlineRendererInterface, ConfigurationAwareI
return '';
}
- if ($this->config->getConfig('html_input') === Environment::HTML_INPUT_STRIP) {
+ if ($this->config->getConfig('html_input') === EnvironmentInterface::HTML_INPUT_STRIP) {
return '';
}
- if ($this->config->getConfig('html_input') === Environment::HTML_INPUT_ESCAPE) {
+ if ($this->config->getConfig('html_input') === EnvironmentInterface::HTML_INPUT_ESCAPE) {
return htmlspecialchars($inline->getContent(), ENT_NOQUOTES);
}
diff --git a/vendor/league/commonmark/src/Inline/Renderer/ImageRenderer.php b/vendor/league/commonmark/src/Inline/Renderer/ImageRenderer.php
index 082e74aff0..77fd8918ea 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/ImageRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/ImageRenderer.php
@@ -21,7 +21,6 @@ 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
{
@@ -39,27 +38,24 @@ class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterf
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
{
if (!($inline instanceof Image)) {
- throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
+ throw new \InvalidArgumentException('Incompatible inline type: ' . \get_class($inline));
}
- $attrs = [];
- foreach ($inline->getData('attributes', []) as $key => $value) {
- $attrs[$key] = Xml::escape($value);
- }
+ $attrs = $inline->getData('attributes', []);
$forbidUnsafeLinks = $this->config->getConfig('safe') || !$this->config->getConfig('allow_unsafe_links');
if ($forbidUnsafeLinks && RegexHelper::isLinkPotentiallyUnsafe($inline->getUrl())) {
$attrs['src'] = '';
} else {
- $attrs['src'] = Xml::escape($inline->getUrl());
+ $attrs['src'] = $inline->getUrl();
}
$alt = $htmlRenderer->renderInlines($inline->children());
- $alt = preg_replace('/\<[^>]*alt="([^"]*)"[^>]*\>/', '$1', $alt);
- $attrs['alt'] = preg_replace('/\<[^>]*\>/', '', $alt);
+ $alt = \preg_replace('/\<[^>]*alt="([^"]*)"[^>]*\>/', '$1', $alt);
+ $attrs['alt'] = \preg_replace('/\<[^>]*\>/', '', $alt);
if (isset($inline->data['title'])) {
- $attrs['title'] = Xml::escape($inline->data['title']);
+ $attrs['title'] = $inline->data['title'];
}
return new HtmlElement('img', $attrs, '', true);
diff --git a/vendor/league/commonmark/src/Inline/Renderer/InlineRendererInterface.php b/vendor/league/commonmark/src/Inline/Renderer/InlineRendererInterface.php
index 06741e5028..1407f9717d 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/InlineRendererInterface.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/InlineRendererInterface.php
@@ -24,7 +24,7 @@ interface InlineRendererInterface
* @param AbstractInline $inline
* @param ElementRendererInterface $htmlRenderer
*
- * @return HtmlElement|string
+ * @return HtmlElement|string|null
*/
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer);
}
diff --git a/vendor/league/commonmark/src/Inline/Renderer/LinkRenderer.php b/vendor/league/commonmark/src/Inline/Renderer/LinkRenderer.php
index 07e8e3f05f..7ad85152c5 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/LinkRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/LinkRenderer.php
@@ -21,7 +21,6 @@ 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
{
@@ -39,21 +38,18 @@ class LinkRenderer implements InlineRendererInterface, ConfigurationAwareInterfa
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
{
if (!($inline instanceof Link)) {
- throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
+ throw new \InvalidArgumentException('Incompatible inline type: ' . \get_class($inline));
}
- $attrs = [];
- foreach ($inline->getData('attributes', []) as $key => $value) {
- $attrs[$key] = Xml::escape($value);
- }
+ $attrs = $inline->getData('attributes', []);
$forbidUnsafeLinks = $this->config->getConfig('safe') || !$this->config->getConfig('allow_unsafe_links');
if (!($forbidUnsafeLinks && RegexHelper::isLinkPotentiallyUnsafe($inline->getUrl()))) {
- $attrs['href'] = Xml::escape($inline->getUrl());
+ $attrs['href'] = $inline->getUrl();
}
if (isset($inline->data['title'])) {
- $attrs['title'] = Xml::escape($inline->data['title']);
+ $attrs['title'] = $inline->data['title'];
}
if (isset($attrs['target']) && $attrs['target'] === '_blank' && !isset($attrs['rel'])) {
diff --git a/vendor/league/commonmark/src/Inline/Renderer/NewlineRenderer.php b/vendor/league/commonmark/src/Inline/Renderer/NewlineRenderer.php
index 024abaeb55..334e0e2b1d 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/NewlineRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/NewlineRenderer.php
@@ -30,7 +30,7 @@ class NewlineRenderer implements InlineRendererInterface
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
{
if (!($inline instanceof Newline)) {
- throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
+ throw new \InvalidArgumentException('Incompatible inline type: ' . \get_class($inline));
}
if ($inline->getType() === Newline::HARDBREAK) {
diff --git a/vendor/league/commonmark/src/Inline/Renderer/StrongRenderer.php b/vendor/league/commonmark/src/Inline/Renderer/StrongRenderer.php
index 06357c1d43..6aaa3848bc 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/StrongRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/StrongRenderer.php
@@ -18,7 +18,6 @@ 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
{
@@ -31,13 +30,10 @@ class StrongRenderer implements InlineRendererInterface
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
{
if (!($inline instanceof Strong)) {
- throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
+ throw new \InvalidArgumentException('Incompatible inline type: ' . \get_class($inline));
}
- $attrs = [];
- foreach ($inline->getData('attributes', []) as $key => $value) {
- $attrs[$key] = Xml::escape($value);
- }
+ $attrs = $inline->getData('attributes', []);
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 dcd3cdea88..b009ee8e2c 100644
--- a/vendor/league/commonmark/src/Inline/Renderer/TextRenderer.php
+++ b/vendor/league/commonmark/src/Inline/Renderer/TextRenderer.php
@@ -30,7 +30,7 @@ class TextRenderer implements InlineRendererInterface
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
{
if (!($inline instanceof Text)) {
- throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
+ throw new \InvalidArgumentException('Incompatible inline type: ' . \get_class($inline));
}
return Xml::escape($inline->getContent());
diff --git a/vendor/league/commonmark/src/InlineParserContext.php b/vendor/league/commonmark/src/InlineParserContext.php
index f1e99257e3..ef14a6dfda 100644
--- a/vendor/league/commonmark/src/InlineParserContext.php
+++ b/vendor/league/commonmark/src/InlineParserContext.php
@@ -15,6 +15,7 @@
namespace League\CommonMark;
use League\CommonMark\Block\Element\AbstractBlock;
+use League\CommonMark\Block\Element\AbstractStringContainerBlock;
use League\CommonMark\Delimiter\DelimiterStack;
use League\CommonMark\Reference\ReferenceMap;
@@ -25,18 +26,18 @@ class InlineParserContext
private $cursor;
private $delimiterStack;
- public function __construct(AbstractBlock $container, ReferenceMap $referenceMap)
+ public function __construct(AbstractStringContainerBlock $container, ReferenceMap $referenceMap)
{
$this->referenceMap = $referenceMap;
$this->container = $container;
- $this->cursor = new Cursor(trim($container->getStringContent()));
+ $this->cursor = new Cursor(\trim($container->getStringContent()));
$this->delimiterStack = new DelimiterStack();
}
/**
* @return AbstractBlock
*/
- public function getContainer()
+ public function getContainer(): AbstractBlock
{
return $this->container;
}
@@ -44,7 +45,7 @@ class InlineParserContext
/**
* @return ReferenceMap
*/
- public function getReferenceMap()
+ public function getReferenceMap(): ReferenceMap
{
return $this->referenceMap;
}
@@ -52,7 +53,7 @@ class InlineParserContext
/**
* @return Cursor
*/
- public function getCursor()
+ public function getCursor(): Cursor
{
return $this->cursor;
}
@@ -60,7 +61,7 @@ class InlineParserContext
/**
* @return DelimiterStack
*/
- public function getDelimiterStack()
+ public function getDelimiterStack(): DelimiterStack
{
return $this->delimiterStack;
}
diff --git a/vendor/league/commonmark/src/InlineParserEngine.php b/vendor/league/commonmark/src/InlineParserEngine.php
index e056493736..e92e158076 100644
--- a/vendor/league/commonmark/src/InlineParserEngine.php
+++ b/vendor/league/commonmark/src/InlineParserEngine.php
@@ -23,7 +23,7 @@ class InlineParserEngine
{
protected $environment;
- public function __construct(Environment $environment)
+ public function __construct(EnvironmentInterface $environment)
{
$this->environment = $environment;
}
@@ -52,7 +52,7 @@ class InlineParserEngine
*
* @return bool Whether we successfully parsed a character at that position
*/
- protected function parseCharacter($character, InlineParserContext $inlineParserContext)
+ protected function parseCharacter(string $character, InlineParserContext $inlineParserContext): bool
{
foreach ($this->environment->getInlineParsersForCharacter($character) as $parser) {
if ($parser->parse($inlineParserContext)) {
@@ -83,7 +83,7 @@ class InlineParserEngine
* @param Node $container
* @param InlineParserContext $inlineParserContext
*/
- private function addPlainText($character, Node $container, InlineParserContext $inlineParserContext)
+ private function addPlainText(string $character, Node $container, InlineParserContext $inlineParserContext)
{
// We reach here if none of the parsers can handle the input
// Attempt to match multiple non-special characters at once
diff --git a/vendor/league/commonmark/src/Node/Node.php b/vendor/league/commonmark/src/Node/Node.php
index 6a8d27d012..17f373ccca 100644
--- a/vendor/league/commonmark/src/Node/Node.php
+++ b/vendor/league/commonmark/src/Node/Node.php
@@ -2,8 +2,6 @@
namespace League\CommonMark\Node;
-use League\CommonMark\Util\ArrayCollection;
-
abstract class Node
{
/**
@@ -39,7 +37,7 @@ abstract class Node
/**
* @return Node|null
*/
- public function previous()
+ public function previous(): ?Node
{
return $this->previous;
}
@@ -47,7 +45,7 @@ abstract class Node
/**
* @return Node|null
*/
- public function next()
+ public function next(): ?Node
{
return $this->next;
}
@@ -55,7 +53,7 @@ abstract class Node
/**
* @return Node|null
*/
- public function parent()
+ public function parent(): ?Node
{
return $this->parent;
}
@@ -145,12 +143,12 @@ abstract class Node
/**
* @return bool
*/
- abstract public function isContainer();
+ abstract public function isContainer(): bool;
/**
* @return Node|null
*/
- public function firstChild()
+ public function firstChild(): ?Node
{
return $this->firstChild;
}
@@ -158,7 +156,7 @@ abstract class Node
/**
* @return Node|null
*/
- public function lastChild()
+ public function lastChild(): ?Node
{
return $this->lastChild;
}
@@ -166,7 +164,7 @@ abstract class Node
/**
* @return Node[]
*/
- public function children()
+ public function children(): iterable
{
$children = [];
for ($current = $this->firstChild; null !== $current; $current = $current->next) {
@@ -220,16 +218,12 @@ abstract class Node
/**
* Replace all children of given node with collection of another
*
- * @param array $children
+ * @param iterable $children
*
* @return $this
*/
- public function replaceChildren(array $children)
+ public function replaceChildren(iterable $children)
{
- if (!is_array($children) && !(is_object($children) && $children instanceof ArrayCollection)) {
- throw new \InvalidArgumentException(sprintf('Expect iterable, got %s', get_class($children)));
- }
-
$this->detachChildren();
foreach ($children as $item) {
$this->appendChild($item);
@@ -241,7 +235,7 @@ abstract class Node
/**
* @return int
*/
- public function getDepth()
+ public function getDepth(): int
{
return $this->depth;
}
@@ -249,7 +243,7 @@ abstract class Node
/**
* @return NodeWalker
*/
- public function walker()
+ public function walker(): NodeWalker
{
return new NodeWalker($this);
}
diff --git a/vendor/league/commonmark/src/Node/NodeWalker.php b/vendor/league/commonmark/src/Node/NodeWalker.php
index 7ffc1663dd..0d5e2b1872 100644
--- a/vendor/league/commonmark/src/Node/NodeWalker.php
+++ b/vendor/league/commonmark/src/Node/NodeWalker.php
@@ -10,7 +10,7 @@ class NodeWalker
private $root;
/**
- * @var Node
+ * @var Node|null
*/
private $current;
@@ -36,12 +36,12 @@ class NodeWalker
*
* @return NodeWalkerEvent|null
*/
- public function next()
+ public function next(): ?NodeWalkerEvent
{
$current = $this->current;
$entering = $this->entering;
if (null === $current) {
- return;
+ return null;
}
if ($entering && $current->isContainer()) {
@@ -70,7 +70,7 @@ class NodeWalker
* @param Node $node
* @param bool $entering
*/
- public function resumeAt(Node $node, $entering = true)
+ public function resumeAt(Node $node, bool $entering = true)
{
$this->current = $node;
$this->entering = $entering;
diff --git a/vendor/league/commonmark/src/Node/NodeWalkerEvent.php b/vendor/league/commonmark/src/Node/NodeWalkerEvent.php
index 203a3106aa..aee2c86b82 100644
--- a/vendor/league/commonmark/src/Node/NodeWalkerEvent.php
+++ b/vendor/league/commonmark/src/Node/NodeWalkerEvent.php
@@ -27,7 +27,7 @@ final class NodeWalkerEvent
/**
* @return Node
*/
- public function getNode()
+ public function getNode(): Node
{
return $this->node;
}
@@ -35,7 +35,7 @@ final class NodeWalkerEvent
/**
* @return bool
*/
- public function isEntering()
+ public function isEntering(): bool
{
return $this->isEntering;
}
diff --git a/vendor/league/commonmark/src/Reference/Reference.php b/vendor/league/commonmark/src/Reference/Reference.php
index c150c2791e..819a80a56a 100644
--- a/vendor/league/commonmark/src/Reference/Reference.php
+++ b/vendor/league/commonmark/src/Reference/Reference.php
@@ -41,7 +41,7 @@ class Reference
* @param string $destination
* @param string $title
*/
- public function __construct($label, $destination, $title)
+ public function __construct(string $label, string $destination, string $title)
{
$this->label = self::normalizeReference($label);
$this->destination = $destination;
@@ -51,7 +51,7 @@ class Reference
/**
* @return string
*/
- public function getLabel()
+ public function getLabel(): string
{
return $this->label;
}
@@ -59,7 +59,7 @@ class Reference
/**
* @return string
*/
- public function getDestination()
+ public function getDestination(): string
{
return $this->destination;
}
@@ -67,7 +67,7 @@ class Reference
/**
* @return string
*/
- public function getTitle()
+ public function getTitle(): string
{
return $this->title;
}
@@ -81,12 +81,12 @@ class Reference
*
* @return string
*/
- public static function normalizeReference($string)
+ public static function normalizeReference(string $string): string
{
// 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');
+ 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 db2ceedcda..97f878f9fe 100644
--- a/vendor/league/commonmark/src/Reference/ReferenceMap.php
+++ b/vendor/league/commonmark/src/Reference/ReferenceMap.php
@@ -42,7 +42,7 @@ class ReferenceMap
*
* @return bool
*/
- public function contains($label)
+ public function contains(string $label): bool
{
$label = Reference::normalizeReference($label);
@@ -54,12 +54,12 @@ class ReferenceMap
*
* @return Reference|null
*/
- public function getReference($label)
+ public function getReference(string $label): ?Reference
{
$label = Reference::normalizeReference($label);
if (!isset($this->references[$label])) {
- return;
+ return null;
}
return $this->references[$label];
@@ -70,8 +70,8 @@ class ReferenceMap
*
* @return Reference[]
*/
- public function listReferences()
+ public function listReferences(): iterable
{
- return array_values($this->references);
+ return \array_values($this->references);
}
}
diff --git a/vendor/league/commonmark/src/ReferenceParser.php b/vendor/league/commonmark/src/ReferenceParser.php
index 3324dd3f26..5c0bc8a0dd 100644
--- a/vendor/league/commonmark/src/ReferenceParser.php
+++ b/vendor/league/commonmark/src/ReferenceParser.php
@@ -53,9 +53,9 @@ class ReferenceParser
}
// We need to trim the opening and closing brackets from the previously-matched text
- $label = substr($cursor->getPreviousText(), 1, -1);
+ $label = \substr($cursor->getPreviousText(), 1, -1);
- if (preg_match('/[^\s]/', $label) === 0) {
+ if (\preg_match('/[^\s]/', $label) === 0) {
$cursor->restoreState($initialState);
return false;
@@ -74,17 +74,19 @@ class ReferenceParser
$cursor->advanceToNextNonSpaceOrNewline();
$destination = LinkParserHelper::parseLinkDestination($cursor);
- if (empty($destination)) {
+ if ($destination === null) {
$cursor->restoreState($initialState);
return false;
}
$previousState = $cursor->saveState();
- $cursor->advanceToNextNonSpaceOrNewline();
- $title = LinkParserHelper::parseLinkTitle($cursor);
- if ($title === null) {
+ if ($cursor->advanceToNextNonSpaceOrNewline() > 0) {
+ $title = LinkParserHelper::parseLinkTitle($cursor);
+ }
+
+ if (!isset($title)) {
$title = '';
$cursor->restoreState($previousState);
}
diff --git a/vendor/league/commonmark/src/UnmatchedBlockCloser.php b/vendor/league/commonmark/src/UnmatchedBlockCloser.php
index 0dcd791842..eab47cda2c 100644
--- a/vendor/league/commonmark/src/UnmatchedBlockCloser.php
+++ b/vendor/league/commonmark/src/UnmatchedBlockCloser.php
@@ -56,6 +56,7 @@ class UnmatchedBlockCloser
$endLine = $this->context->getLineNumber() - 1;
while ($this->oldTip !== $this->lastMatchedContainer) {
+ /** @var AbstractBlock $oldTip */
$oldTip = $this->oldTip->parent();
$this->oldTip->finalize($this->context, $endLine);
$this->oldTip = $oldTip;
@@ -70,7 +71,7 @@ class UnmatchedBlockCloser
/**
* @return bool
*/
- public function areAllClosed()
+ public function areAllClosed(): bool
{
return $this->context->getTip() === $this->lastMatchedContainer;
}
diff --git a/vendor/league/commonmark/src/Util/ArrayCollection.php b/vendor/league/commonmark/src/Util/ArrayCollection.php
index e2492636b9..3b96eaa50e 100644
--- a/vendor/league/commonmark/src/Util/ArrayCollection.php
+++ b/vendor/league/commonmark/src/Util/ArrayCollection.php
@@ -34,11 +34,11 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
}
/**
- * @return string
+ * @return mixed
*/
public function first()
{
- return reset($this->elements);
+ return \reset($this->elements);
}
/**
@@ -46,7 +46,7 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
*/
public function last()
{
- return end($this->elements);
+ return \end($this->elements);
}
/**
@@ -64,7 +64,7 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
*
* @return bool
*/
- public function add($element)
+ public function add($element): bool
{
$this->elements[] = $element;
@@ -97,7 +97,7 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
*/
public function remove($key)
{
- if (!array_key_exists($key, $this->elements)) {
+ if (!\array_key_exists($key, $this->elements)) {
return;
}
@@ -110,7 +110,7 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
/**
* @return bool
*/
- public function isEmpty()
+ public function isEmpty(): bool
{
return empty($this->elements);
}
@@ -120,9 +120,9 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
*
* @return bool
*/
- public function contains($element)
+ public function contains($element): bool
{
- return in_array($element, $this->elements, true);
+ return \in_array($element, $this->elements, true);
}
/**
@@ -132,7 +132,7 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
*/
public function indexOf($element)
{
- return array_search($element, $this->elements, true);
+ return \array_search($element, $this->elements, true);
}
/**
@@ -140,9 +140,9 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
*
* @return bool
*/
- public function containsKey($key)
+ public function containsKey($key): bool
{
- return array_key_exists($key, $this->elements);
+ return \array_key_exists($key, $this->elements);
}
/**
@@ -150,9 +150,9 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
*
* @return int The count as an integer.
*/
- public function count()
+ public function count(): int
{
- return count($this->elements);
+ return \count($this->elements);
}
/**
@@ -162,7 +162,7 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
*
* @return bool true on success or false on failure.
*/
- public function offsetExists($offset)
+ public function offsetExists($offset): bool
{
return $this->containsKey($offset);
}
@@ -216,15 +216,15 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
*
* @return array
*/
- public function slice($offset, $length = null)
+ public function slice(int $offset, ?int $length = null): array
{
- return array_slice($this->elements, $offset, $length, true);
+ return \array_slice($this->elements, $offset, $length, true);
}
/**
* @return array
*/
- public function toArray()
+ public function toArray(): array
{
return $this->elements;
}
@@ -243,6 +243,6 @@ class ArrayCollection implements \IteratorAggregate, \Countable, \ArrayAccess
public function removeGaps()
{
- $this->elements = array_filter($this->elements);
+ $this->elements = \array_filter($this->elements);
}
}
diff --git a/vendor/league/commonmark/src/Util/Configuration.php b/vendor/league/commonmark/src/Util/Configuration.php
index 974527c16f..26f676b091 100644
--- a/vendor/league/commonmark/src/Util/Configuration.php
+++ b/vendor/league/commonmark/src/Util/Configuration.php
@@ -31,7 +31,7 @@ class Configuration
*/
public function mergeConfig(array $config = [])
{
- $this->config = array_replace_recursive($this->config, $config);
+ $this->config = \array_replace_recursive($this->config, $config);
}
/**
@@ -48,14 +48,14 @@ class Configuration
*
* @return mixed
*/
- public function getConfig($key = null, $default = null)
+ public function getConfig(?string $key = null, $default = null)
{
if ($key === null) {
return $this->config;
}
// accept a/b/c as ['a']['b']['c']
- if (strpos($key, '/')) {
+ if (\strpos($key, '/')) {
return $this->getConfigByPath($key, $default);
}
@@ -72,12 +72,12 @@ class Configuration
*
* @return mixed
*/
- protected function getConfigByPath($keyPath, $default = null)
+ protected function getConfigByPath(string $keyPath, $default = null)
{
- $keyArr = explode('/', $keyPath);
+ $keyArr = \explode('/', $keyPath);
$data = $this->config;
foreach ($keyArr as $k) {
- if (!is_array($data) || !isset($data[$k])) {
+ if (!\is_array($data) || !isset($data[$k])) {
return $default;
}
diff --git a/vendor/league/commonmark/src/Util/Html5Entities.php b/vendor/league/commonmark/src/Util/Html5Entities.php
index d0509f719b..09c540989f 100644
--- a/vendor/league/commonmark/src/Util/Html5Entities.php
+++ b/vendor/league/commonmark/src/Util/Html5Entities.php
@@ -2247,21 +2247,21 @@ final class Html5Entities
*
* @return string
*/
- public static function decodeEntity($entity)
+ public static function decodeEntity(string $entity): string
{
- if (substr($entity, -1) !== ';') {
+ if (\substr($entity, -1) !== ';') {
return $entity;
}
- if (substr($entity, 0, 2) === '&#') {
- if (strtolower(substr($entity, 2, 1)) === 'x') {
- return self::fromHex(substr($entity, 3, -1));
+ if (\substr($entity, 0, 2) === '&#') {
+ if (\strtolower(\substr($entity, 2, 1)) === 'x') {
+ return self::fromHex(\substr($entity, 3, -1));
}
- return self::fromDecimal(substr($entity, 2, -1));
+ return self::fromDecimal(\substr($entity, 2, -1));
}
- $name = substr($entity, 1, -1);
+ $name = \substr($entity, 1, -1);
if (isset(self::$entitiesByName[$name])) {
return self::$entitiesByName[$name];
}
@@ -2274,7 +2274,7 @@ final class Html5Entities
*
* @return string
*/
- public static function fromDecimal($number)
+ public static function fromDecimal($number): string
{
// Only convert code points within planes 0-2, excluding NULL
if (empty($number) || $number > 0x2FFFF) {
@@ -2283,7 +2283,7 @@ final class Html5Entities
$entity = '&#' . $number . ';';
- $converted = mb_decode_numericentity($entity, [0x0, 0x2FFFF, 0, 0xFFFF], 'UTF-8');
+ $converted = \mb_decode_numericentity($entity, [0x0, 0x2FFFF, 0, 0xFFFF], 'UTF-8');
if ($converted === $entity) {
return self::fromHex('fffd');
@@ -2297,8 +2297,8 @@ final class Html5Entities
*
* @return string
*/
- public static function fromHex($hexChars)
+ public static function fromHex(string $hexChars): string
{
- return self::fromDecimal(hexdec($hexChars));
+ return self::fromDecimal(\hexdec($hexChars));
}
}
diff --git a/vendor/league/commonmark/src/Util/LinkParserHelper.php b/vendor/league/commonmark/src/Util/LinkParserHelper.php
index 2c6cfb3801..9d65496321 100644
--- a/vendor/league/commonmark/src/Util/LinkParserHelper.php
+++ b/vendor/league/commonmark/src/Util/LinkParserHelper.php
@@ -25,46 +25,26 @@ final class LinkParserHelper
*
* @return null|string The string, or null if no match
*/
- public static function parseLinkDestination(Cursor $cursor)
+ public static function parseLinkDestination(Cursor $cursor): ?string
{
if ($res = $cursor->match(RegexHelper::REGEX_LINK_DESTINATION_BRACES)) {
// Chop off surrounding <..>:
return UrlEncoder::unescapeAndEncode(
- RegexHelper::unescape(substr($res, 1, -1))
+ RegexHelper::unescape(\substr($res, 1, -1))
);
}
- $oldState = $cursor->saveState();
- $openParens = 0;
- while (($c = $cursor->getCharacter()) !== null) {
- if ($c === '\\' && RegexHelper::isEscapable($cursor->peek())) {
- $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();
- }
+ if ($cursor->getCharacter() === '<') {
+ return null;
}
- $newPos = $cursor->getPosition();
- $cursor->restoreState($oldState);
-
- $cursor->advanceBy($newPos - $cursor->getPosition());
-
- $res = $cursor->getPreviousText();
+ $destination = self::manuallyParseLinkDestination($cursor);
+ if ($destination === null) {
+ return null;
+ }
return UrlEncoder::unescapeAndEncode(
- RegexHelper::unescape($res)
+ RegexHelper::unescape($destination)
);
}
@@ -73,14 +53,14 @@ final class LinkParserHelper
*
* @return int
*/
- public static function parseLinkLabel(Cursor $cursor)
+ public static function parseLinkLabel(Cursor $cursor): int
{
$match = $cursor->match('/^\[(?:[^\\\\\[\]]|\\\\.){0,1000}\]/');
if ($match === null) {
return 0;
}
- $length = mb_strlen($match, 'utf-8');
+ $length = \mb_strlen($match, 'utf-8');
if ($length > 1001) {
return 0;
@@ -96,11 +76,56 @@ final class LinkParserHelper
*
* @return null|string The string, or null if no match
*/
- public static function parseLinkTitle(Cursor $cursor)
+ public static function parseLinkTitle(Cursor $cursor): ?string
{
if ($title = $cursor->match('/' . RegexHelper::PARTIAL_LINK_TITLE . '/')) {
// Chop off quotes from title and unescape
- return RegexHelper::unescape(substr($title, 1, -1));
+ return RegexHelper::unescape(\substr($title, 1, -1));
+ }
+
+ return null;
+ }
+
+ /**
+ * @param Cursor $cursor
+ *
+ * @return string|null
+ */
+ private static function manuallyParseLinkDestination(Cursor $cursor): ?string
+ {
+ $oldPosition = $cursor->getPosition();
+ $oldState = $cursor->saveState();
+
+ $openParens = 0;
+ while (($c = $cursor->getCharacter()) !== null) {
+ if ($c === '\\' && RegexHelper::isEscapable($cursor->peek())) {
+ $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();
+ }
}
+
+ if ($cursor->getPosition() === $oldPosition && $c !== ')') {
+ return null;
+ }
+
+ $newPos = $cursor->getPosition();
+ $cursor->restoreState($oldState);
+
+ $cursor->advanceBy($newPos - $cursor->getPosition());
+
+ return $cursor->getPreviousText();
}
}
diff --git a/vendor/league/commonmark/src/Util/PrioritizedList.php b/vendor/league/commonmark/src/Util/PrioritizedList.php
new file mode 100644
index 0000000000..83be39dc01
--- /dev/null
+++ b/vendor/league/commonmark/src/Util/PrioritizedList.php
@@ -0,0 +1,53 @@
+<?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;
+
+final class PrioritizedList implements \IteratorAggregate
+{
+ private $list = [];
+
+ private $optimized;
+
+ /**
+ * @param mixed $item
+ * @param int $priority
+ */
+ public function add($item, int $priority)
+ {
+ $this->list[$priority][] = $item;
+ $this->optimized = null;
+ }
+
+ /**
+ * @return \Traversable
+ */
+ public function getIterator(): iterable
+ {
+ if ($this->optimized === null) {
+ \krsort($this->list);
+
+ $sorted = [];
+ foreach ($this->list as $group) {
+ foreach ($group as $item) {
+ $sorted[] = $item;
+ }
+ }
+
+ $this->optimized = new \ArrayIterator($sorted);
+ }
+
+ return $this->optimized;
+ }
+}
diff --git a/vendor/league/commonmark/src/Util/RegexHelper.php b/vendor/league/commonmark/src/Util/RegexHelper.php
index b677a4c7dd..a4703bd075 100644
--- a/vendor/league/commonmark/src/Util/RegexHelper.php
+++ b/vendor/league/commonmark/src/Util/RegexHelper.php
@@ -103,7 +103,7 @@ final class RegexHelper
const LINK_TITLE = 26;
// 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_ENTITY = '&(?:#x[a-f0-9]{1,6}|#[0-9]{1,7}|[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])*"';
@@ -112,7 +112,7 @@ final class RegexHelper
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_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|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 = '\'[^\']*\'';
@@ -151,135 +151,16 @@ final class RegexHelper
const REGEX_WHITESPACE = '/[ \t\n\x0b\x0c\x0d]+/';
const REGEX_UNICODE_WHITESPACE_CHAR = '/^\pZ|\s/u';
const REGEX_THEMATIC_BREAK = '/^(?:(?:\*[ \t]*){3,}|(?:_[ \t]*){3,}|(?:-[ \t]*){3,})[ \t]*$/';
- const REGEX_LINK_DESTINATION_BRACES = '/^(?:<(?:[^ <>\\t\\n\\\\\\x00]|\\\\.)*>)/';
+ const REGEX_LINK_DESTINATION_BRACES = '/^(?:<(?:[^<>\\n\\\\\\x00]|\\\\.)*>)/';
/**
- * @deprecated Instance methods will be removed in 0.18 or 1.0 (whichever comes first)
- */
- 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();
- }
-
- return self::$instance;
- }
-
- /**
- * @param string|null $character
+ * @param string $character
*
* @return bool
*/
- public static function isEscapable($character)
- {
- if ($character === null) {
- return false;
- }
-
- return preg_match('/' . self::PARTIAL_ESCAPABLE . '/', $character) === 1;
- }
-
- /**
- * Returns a partial regex
- *
- * It'll need to be wrapped with /.../ before use
- *
- * @param int $const
- *
- * @return string
- *
- * @deprecated Just grab the constant directly
- */
- public function getPartialRegex($const)
+ public static function isEscapable(string $character): bool
{
- @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()
- {
- @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()
- {
- @trigger_error('RegexHelper::getLinkTitleRegex() has been deprecated. Use the RegexHelper::PARTIAL_LINK_TITLE constant instead.', E_USER_DEPRECATED);
-
- return '/' . self::PARTIAL_LINK_TITLE . '/';
- }
-
- /**
- * @return string
- *
- * @deprecated Use REGEX_LINK_DESTINATION_BRACES instead
- */
- public function getLinkDestinationBracesRegex()
- {
- @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()
- {
- @trigger_error('RegexHelper::getThematicBreakRegex() has been deprecated. Use the RegexHelper::REGEX_THEMATIC_BREAK constant instead.', E_USER_DEPRECATED);
-
- return self::REGEX_THEMATIC_BREAK;
+ return \preg_match('/' . self::PARTIAL_ESCAPABLE . '/', $character) === 1;
}
/**
@@ -291,16 +172,16 @@ final class RegexHelper
*
* @return int|null Index of match, or null
*/
- public static function matchAt($regex, $string, $offset = 0)
+ public static function matchAt(string $regex, string $string, int $offset = 0): ?int
{
$matches = [];
- $string = mb_substr($string, $offset, null, 'utf-8');
- if (!preg_match($regex, $string, $matches, PREG_OFFSET_CAPTURE)) {
- return;
+ $string = \mb_substr($string, $offset, null, 'utf-8');
+ if (!\preg_match($regex, $string, $matches, PREG_OFFSET_CAPTURE)) {
+ return null;
}
// PREG_OFFSET_CAPTURE always returns the byte offset, not the char offset, which is annoying
- $charPos = mb_strlen(mb_strcut($string, 0, $matches[0][1], 'utf-8'), 'utf-8');
+ $charPos = \mb_strlen(\mb_strcut($string, 0, $matches[0][1], 'utf-8'), 'utf-8');
return $offset + $charPos;
}
@@ -314,25 +195,26 @@ final class RegexHelper
*
* @return array|null
*/
- public static function matchAll($pattern, $subject, $offset = 0)
+ public static function matchAll(string $pattern, string $subject, int $offset = 0): ?array
{
- $subject = substr($subject, $offset);
- preg_match_all($pattern, $subject, $matches, PREG_PATTERN_ORDER);
+ if ($offset !== 0) {
+ $subject = \substr($subject, $offset);
+ }
+
+ \preg_match_all($pattern, $subject, $matches, PREG_PATTERN_ORDER);
- $fullMatches = reset($matches);
+ $fullMatches = \reset($matches);
if (empty($fullMatches)) {
- return;
+ return null;
}
- if (count($fullMatches) === 1) {
+ if (\count($fullMatches) === 1) {
foreach ($matches as &$match) {
- $match = reset($match);
+ $match = \reset($match);
}
}
- if (!empty($matches)) {
- return $matches;
- }
+ return $matches ?: null;
}
/**
@@ -342,12 +224,12 @@ final class RegexHelper
*
* @return string
*/
- public static function unescape($string)
+ public static function unescape(string $string): string
{
$allEscapedChar = '/\\\\(' . self::PARTIAL_ESCAPABLE . ')/';
- $escaped = preg_replace($allEscapedChar, '$1', $string);
- $replaced = preg_replace_callback('/' . self::PARTIAL_ENTITY . '/i', function ($e) {
+ $escaped = \preg_replace($allEscapedChar, '$1', $string);
+ $replaced = \preg_replace_callback('/' . self::PARTIAL_ENTITY . '/i', function ($e) {
return Html5Entities::decodeEntity($e[0]);
}, $escaped);
@@ -359,7 +241,7 @@ final class RegexHelper
*
* @return string|null
*/
- public static function getHtmlBlockOpenRegex($type)
+ public static function getHtmlBlockOpenRegex(int $type): ?string
{
switch ($type) {
case HtmlBlock::TYPE_1_CODE_CONTAINER:
@@ -373,10 +255,12 @@ final 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|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';
+ 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|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:
return '/^(?:' . self::PARTIAL_OPENTAG . '|' . self::PARTIAL_CLOSETAG . ')\\s*$/i';
}
+
+ return null;
}
/**
@@ -384,7 +268,7 @@ final class RegexHelper
*
* @return string|null
*/
- public static function getHtmlBlockCloseRegex($type)
+ public static function getHtmlBlockCloseRegex(int $type): ?string
{
switch ($type) {
case HtmlBlock::TYPE_1_CODE_CONTAINER:
@@ -398,6 +282,8 @@ final class RegexHelper
case HtmlBlock::TYPE_5_CDATA:
return '/\]\]>/';
}
+
+ return null;
}
/**
@@ -405,8 +291,8 @@ final class RegexHelper
*
* @return bool
*/
- public static function isLinkPotentiallyUnsafe($url)
+ public static function isLinkPotentiallyUnsafe(string $url): bool
{
- return preg_match(self::REGEX_UNSAFE_PROTOCOL, $url) !== 0 && preg_match(self::REGEX_SAFE_DATA_PROTOCOL, $url) === 0;
+ return \preg_match(self::REGEX_UNSAFE_PROTOCOL, $url) !== 0 && \preg_match(self::REGEX_SAFE_DATA_PROTOCOL, $url) === 0;
}
}
diff --git a/vendor/league/commonmark/src/Util/UrlEncoder.php b/vendor/league/commonmark/src/Util/UrlEncoder.php
index 774d1fa3c6..f808e39415 100644
--- a/vendor/league/commonmark/src/Util/UrlEncoder.php
+++ b/vendor/league/commonmark/src/Util/UrlEncoder.php
@@ -58,9 +58,9 @@ final class UrlEncoder
*
* @return string
*/
- public static function unescapeAndEncode($uri)
+ public static function unescapeAndEncode(string $uri): string
{
- $decoded = html_entity_decode($uri);
+ $decoded = \html_entity_decode($uri);
return self::encode(self::decode($decoded));
}
@@ -72,13 +72,13 @@ final class UrlEncoder
*
* @return string
*/
- private static function decode($uri)
+ private static function decode(string $uri): string
{
- return preg_replace_callback('/%([0-9a-f]{2})/iu', function ($matches) {
- $char = chr(hexdec($matches[1]));
+ return \preg_replace_callback('/%([0-9a-f]{2})/iu', function ($matches) {
+ $char = \chr(\hexdec($matches[1]));
- if (in_array($char, self::$dontDecode, true)) {
- return strtoupper($matches[0]);
+ if (\in_array($char, self::$dontDecode, true)) {
+ return \strtoupper($matches[0]);
}
return $char;
@@ -92,21 +92,21 @@ final class UrlEncoder
*
* @return string
*/
- private static function encode($uri)
+ private static function encode(string $uri): string
{
- return preg_replace_callback('/(%[0-9a-f]{2})|./isu', function ($matches) {
+ return \preg_replace_callback('/(%[0-9a-f]{2})|./isu', function ($matches) {
// Keep already-encoded characters as-is
- if (count($matches) > 1) {
+ if (\count($matches) > 1) {
return $matches[0];
}
// Keep excluded characters as-is
- if (in_array($matches[0], self::$dontEncode)) {
+ if (\in_array($matches[0], self::$dontEncode)) {
return $matches[0];
}
// Otherwise, encode the character
- return rawurlencode($matches[0]);
+ return \rawurlencode($matches[0]);
}, $uri);
}
}
diff --git a/vendor/league/commonmark/src/Util/Xml.php b/vendor/league/commonmark/src/Util/Xml.php
index db1d460b45..1d8e3b76c8 100644
--- a/vendor/league/commonmark/src/Util/Xml.php
+++ b/vendor/league/commonmark/src/Util/Xml.php
@@ -21,22 +21,11 @@ final class Xml
{
/**
* @param string $string
- * @param bool $preserveEntities
*
* @return string
*/
- public static function escape($string, $preserveEntities = null)
+ public static function escape($string)
{
- if ($preserveEntities === true) {
- @trigger_error('Preserving entities in Xml::escape() has been deprecated and will be removed in the next release', E_USER_DEPRECATED);
- $string = preg_replace('/[&](?![#](x[a-f0-9]{1,8}|[0-9]{1,8});|[a-z][a-z0-9]{1,31};)/i', '&amp;', $string);
- } elseif ($preserveEntities === false) {
- @trigger_error('The $preserveEntities argument of Xml::escape() has been deprecated and will be removed in the next release', E_USER_DEPRECATED);
- $string = str_replace('&', '&amp;', $string);
- } else {
- $string = str_replace('&', '&amp;', $string);
- }
-
- return str_replace(['<', '>', '"'], ['&lt;', '&gt;', '&quot;'], $string);
+ return \str_replace(['&', '<', '>', '"'], ['&amp;', '&lt;', '&gt;', '&quot;'], $string);
}
}