Fixes add caption handling in StructuralNode
MODIFY
asciidoctorj-api/src/main/java/org/asciidoctor/ast/StructuralNode.java
asciidoctorj-api/src/main/java/org/asciidoctor/ast/StructuralNode.java
@@ -47,6 +47,10 @@ public interface StructuralNode extends ContentNode {
String title();
String getTitle();
void setTitle(String title);
+
+ String getCaption();
+ void setCaption(String caption);
+
/**
* @deprecated Please use {@linkplain #getStyle()} instead
*/

MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/ast/impl/StructuralNodeImpl.java
asciidoctorj-core/src/main/java/org/asciidoctor/ast/impl/StructuralNodeImpl.java
@@ -35,6 +35,16 @@ public class StructuralNodeImpl extends ContentNodeImpl implements StructuralNod
setString("title", title);
}
+ @Override
+ public String getCaption() {
+ return getString("caption");
+ }
+
+ @Override
+ public void setCaption(String caption) {
+ setString("caption", caption);
+ }
+
@Override
public String style() {
return getStyle();

MODIFY
asciidoctorj-core/src/test/java/org/asciidoctor/WhenAsciiDocIsRenderedToDocument.java
asciidoctorj-core/src/test/java/org/asciidoctor/WhenAsciiDocIsRenderedToDocument.java
@@ -24,6 +24,7 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.hamcrest.collection.IsMapContaining.hasKey;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
@@ -352,4 +353,19 @@ public class WhenAsciiDocIsRenderedToDocument {
assertNull(document.getParent());
}
+ @Test
+ public void should_read_caption() {
+ String s = "[caption=\"Table A. \"]\n" +
+ ".A formal table\n" +
+ "|===\n" +
+ "|Cell in column 1, row 1\n" +
+ "|Cell in column 2, row 1\n" +
+ "|===";
+
+ Document document = asciidoctor.load(s, new HashMap<String, Object>());
+ assertNotNull(document.getBlocks());
+ assertThat(document.getBlocks().size(), is(1));
+ assertThat(document.getBlocks().get(0).getCaption(), is("Table A. "));
+ }
+
}

Fixes #612: add caption handling in StructuralNode