diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b49d80..c31d9c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## 3.3.1 (24. March 2023) + ++ [#78](https://github.com/nadar/quill-delta-parser/issues/78) Fixed a bug where lists with empty contents would break all output. + ## 3.3.0 (10. March 2023) + [#77](https://github.com/nadar/quill-delta-parser/pull/77) Allow method chaining for `registerListener()` and `overwriteListener()`. diff --git a/composer.lock b/composer.lock index 0f0c2b4..4cca5b9 100644 --- a/composer.lock +++ b/composer.lock @@ -806,16 +806,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.6", + "version": "1.10.7", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "50d089a3e0904b0fe7e2cf2d4fd37d427d64235a" + "reference": "b10ceb526d9607903c5b2673f1fc8775dbe48975" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/50d089a3e0904b0fe7e2cf2d4fd37d427d64235a", - "reference": "50d089a3e0904b0fe7e2cf2d4fd37d427d64235a", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b10ceb526d9607903c5b2673f1fc8775dbe48975", + "reference": "b10ceb526d9607903c5b2673f1fc8775dbe48975", "shasum": "" }, "require": { @@ -844,8 +844,11 @@ "static analysis" ], "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.10.6" + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" }, "funding": [ { @@ -861,7 +864,7 @@ "type": "tidelift" } ], - "time": "2023-03-09T16:55:12+00:00" + "time": "2023-03-16T15:24:20+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/src/listener/Lists.php b/src/listener/Lists.php index 80e8dab..f55245e 100644 --- a/src/listener/Lists.php +++ b/src/listener/Lists.php @@ -49,24 +49,33 @@ public function process(Line $line) public function render(Lexer $lexer) { $isOpen = false; + $isEmpty = false; $listTag = null; foreach ($this->picks() as $pick) { $first = $this->getFirstLine($pick); - // while from first to the pick line and store content in buffer - $buffer = null; - $first->while(static function (&$index, Line $line) use (&$buffer, $pick) { - ++$index; - $buffer.= $line->getInput(); - $line->setDone(); - if ($index == $pick->line->getIndex()) { - return false; - } - }); - // defines whether this attribute list element is the last one of a list serie. $isLast = false; + // if this is an empty line .... the first attribute contains the list information, otherwise + // the first line contains content. + if ($first->getAttribute(self::ATTRIBUTE_LIST)) { + $isEmpty = true; + } + + // while from first to the pick line and store content in buffer + $buffer = null; + if (!$isEmpty) { + $first->while(static function (&$index, Line $line) use (&$buffer, $pick) { + ++$index; + $buffer.= $line->getInput(); + $line->setDone(); + if ($index == $pick->line->getIndex()) { + return false; + } + }); + } + // go to the next element with endlinew and check if it contains a list type until then $hasNextInside = false; $pick->line->whileNext(static function (Line $line) use (&$hasNextInside) { @@ -113,19 +122,23 @@ public function render(Lexer $lexer) } }); - $output .= '
Bullet point content
EOT; } diff --git a/tests/Issue53TestFixedTest.php b/tests/Issue53TestFixedTest.php new file mode 100644 index 0000000..e0b3c3a --- /dev/null +++ b/tests/Issue53TestFixedTest.php @@ -0,0 +1,26 @@ +New title