org.commonmark.node.Node.accept()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(171)

本文整理了Java中org.commonmark.node.Node.accept()方法的一些代码示例,展示了Node.accept()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.accept()方法的具体详情如下:
包路径:org.commonmark.node.Node
类名称:Node
方法名:accept

Node.accept介绍

暂无

代码示例

代码示例来源:origin: atlassian/commonmark-java

  1. @Override
  2. public void render(Node node) {
  3. node.accept(this);
  4. }

代码示例来源:origin: atlassian/commonmark-java

  1. @Override
  2. public void render(Node node) {
  3. node.accept(this);
  4. }

代码示例来源:origin: atlassian/commonmark-java

  1. @Override
  2. public Node process(Node node) {
  3. AutolinkVisitor autolinkVisitor = new AutolinkVisitor();
  4. node.accept(autolinkVisitor);
  5. return node;
  6. }

代码示例来源:origin: atlassian/commonmark-java

  1. @Override
  2. public void setAttributes(Node node, String tagName, final Map<String, String> attributes) {
  3. if (node instanceof Heading) {
  4. final List<String> wordList = new ArrayList<>();
  5. node.accept(new AbstractVisitor() {
  6. @Override
  7. public void visit(Text text) {
  8. wordList.add(text.getLiteral());
  9. }
  10. @Override
  11. public void visit(Code code) {
  12. wordList.add(code.getLiteral());
  13. }
  14. });
  15. String finalString = "";
  16. for (String word : wordList) {
  17. finalString += word;
  18. }
  19. finalString = finalString.trim().toLowerCase();
  20. attributes.put("id", idGenerator.generateId(finalString));
  21. }
  22. }
  23. }

代码示例来源:origin: atlassian/commonmark-java

  1. /**
  2. * Visit the child nodes.
  3. *
  4. * @param parent the parent node whose children should be visited
  5. */
  6. protected void visitChildren(Node parent) {
  7. Node node = parent.getFirstChild();
  8. while (node != null) {
  9. // A subclass of this visitor might modify the node, resulting in getNext returning a different node or no
  10. // node after visiting it. So get the next node before visiting.
  11. Node next = node.getNext();
  12. node.accept(this);
  13. node = next;
  14. }
  15. }
  16. }

代码示例来源:origin: JpressProjects/jpress

  1. /**
  2. * 获取元数据
  3. *
  4. * @param content content
  5. * @return Map
  6. */
  7. public static Map<String, List<String>> getFrontMatter(String content) {
  8. YamlFrontMatterVisitor visitor = new YamlFrontMatterVisitor();
  9. Node document = PARSER.parse(content);
  10. document.accept(visitor);
  11. return visitor.getData();
  12. }

代码示例来源:origin: com.atlassian.commonmark/commonmark

  1. @Override
  2. public void render(Node node) {
  3. node.accept(this);
  4. }

代码示例来源:origin: com.atlassian.commonmark/commonmark

  1. @Override
  2. public void render(Node node) {
  3. node.accept(this);
  4. }

代码示例来源:origin: com.atlassian.commonmark/commonmark-ext-heading-anchor

  1. @Override
  2. public void setAttributes(Node node, String tagName, final Map<String, String> attributes) {
  3. if (node instanceof Heading) {
  4. final List<String> wordList = new ArrayList<>();
  5. node.accept(new AbstractVisitor() {
  6. @Override
  7. public void visit(Text text) {
  8. wordList.add(text.getLiteral());
  9. }
  10. @Override
  11. public void visit(Code code) {
  12. wordList.add(code.getLiteral());
  13. }
  14. });
  15. String finalString = "";
  16. for (String word : wordList) {
  17. finalString += word;
  18. }
  19. finalString = finalString.trim().toLowerCase();
  20. attributes.put("id", idGenerator.generateId(finalString));
  21. }
  22. }
  23. }

代码示例来源:origin: org.symphonyoss.symphony/messageml

  1. /**
  2. * Parse the Markdown message and entity JSON into a MessageML document.
  3. */
  4. public MessageML parse(String message, JsonNode entities, JsonNode media) throws InvalidInputException {
  5. this.index = 0;
  6. message = message.replace((char) 160, (char) 32);
  7. String enriched = enrichMarkdown(message, entities, media);
  8. Node markdown = MARKDOWN_PARSER.parse(enriched);
  9. markdown.accept(this);
  10. return messageML;
  11. }

