diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 6e0394c8d..09d557018 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -18,6 +18,9 @@ Improvement:: * BREAKING: Allow Preprocessor extensions to create new Readers and replace the original Reader. (#1081) * Upgrade to asciidoctorj-pdf 2.1.6 (#1094) +Bug Fixes:: + +* Cell nodes do not inherit from StructuralNode (#1086) (@rahmanusta) == 2.5.4 (2022-06-30) diff --git a/asciidoctorj-api/src/main/java/org/asciidoctor/ast/Cell.java b/asciidoctorj-api/src/main/java/org/asciidoctor/ast/Cell.java index e860fb3b3..7edc6da11 100644 --- a/asciidoctorj-api/src/main/java/org/asciidoctor/ast/Cell.java +++ b/asciidoctorj-api/src/main/java/org/asciidoctor/ast/Cell.java @@ -1,6 +1,6 @@ package org.asciidoctor.ast; -public interface Cell extends ContentNode { +public interface Cell extends StructuralNode { Column getColumn(); diff --git a/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/ast/impl/CellImpl.java b/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/ast/impl/CellImpl.java index 801383441..495b7d883 100644 --- a/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/ast/impl/CellImpl.java +++ b/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/ast/impl/CellImpl.java @@ -6,7 +6,7 @@ import org.asciidoctor.ast.Table; import org.jruby.runtime.builtin.IRubyObject; -public class CellImpl extends ContentNodeImpl implements Cell { +public class CellImpl extends StructuralNodeImpl implements Cell { public CellImpl(IRubyObject rubyNode) { super(rubyNode); diff --git a/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAsciiDocIsLoadedToDocument.java b/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAsciiDocIsLoadedToDocument.java index be6c12733..4f965e885 100644 --- a/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAsciiDocIsLoadedToDocument.java +++ b/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAsciiDocIsLoadedToDocument.java @@ -2,6 +2,7 @@ import org.asciidoctor.arquillian.api.Unshared; import org.asciidoctor.ast.Author; +import org.asciidoctor.ast.Cell; import org.asciidoctor.ast.Document; import org.asciidoctor.ast.RevisionInfo; import org.asciidoctor.ast.Section; @@ -21,6 +22,7 @@ import java.util.Map; import static java.util.Collections.emptyMap; +import static java.util.stream.Collectors.toList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @@ -51,7 +53,12 @@ public class WhenAsciiDocIsLoadedToDocument { "\n" + "== Section B\n" + "\n" + - "paragraph"; + "paragraph\n" + + "\n" + + "|===\n" + + "|A\n" + + "|B\n" + + "|==="; private static final String ROLE = "[\"quote\", \"author\", \"source\", role=\"famous\"]\n" + "____\n" + @@ -93,6 +100,20 @@ public void should_return_a_document_object_from_string() { assertThat(document.getDoctitle(), is("Document Title")); } + @Test + public void should_find_all_nodes() { + Document document = asciidoctor.load(DOCUMENT, Options.builder().sourcemap(true).build()); + List findBy = document.findBy(new HashMap<>()); + assertThat(findBy, hasSize(17)); + List tableCells = findBy.stream() + .filter(Cell.class::isInstance) + .map(Cell.class::cast) + .collect(toList()); + assertThat(tableCells, hasSize(2)); + assertThat(tableCells.get(0).getSourceLocation().getLineNumber(), is(23)); + assertThat(tableCells.get(1).getSourceLocation().getLineNumber(), is(24)); + } + @Test public void should_find_elements_from_document() {