diff --git a/CHANGELOG.md b/CHANGELOG.md index b331504967..917e5e80c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi ## [Unreleased][unreleased] +## [2.5.3] - 2024-08-16 + +### Changed + +- Made compatible with CommonMark spec 0.31.1, including: + - Remove `source`, add `search` to list of recognized block tags + ## [2.5.2] - 2024-08-14 ### Changed @@ -624,7 +631,8 @@ No changes were introduced since the previous release. - Alternative 1: Use `CommonMarkConverter` or `GithubFlavoredMarkdownConverter` if you don't need to customize the environment - Alternative 2: Instantiate a new `Environment` and add the necessary extensions yourself -[unreleased]: https://github.com/thephpleague/commonmark/compare/2.5.2...main +[unreleased]: https://github.com/thephpleague/commonmark/compare/2.5.3...main +[2.5.3]: https://github.com/thephpleague/commonmark/compare/2.5.2...2.5.3 [2.5.2]: https://github.com/thephpleague/commonmark/compare/2.5.1...2.5.2 [2.5.1]: https://github.com/thephpleague/commonmark/compare/2.5.0...2.5.1 [2.5.0]: https://github.com/thephpleague/commonmark/compare/2.4.4...2.5.0 diff --git a/README.md b/README.md index 36a337b0f7..c5cc592f98 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,6 @@ We'd also like to extend our sincere thanks the following sponsors who support o - [Tidelift](https://tidelift.com/subscription/pkg/packagist-league-commonmark?utm_source=packagist-league-commonmark&utm_medium=referral&utm_campaign=readme) for offering support to both the maintainers and end-users through their [professional support](https://tidelift.com/subscription/pkg/packagist-league-commonmark?utm_source=packagist-league-commonmark&utm_medium=referral&utm_campaign=readme) program - [Blackfire](https://www.blackfire.io/) for providing an Open-Source Profiler subscription - [JetBrains](https://www.jetbrains.com/) for supporting this project with complimentary [PhpStorm](https://www.jetbrains.com/phpstorm/) licenses - - [Taylor Otwell](https://twitter.com/taylorotwell) for sponsoring this project through GitHub sponsors Are you interested in sponsoring development of this project? See for a list of ways to contribute. diff --git a/composer.json b/composer.json index 0dd28291b2..9b90662034 100644 --- a/composer.json +++ b/composer.json @@ -31,8 +31,8 @@ "require-dev": { "ext-json": "*", "cebe/markdown": "^1.0", - "commonmark/cmark": "0.31.0", - "commonmark/commonmark.js": "0.31.0", + "commonmark/cmark": "0.31.1", + "commonmark/commonmark.js": "0.31.1", "composer/package-versions-deprecated": "^1.8", "embed/embed": "^4.4", "erusev/parsedown": "^1.0", @@ -56,9 +56,9 @@ "type": "package", "package": { "name": "commonmark/commonmark.js", - "version": "0.31.0", + "version": "0.31.1", "dist": { - "url": "https://github.com/commonmark/commonmark.js/archive/0.31.0.zip", + "url": "https://github.com/commonmark/commonmark.js/archive/0.31.1.zip", "type": "zip" } } @@ -67,9 +67,9 @@ "type": "package", "package": { "name": "commonmark/cmark", - "version": "0.31.0", + "version": "0.31.1", "dist": { - "url": "https://github.com/commonmark/cmark/archive/0.31.0.zip", + "url": "https://github.com/commonmark/cmark/archive/0.31.1.zip", "type": "zip" } } diff --git a/docs/2.5/extensions/autolinks.md b/docs/2.5/extensions/autolinks.md index 22848050b2..708afb47f3 100644 --- a/docs/2.5/extensions/autolinks.md +++ b/docs/2.5/extensions/autolinks.md @@ -35,7 +35,7 @@ use League\CommonMark\MarkdownConverter; $config = [ 'autolink' => [ 'allowed_protocols' => ['https'], // defaults to ['https', 'http', 'ftp'] - 'default_protocols' => 'https', // defaults to 'http' + 'default_protocol' => 'https', // defaults to 'http' ], ]; diff --git a/docs/2.5/extensions/embed.md b/docs/2.5/extensions/embed.md index c14e8a3c66..efd8b4979d 100644 --- a/docs/2.5/extensions/embed.md +++ b/docs/2.5/extensions/embed.md @@ -110,6 +110,12 @@ of embeddable content. To use that library, you'll need to `composer install embed/embed` and then pass `new OscaroteroEmbedAdapter()` as the `adapter` configuration option, as shown in the [**Usage**](#usage) section above. +Note: `embed/embed` *requires* a PSR-17 implementation to be installed. If you do not have one installed, the library will not work. By default these libraries are detected automatically: + * [laminas/laminas-diactoros](https://github.com/laminas/laminas-diactoros) + * [guzzle/psr7](https://github.com/guzzle/psr7) + * [nyholm/psr7](https://github.com/Nyholm/psr7) + * [sunrise/http-message](https://github.com/sunrise-php/http-message) + Need to customize the maximum width/height of the embedded content? You can do that by instantiating the service provided by `embed/embed`, [configuring it as needed](https://github.com/oscarotero/Embed#settings), and passing that customized instance into the adapter: diff --git a/docs/2.5/extensions/footnotes.md b/docs/2.5/extensions/footnotes.md index ff5f7fcade..7e64d0ed6d 100644 --- a/docs/2.5/extensions/footnotes.md +++ b/docs/2.5/extensions/footnotes.md @@ -85,7 +85,7 @@ $environment->addExtension(new FootnoteExtension()); // Instantiate the converter engine and start converting some Markdown! $converter = new MarkdownConverter($environment); -echo $converter->convert('# Hello World!'); +echo $converter->convert("This is a footnote[^test] test.\n\n[^test]: Doesn't it look good!"); ``` ## Configuration diff --git a/docs/2.6/extensions/autolinks.md b/docs/2.6/extensions/autolinks.md index 297902437c..1e0a827b94 100644 --- a/docs/2.6/extensions/autolinks.md +++ b/docs/2.6/extensions/autolinks.md @@ -35,7 +35,7 @@ use League\CommonMark\MarkdownConverter; $config = [ 'autolink' => [ 'allowed_protocols' => ['https'], // defaults to ['https', 'http', 'ftp'] - 'default_protocols' => 'https', // defaults to 'http' + 'default_protocol' => 'https', // defaults to 'http' ], ]; diff --git a/docs/2.6/extensions/embed.md b/docs/2.6/extensions/embed.md index f80a44fbaa..4cfcfb39ef 100644 --- a/docs/2.6/extensions/embed.md +++ b/docs/2.6/extensions/embed.md @@ -110,6 +110,12 @@ of embeddable content. To use that library, you'll need to `composer install embed/embed` and then pass `new OscaroteroEmbedAdapter()` as the `adapter` configuration option, as shown in the [**Usage**](#usage) section above. +Note: `embed/embed` *requires* a PSR-17 implementation to be installed. If you do not have one installed, the library will not work. By default these libraries are detected automatically: + * [laminas/laminas-diactoros](https://github.com/laminas/laminas-diactoros) + * [guzzle/psr7](https://github.com/guzzle/psr7) + * [nyholm/psr7](https://github.com/Nyholm/psr7) + * [sunrise/http-message](https://github.com/sunrise-php/http-message) + Need to customize the maximum width/height of the embedded content? You can do that by instantiating the service provided by `embed/embed`, [configuring it as needed](https://github.com/oscarotero/Embed#settings), and passing that customized instance into the adapter: diff --git a/docs/2.6/extensions/footnotes.md b/docs/2.6/extensions/footnotes.md index cbf6bd64c1..4880aab5b2 100644 --- a/docs/2.6/extensions/footnotes.md +++ b/docs/2.6/extensions/footnotes.md @@ -85,7 +85,7 @@ $environment->addExtension(new FootnoteExtension()); // Instantiate the converter engine and start converting some Markdown! $converter = new MarkdownConverter($environment); -echo $converter->convert('# Hello World!'); +echo $converter->convert("This is a footnote[^test] test.\n\n[^test]: Doesn't it look good!"); ``` ## Configuration diff --git a/src/Parser/Cursor.php b/src/Parser/Cursor.php index d6d76b3a92..faae75bc1d 100644 --- a/src/Parser/Cursor.php +++ b/src/Parser/Cursor.php @@ -336,6 +336,7 @@ public function advanceToNextNonSpaceOrNewline(): int // [0][0] contains the matched text // [0][1] contains the index of that match + \assert(isset($matches[0])); $increment = $matches[0][1] + \strlen($matches[0][0]); $this->advanceBy($increment); diff --git a/src/Util/RegexHelper.php b/src/Util/RegexHelper.php index cab073d7f9..a89e7bda66 100644 --- a/src/Util/RegexHelper.php +++ b/src/Util/RegexHelper.php @@ -41,7 +41,7 @@ final class RegexHelper public const PARTIAL_REG_CHAR = '[^\\\\()\x00-\x20]'; public const PARTIAL_IN_PARENS_NOSP = '\((' . self::PARTIAL_REG_CHAR . '|' . self::PARTIAL_ESCAPED_CHAR . '|\\\\)*\)'; public const PARTIAL_TAGNAME = '[a-z][a-z0-9-]*'; - public 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|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)'; + public 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|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)'; public const PARTIAL_ATTRIBUTENAME = '[a-z_:][a-z0-9:._-]*'; public const PARTIAL_UNQUOTEDVALUE = '[^"\'=<>`\x00-\x20]+'; public const PARTIAL_SINGLEQUOTEDVALUE = '\'[^\']*\''; diff --git a/src/Util/SpecReader.php b/src/Util/SpecReader.php index 7523304e8f..faee2042ce 100644 --- a/src/Util/SpecReader.php +++ b/src/Util/SpecReader.php @@ -40,6 +40,7 @@ public static function read(string $data): iterable $exampleNumber = 0; foreach ($matches as $match) { + \assert(isset($match[1], $match[2], $match[3])); if (isset($match[4])) { $currentSection = $match[4]; continue; diff --git a/tests/functional/CMarkRegressionTest.php b/tests/functional/CMarkRegressionTest.php index 16ae72a1de..3ebd402fb0 100644 --- a/tests/functional/CMarkRegressionTest.php +++ b/tests/functional/CMarkRegressionTest.php @@ -33,6 +33,12 @@ public static function dataProvider(): \Generator $example['output'] = \str_replace('', "\n", $example['output']); } + // The case-fold test from example 21 fails on PHP 8.0.* and below due to the behavior of mb_convert_case(). + // See https://3v4l.org/7TeXJ. + if (\PHP_VERSION_ID < 81000 && $example['number'] === 21) { + continue; + } + yield $example; } }