Skip to content

Commit

Permalink
Fixes asciidoctor#1086. Make Cell extend StructuralNode instead of Co…
Browse files Browse the repository at this point in the history
…ntentNode.
  • Loading branch information
robertpanzer committed Jul 23, 2022
1 parent 8d2f7be commit 7f40e7e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.asciidoctor.ast;

public interface Cell extends ContentNode {
public interface Cell extends StructuralNode {

Column getColumn();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.*;
Expand Down Expand Up @@ -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" +
Expand Down Expand Up @@ -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<StructuralNode> findBy = document.findBy(new HashMap<>());
assertThat(findBy, hasSize(17));
List<Cell> 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() {

Expand Down

0 comments on commit 7f40e7e

Please sign in to comment.