org.commonmark.ext.front.matter.YamlFrontMatterVisitor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commonmark-ext-yaml-front-matter Show documentation
Show all versions of commonmark-ext-yaml-front-matter Show documentation
commonmark-java extension for YAML front matter
package org.commonmark.ext.front.matter;
import org.commonmark.node.AbstractVisitor;
import org.commonmark.node.CustomNode;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class YamlFrontMatterVisitor extends AbstractVisitor {
private Map> data;
public YamlFrontMatterVisitor() {
data = new LinkedHashMap<>();
}
@Override
public void visit(CustomNode customNode) {
if (customNode instanceof YamlFrontMatterNode) {
data.put(((YamlFrontMatterNode) customNode).getKey(), ((YamlFrontMatterNode) customNode).getValues());
} else {
super.visit(customNode);
}
}
public Map> getData() {
return data;
}
}