org.pegdown.ast.Node类的使用及代码示例

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

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

Node介绍

暂无

代码示例

代码示例来源:origin: org.pegdown/pegdown

SuperNode wrapFirstSubItemInPara(SuperNode item) {
  Node firstItemFirstChild = item.getChildren().get(0);
  if (firstItemFirstChild.getChildren().size() == 1) {
    Node firstGrandChild = firstItemFirstChild.getChildren().get(0);
    if (firstGrandChild instanceof ListItemNode) {
      wrapFirstItemInPara((SuperNode)firstGrandChild);
    }
  }
  return item;
}

代码示例来源:origin: org.pegdown/pegdown

protected void visitChildren(SuperNode node) {
  for (Node child : node.getChildren()) {
    child.accept(this);
  }
}

代码示例来源:origin: org.pegdown/pegdown

boolean wrapFirstItemInPara(SuperNode item) {
  Node firstItemFirstChild = item.getChildren().get(0);
  ParaNode paraNode = new ParaNode(firstItemFirstChild.getChildren());
  paraNode.setStartIndex(firstItemFirstChild.getStartIndex());
  paraNode.setEndIndex(firstItemFirstChild.getEndIndex());
  // vsch: wrap the para in RootNode so that it is identical to the rest of the list items if they are loose, otherwise it creates differences in html serialization of task items
  RootNode rootNode = new RootNode();
  rootNode.setStartIndex(paraNode.getStartIndex());
  rootNode.setEndIndex(paraNode.getEndIndex());
  rootNode.getChildren().add(paraNode);
  item.getChildren().set(0, rootNode);
  return true;
}

代码示例来源:origin: org.pegdown/pegdown

public void collectChildrensText(SuperNode node, AnchorNodeInfo nodeInfo) {
  for (Node child : node.getChildren()) {
    // accumulate all the text
    if (child.getClass() == TextNode.class || child.getClass() == SpecialTextNode.class) {
      nodeInfo.text.append(((TextNode) child).getText());
      if (nodeInfo.startIndex == 0) {
        nodeInfo.startIndex = child.getStartIndex();
      }
      nodeInfo.endIndex = child.getEndIndex();
    } else if (child instanceof SuperNode) {
      collectChildrensText((SuperNode) child, nodeInfo);
    }
  }
}

代码示例来源:origin: gradle.plugin.com.github.qwazer/markdown-confluence-gradle-plugin

protected <T extends Node> void visitChildren(T node) {
  for (Node child : node.getChildren()) {
    child.accept(this);
  }
}

代码示例来源:origin: gradle.plugin.com.github.qwazer/markdown-confluence-gradle-plugin

int col = 0;
int offset = node.getStartIndex();

代码示例来源:origin: org.bsc.maven/maven-confluence-core

protected <T extends Node> void visitChildren(T node) {
  for (Node child : node.getChildren()) {
    child.accept(this);
  }
}

代码示例来源:origin: org.pegdown/pegdown

boolean setListItemIndices() {
  SuperNode listItem = (SuperNode) getContext().getValueStack().peek();
  List<Node> children = listItem.getChildren();
  listItem.setStartIndex(children.get(0).getStartIndex());
  listItem.setEndIndex(children.get(children.size() - 1).getEndIndex());
  return true;
}

代码示例来源:origin: org.bsc.maven/maven-confluence-core

int col = 0;
int offset = node.getStartIndex();

代码示例来源:origin: org.pegdown/pegdown

Node withIndicesShifted(Node node, int delta) {
  if (delta != 0) {
    ((AbstractNode) node).shiftIndices(delta);
    for (Node subNode : node.getChildren()) {
      withIndicesShifted(subNode, delta);
    }
  }
  return node;
}

代码示例来源:origin: bsorrentino/maven-confluence-plugin

protected <T extends Node> void visitChildren(T node) {
  for (Node child : node.getChildren()) {
    child.accept(this);
  }
}

代码示例来源:origin: org.pegdown/pegdown

protected void visitChildrenSkipFirst(SuperNode node) {
  boolean first = true;
  for (Node child : node.getChildren()) {
    if (!first) child.accept(this);
    first = false;
  }
}

代码示例来源:origin: org.pegdown/pegdown

