Re: Is AST Document limited to see blocks - level 1,2 only
Posted by
ch007m on
Apr 09, 2020; 10:36am
URL: https://discuss.asciidoctor.org/Is-AST-Document-limited-to-see-blocks-level-1-2-only-tp7858p7863.html
After digging into the doc, I was able to fix it and to access the levels 3,4,.... Sorry ;-)
private void processBlock(StructuralNode node) {
List<StructuralNode> sections = node.getBlocks();
for (int i = 0; i < sections.size(); i++) {
final StructuralNode currentBlock = sections.get(i);
System.out.println("Node : " + currentBlock.getContext() + ", title \"" + currentBlock.getTitle() + "\"");
if ("section".equals(currentBlock.getContext())) {
List<StructuralNode> subLevels = currentBlock.getBlocks();
for (int j = 0; j < subLevels.size(); j++) {
final StructuralNode subLevel = subLevels.get(j);
if (subLevel.getTitle() == null) {
System.out.println(" Node : " + subLevel.getContext());
} else {
System.out.println(" Node : " + subLevel.getContext() + ", title \"" + subLevel.getTitle() + "\"");
}
}
}
Charles Moulliard
Apache Committer / Technologist Evangelist / Blogger / MiddleWare Specialist
Twitter : @cmoulliard