BadMethodCallException on nested html lists on valid HTML #1265
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
We did not consider nested html lists as edge case in #1239.
Additionally the markup in the Sample 26 is invalid. When nesting lists the
<ol>
should be in a<li>
not outside (compare https://www.w3schools.com/html/html_lists.asp).I corrected the documentation an added a test which fails with
BadMethodCallException : Cannot add ListItemRun in ListItemRun. /opt/Development/PHPWord/src/PhpWord/Element/AbstractContainer.php:230 /opt/Development/PHPWord/src/PhpWord/Element/AbstractContainer.php:130 /opt/Development/PHPWord/src/PhpWord/Element/AbstractContainer.php:112 /opt/Development/PHPWord/src/PhpWord/Shared/Html.php:438 /opt/Development/PHPWord/src/PhpWord/Shared/Html.php:163 /opt/Development/PHPWord/src/PhpWord/Shared/Html.php:195 /opt/Development/PHPWord/src/PhpWord/Shared/Html.php:177 /opt/Development/PHPWord/src/PhpWord/Shared/Html.php:440 /opt/Development/PHPWord/src/PhpWord/Shared/Html.php:163 /opt/Development/PHPWord/src/PhpWord/Shared/Html.php:195 /opt/Development/PHPWord/src/PhpWord/Shared/Html.php:177 /opt/Development/PHPWord/src/PhpWord/Shared/Html.php:195 /opt/Development/PHPWord/src/PhpWord/Shared/Html.php:177 /opt/Development/PHPWord/src/PhpWord/Shared/Html.php:70 /opt/Development/PHPWord/tests/PhpWord/Shared/HtmlTest.php:296
Assertions in Test are not correct yet, I did not know how the markup would be.
I see this PR as WIP, I think you are much faster in tackling this than me, hopefully this PR helps a bit.
Checklist:
composer check
and no errors were reported