public boolean wrapInAnchor() {
  if (ext(ANCHORLINKS | EXTANCHORLINKS)) {
    SuperNode node = (SuperNode) peek();
    List<Node> children = node.getChildren();
    if (ext(EXTANCHORLINKS)) {
      if (children.size() > 0) {
        AnchorNodeInfo nodeInfo = new AnchorNodeInfo();
        collectChildrensText(node, nodeInfo);
        String text = nodeInfo.text.toString().trim();
        if (text.length() > 0) {
          AnchorLinkNode anchor = new AnchorLinkNode(text, "");
          anchor.setStartIndex(nodeInfo.startIndex);
          anchor.setEndIndex(nodeInfo.endIndex);
          children.add(0, anchor);
        }
      }
    } else {
      if (children.size() == 1) {
        Node child = children.get(0);
        if (child instanceof TextNode) {
          AnchorLinkNode anchor = new AnchorLinkNode(((TextNode) child).getText());
          anchor.setStartIndex(child.getStartIndex());
          anchor.setEndIndex(child.getEndIndex());
          children.set(0, anchor);
        }
      }
    }
  }
  return true;
}

代码示例来源:origin: bsorrentino/maven-confluence-plugin

int col = 0;
int offset = node.getStartIndex();

代码示例来源:origin: org.pegdown/pegdown

protected void fixIndices(Node node, int[] ixMap) {
  ((AbstractNode) node).mapIndices(ixMap);
  for (Node subNode : node.getChildren()) {
    fixIndices(subNode, ixMap);
  }
}

代码示例来源:origin: org.pegdown/pegdown

public void visit(RootNode node) {
  for (ReferenceNode refNode : node.getReferences()) {
    visitChildren(refNode);
    references.put(normalize(printer.getString()), refNode);
    printer.clear();
  }
  for (AbbreviationNode abbrNode : node.getAbbreviations()) {
    visitChildren(abbrNode);
    String abbr = printer.getString();
    printer.clear();
    abbrNode.getExpansion().accept(this);
    String expansion = printer.getString();
    abbreviations.put(abbr, expansion);
    printer.clear();
  }
  visitChildren(node);
}

代码示例来源:origin: org.pegdown/pegdown

public Rule TableRow() {
  Var<Boolean> leadingPipe = new Var<Boolean>(Boolean.FALSE);
  return NodeSequence(
      push(new TableRowNode()),
      Optional('|', leadingPipe.set(Boolean.TRUE)),
      OneOrMore(TableCell(), addAsChild()),
      leadingPipe.get() || ((Node) peek()).getChildren().size() > 1 ||
          getContext().getInputBuffer().charAt(matchEnd() - 1) == '|',
      Sp(), Newline()
  );
}

代码示例来源:origin: bodiam/markdown-to-asciidoc

protected void visitChildren(AbstractNode node) {
  for (Node child : node.getChildren()) {
    child.accept(this);
  }
}

代码示例来源:origin: org.pegdown/pegdown

public void visit(ListItemNode node) {
  if (node instanceof TaskListNode) {
    // vsch: #185 handle GitHub style task list items, these are a bit messy because the <input> checkbox needs to be
    // included inside the optional <p></p> first grand-child of the list item, first child is always RootNode
    // because the list item text is recursively parsed.
    Node firstChild = node.getChildren().get(0).getChildren().get(0);
    boolean firstIsPara = firstChild instanceof ParaNode;
    int indent = node.getChildren().size() > 1 ? 2 : 0;
    boolean startWasNewLine = printer.endsWithNewLine();
    printer.println().print("<li class=\"task-list-item\">").indent(indent);
    if (firstIsPara) {
      printer.println().print("<p>");
      printer.print("<input type=\"checkbox\" class=\"task-list-item-checkbox\"" + (((TaskListNode) node).isDone() ? " checked=\"checked\"" : "") + " disabled=\"disabled\"></input>");
      visitChildren((SuperNode) firstChild);
      // render the other children, the p tag is taken care of here
      visitChildrenSkipFirst(node);
      printer.print("</p>");
    } else {
      printer.print("<input type=\"checkbox\" class=\"task-list-item-checkbox\"" + (((TaskListNode) node).isDone() ? " checked=\"checked\"" : "") + " disabled=\"disabled\"></input>");
      visitChildren(node);
    }
    printer.indent(-indent).printchkln(indent != 0).print("</li>")
        .printchkln(startWasNewLine);
  } else {
    printConditionallyIndentedTag(node, "li");
  }
}

代码示例来源:origin: redpen-cc/redpen

protected void visitChildren(SuperNode node) {
  for (Node child : node.getChildren()) {
    child.accept(this);
  }
}

相关文章

微信公众号

最新文章

更多