asciidoctor / asciidoctorj

:coffee: Java bindings for Asciidoctor. Asciidoctor on the JVM!
http://asciidoctor.org
Apache License 2.0
627 stars 172 forks source link

Fixes #1082. Return empty list in DescriptionList.getBlocks() instead… #1083

Closed robertpanzer closed 2 years ago

robertpanzer commented 2 years ago

… of return a list of DescriptionListItems, which are not blocks

Thank you for opening a pull request and contributing to AsciidoctorJ!

Please take a bit of time giving some details about your pull request:

Kind of change

Description

What is the goal of this pull request?

1082 reports that DescriptionList.getSections() returns a list of objects that are not StructuralNodes but DescriptionListEntries instead. (This only works due to type erasure).

How does it achieve that?

This PR tries to fix the problem by making DescriptionList.getSections() return a new empty list. That way there will no longer be a ClassCastException when recursively traversing the AST only via getSections().

Are there any alternative ways to implement this?

It could be possible to change the form of the AST by making DescriptionListEntry a StructuralNode that has the terms as properties. That might be difficult as the implementation of Asciidoctor Ruby currently treats the terms and its description as a list with 2 items: [[ListItem Term1, ListItem Term2], ListItem Description]. This might be difficult to implement, leaves the question open how to handle description list entries without description and also this would be a breaking change.

Are there any implications of this pull request? Anything a user must know?

Adding any nodes to the result of DescriptionList.getSections() is without any effect.

Issue

Fixes #1082

Release notes

Please add a corresponding entry to the file CHANGELOG.adoc

abelsromero commented 2 years ago

Been thinking on & off and I think you are right, it's best to keep it simple and be consistent with the fact these are not blocks and return empty.