代码示例来源:origin: noties/Markwon

  1. @NonNull
  2. public CharSequence render(@NonNull SpannableConfiguration configuration, @NonNull Node node) {
  3. final SpannableBuilder builder = new SpannableBuilder();
  4. node.accept(new SpannableMarkdownVisitor(configuration, builder));
  5. return builder.text();
  6. }
  7. }

代码示例来源:origin: googleapis/gapic-generator

  1. protected void visitChildren(Node node) {
  2. Node child = node.getFirstChild();
  3. while (child != null) {
  4. Node next = child.getNext();
  5. child.accept(this);
  6. child = next;
  7. }
  8. }
  9. }

代码示例来源:origin: com.atlassian.commonmark/commonmark

  1. /**
  2. * Visit the child nodes.
  3. *
  4. * @param parent the parent node whose children should be visited
  5. */
  6. protected void visitChildren(Node parent) {
  7. Node node = parent.getFirstChild();
  8. while (node != null) {
  9. // A subclass of this visitor might modify the node, resulting in getNext returning a different node or no
  10. // node after visiting it. So get the next node before visiting.
  11. Node next = node.getNext();
  12. node.accept(this);
  13. node = next;
  14. }
  15. }
  16. }

代码示例来源:origin: googleapis/gapic-generator

  1. @Override
  2. public String reformat(String comment) {
  3. Node root = PARSER.parse(comment);
  4. GoVisitor visitor = new GoVisitor();
  5. try {
  6. root.accept(visitor);
  7. return visitor.toString();
  8. } catch (ErrorMarkdownVisitor.UnimplementedRenderException e) {
  9. LOGGER.log(
  10. Level.WARNING, "markdown contains elements we don't handle; copying doc verbatim", e);
  11. return comment;
  12. }
  13. }

代码示例来源:origin: org.symphonyoss.symphony/messageml

  1. /**
  2. * Recursively visit the children of the node, processing only those specified by the parameter "includeNodes".
  3. */
  4. private void visitChildren(Node parent, Collection<Class<? extends Node>> includeNodes) {
  5. Node child = parent.getFirstChild();
  6. while (child != null) {
  7. // A subclass of this visitor might modify the node, resulting in getNext returning a different node or no
  8. // node after visiting it. So get the next node before visiting.
  9. Node next = child.getNext();
  10. if (includeNodes.contains(child.getClass())) {
  11. child.accept(this);
  12. } else {
  13. visitChildren(child, includeNodes);
  14. }
  15. child = next;
  16. }
  17. }

代码示例来源:origin: synchrony/smsn

  1. private void visitChildren(final Node node) {
  2. if (verbose) {
  3. echo(node);
  4. }
  5. currentDepth++;
  6. Node child = node.getFirstChild();
  7. while (null != child) {
  8. child.accept(this);
  9. child = child.getNext();
  10. }
  11. currentDepth--;
  12. }

代码示例来源:origin: com.github.nic-luo/rober-sql

  1. curNode.accept(new AbstractVisitor() {
  2. public void visit(Text text) {
  3. texts.add(text.getLiteral());

代码示例来源:origin: noties/Markwon

  1. node.accept(visitor);

代码示例来源:origin: noties/Markwon

  1. node.accept(visitor);

代码示例来源:origin: noties/Markwon

  1. @Test
  2. public void test() {
  3. final TestData data = TestDataReader.readTest(file);
  4. final SpannableConfiguration configuration = configuration(data.config());
  5. final SpannableBuilder builder = new SpannableBuilder();
  6. final SpannableMarkdownVisitor visitor = new SpannableMarkdownVisitor(configuration, builder);
  7. final Node node = Markwon.createParser().parse(data.input());
  8. node.accept(visitor);
  9. final SpannableStringBuilder stringBuilder = builder.spannableStringBuilder();
  10. final TestValidator validator = TestValidator.create(file);
  11. int index = 0;
  12. for (TestNode testNode : data.output()) {
  13. index = validator.validate(stringBuilder, index, testNode);
  14. }
  15. // assert that the whole thing is processed
  16. assertEquals("`" + stringBuilder + "`", stringBuilder.length(), index);
  17. final Object[] spans = stringBuilder.getSpans(0, stringBuilder.length(), Object.class);
  18. final int length = spans != null
  19. ? spans.length
  20. : 0;
  21. assertEquals(Arrays.toString(spans), validator.processedSpanNodesCount(), length);
  22. }

相关文章