return objects;
}
private void recurse(final Element element, final Map<String, Object> values, final int depth) {
final Tag tag = element.tag();
final Set<String> classes = element.classNames();
final String link = element.attr("href");
final Object content = extractChildContent(element);
if (!classes.isEmpty()) {
removeEmpty(classes);
// toplevel classes define type
if (tag.isBlock()) {
if (depth == 0) {
// store type attribute
values.put("type", classes);
for (final Element child : element.children()) {
recurse(child, values, depth+1);
}
} else {
final Map<String, Object> childMap = new LinkedHashMap<>();
values.put(classes.iterator().next(), childMap);
if (content != null) {
childMap.put("name", content);
}
for (final Element child : element.children()) {
recurse(child, childMap, depth+1);
}
}
} else if (tag.isInline()) {
// extract href and store as URL
if (classes.contains("url") && StringUtils.isNotBlank(link)) {
values.put("url", link);