use of com.vladsch.flexmark.util.ast.Block in project gerrit by GerritCodeReview.
the class MarkdownFormatter method findTitle.
private String findTitle(Node root) {
if (root instanceof Heading) {
Heading h = (Heading) root;
if (h.getLevel() == 1 && h.hasChildren()) {
TextCollectingVisitor collectingVisitor = new TextCollectingVisitor();
return collectingVisitor.collectAndGetText(h);
}
}
if (root instanceof Block && root.hasChildren()) {
Node child = root.getFirstChild();
while (child != null) {
String title = findTitle(child);
if (title != null) {
return title;
}
child = child.getNext();
}
}
return null;
}
Aggregations