本文整理了Java中org.commonmark.node.Node.accept()
方法的一些代码示例,展示了Node.accept()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.accept()
方法的具体详情如下:
包路径:org.commonmark.node.Node
类名称:Node
方法名:accept
暂无
代码示例来源:origin: atlassian/commonmark-java
@Override
public void render(Node node) {
node.accept(this);
}
代码示例来源:origin: atlassian/commonmark-java
@Override
public void render(Node node) {
node.accept(this);
}
代码示例来源:origin: atlassian/commonmark-java
@Override
public Node process(Node node) {
AutolinkVisitor autolinkVisitor = new AutolinkVisitor();
node.accept(autolinkVisitor);
return node;
}
代码示例来源:origin: atlassian/commonmark-java
@Override
public void setAttributes(Node node, String tagName, final Map<String, String> attributes) {
if (node instanceof Heading) {
final List<String> wordList = new ArrayList<>();
node.accept(new AbstractVisitor() {
@Override
public void visit(Text text) {
wordList.add(text.getLiteral());
}
@Override
public void visit(Code code) {
wordList.add(code.getLiteral());
}
});
String finalString = "";
for (String word : wordList) {
finalString += word;
}
finalString = finalString.trim().toLowerCase();
attributes.put("id", idGenerator.generateId(finalString));
}
}
}
代码示例来源:origin: atlassian/commonmark-java
/**
* Visit the child nodes.
*
* @param parent the parent node whose children should be visited
*/
protected void visitChildren(Node parent) {
Node node = parent.getFirstChild();
while (node != null) {
// A subclass of this visitor might modify the node, resulting in getNext returning a different node or no
// node after visiting it. So get the next node before visiting.
Node next = node.getNext();
node.accept(this);
node = next;
}
}
}
代码示例来源:origin: JpressProjects/jpress
/**
* 获取元数据
*
* @param content content
* @return Map
*/
public static Map<String, List<String>> getFrontMatter(String content) {
YamlFrontMatterVisitor visitor = new YamlFrontMatterVisitor();
Node document = PARSER.parse(content);
document.accept(visitor);
return visitor.getData();
}
代码示例来源:origin: com.atlassian.commonmark/commonmark
@Override
public void render(Node node) {
node.accept(this);
}
代码示例来源:origin: com.atlassian.commonmark/commonmark
@Override
public void render(Node node) {
node.accept(this);
}
代码示例来源:origin: com.atlassian.commonmark/commonmark-ext-heading-anchor
@Override
public void setAttributes(Node node, String tagName, final Map<String, String> attributes) {
if (node instanceof Heading) {
final List<String> wordList = new ArrayList<>();
node.accept(new AbstractVisitor() {
@Override
public void visit(Text text) {
wordList.add(text.getLiteral());
}
@Override
public void visit(Code code) {
wordList.add(code.getLiteral());
}
});
String finalString = "";
for (String word : wordList) {
finalString += word;
}
finalString = finalString.trim().toLowerCase();
attributes.put("id", idGenerator.generateId(finalString));
}
}
}
代码示例来源:origin: org.symphonyoss.symphony/messageml
/**
* Parse the Markdown message and entity JSON into a MessageML document.
*/
public MessageML parse(String message, JsonNode entities, JsonNode media) throws InvalidInputException {
this.index = 0;
message = message.replace((char) 160, (char) 32);
String enriched = enrichMarkdown(message, entities, media);
Node markdown = MARKDOWN_PARSER.parse(enriched);
markdown.accept(this);
return messageML;
}
代码示例来源:origin: noties/Markwon
@NonNull
public CharSequence render(@NonNull SpannableConfiguration configuration, @NonNull Node node) {
final SpannableBuilder builder = new SpannableBuilder();
node.accept(new SpannableMarkdownVisitor(configuration, builder));
return builder.text();
}
}
代码示例来源:origin: googleapis/gapic-generator
protected void visitChildren(Node node) {
Node child = node.getFirstChild();
while (child != null) {
Node next = child.getNext();
child.accept(this);
child = next;
}
}
}
代码示例来源:origin: com.atlassian.commonmark/commonmark
/**
* Visit the child nodes.
*
* @param parent the parent node whose children should be visited
*/
protected void visitChildren(Node parent) {
Node node = parent.getFirstChild();
while (node != null) {
// A subclass of this visitor might modify the node, resulting in getNext returning a different node or no
// node after visiting it. So get the next node before visiting.
Node next = node.getNext();
node.accept(this);
node = next;
}
}
}
代码示例来源:origin: googleapis/gapic-generator
@Override
public String reformat(String comment) {
Node root = PARSER.parse(comment);
GoVisitor visitor = new GoVisitor();
try {
root.accept(visitor);
return visitor.toString();
} catch (ErrorMarkdownVisitor.UnimplementedRenderException e) {
LOGGER.log(
Level.WARNING, "markdown contains elements we don't handle; copying doc verbatim", e);
return comment;
}
}
代码示例来源:origin: org.symphonyoss.symphony/messageml
/**
* Recursively visit the children of the node, processing only those specified by the parameter "includeNodes".
*/
private void visitChildren(Node parent, Collection<Class<? extends Node>> includeNodes) {
Node child = parent.getFirstChild();
while (child != null) {
// A subclass of this visitor might modify the node, resulting in getNext returning a different node or no
// node after visiting it. So get the next node before visiting.
Node next = child.getNext();
if (includeNodes.contains(child.getClass())) {
child.accept(this);
} else {
visitChildren(child, includeNodes);
}
child = next;
}
}
代码示例来源:origin: synchrony/smsn
private void visitChildren(final Node node) {
if (verbose) {
echo(node);
}
currentDepth++;
Node child = node.getFirstChild();
while (null != child) {
child.accept(this);
child = child.getNext();
}
currentDepth--;
}
代码示例来源:origin: com.github.nic-luo/rober-sql
curNode.accept(new AbstractVisitor() {
public void visit(Text text) {
texts.add(text.getLiteral());
代码示例来源:origin: noties/Markwon
node.accept(visitor);
代码示例来源:origin: noties/Markwon
node.accept(visitor);
代码示例来源:origin: noties/Markwon
@Test
public void test() {
final TestData data = TestDataReader.readTest(file);
final SpannableConfiguration configuration = configuration(data.config());
final SpannableBuilder builder = new SpannableBuilder();
final SpannableMarkdownVisitor visitor = new SpannableMarkdownVisitor(configuration, builder);
final Node node = Markwon.createParser().parse(data.input());
node.accept(visitor);
final SpannableStringBuilder stringBuilder = builder.spannableStringBuilder();
final TestValidator validator = TestValidator.create(file);
int index = 0;
for (TestNode testNode : data.output()) {
index = validator.validate(stringBuilder, index, testNode);
}
// assert that the whole thing is processed
assertEquals("`" + stringBuilder + "`", stringBuilder.length(), index);
final Object[] spans = stringBuilder.getSpans(0, stringBuilder.length(), Object.class);
final int length = spans != null
? spans.length
: 0;
assertEquals(Arrays.toString(spans), validator.processedSpanNodesCount(), length);
}
内容来源于网络,如有侵权,请联系作者删除!