本文整理了Java中org.pegdown.ast.Node.getChildren()
方法的一些代码示例,展示了Node.getChildren()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getChildren()
方法的具体详情如下:
包路径:org.pegdown.ast.Node
类名称:Node
方法名:getChildren
暂无
代码示例来源: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
Node withIndicesShifted(Node node, int delta) {
if (delta != 0) {
((AbstractNode) node).shiftIndices(delta);
for (Node subNode : node.getChildren()) {
withIndicesShifted(subNode, delta);
}
}
return node;
}
代码示例来源: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
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 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: 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: org.pegdown/pegdown
public Rule DefinitionList() {
return NodeSequence(
// test for successful definition list match before actually building it to reduce backtracking
TestNot(Spacechar()),
Test(
OneOrMore(TestNot(BlankLine()), TestNot(DefListBullet()),
OneOrMore(NotNewline(), ANY), Newline()),
ZeroOrMore(BlankLine()),
DefListBullet()
),
push(new DefinitionListNode()),
OneOrMore(
push(new SuperNode()),
OneOrMore(DefListTerm(), addAsChild()),
OneOrMore(Definition(), addAsChild()),
((SuperNode)peek(1)).getChildren().addAll(popAsNode().getChildren()),
Optional(BlankLine())
)
);
}
代码示例来源:origin: org.pegdown/pegdown
public Rule BlockQuote() {
StringBuilderVar inner = new StringBuilderVar();
StringBuilderVar optional = new StringBuilderVar();
return NodeSequence(
OneOrMore(
CrossedOut(Sequence('>', Optional(' ')), inner), Line(inner),
ZeroOrMore(
TestNot('>'),
TestNot(BlankLine()),
Line(inner)
),
// ZeroOrMore(BlankLine()), inner.append(match())
Optional(Sequence(OneOrMore(BlankLine()), optional.append(match()), Test('>')), inner.append(optional.getString()) && optional.clearContents())
),
// vsch: the block quotes won't parse into Para because they will not be followed by a blank line,
// unless the last line of the block quote is an empty block-quote line: ">". We append one here to
// take care of that possibility, now that we don't include blank lines after a block quote we add one extra
inner.append("\n\n"),
// trigger a recursive parsing run on the inner source we just built
// and attach the root of the inner parses AST
push(new BlockQuoteNode(withIndicesShifted(parseInternal(inner), (Integer) peek()).getChildren()))
);
}
代码示例来源:origin: org.concordion/concordion
private int numberOfLinkNodeChildren(Node cell) {
int linkNodeCount = 0;
List<Node> children = cell.getChildren();
for (Node child : children) {
if (ExpLinkNode.class.isAssignableFrom(child.getClass()) || RefLinkNode.class.isAssignableFrom(child.getClass())) {
linkNodeCount ++;
}
}
return linkNodeCount;
}
代码示例来源:origin: concordion/concordion
private int numberOfLinkNodeChildren(Node cell) {
int linkNodeCount = 0;
List<Node> children = cell.getChildren();
for (Node child : children) {
if (ExpLinkNode.class.isAssignableFrom(child.getClass()) || RefLinkNode.class.isAssignableFrom(child.getClass())) {
linkNodeCount ++;
}
}
return linkNodeCount;
}
代码示例来源: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: org.bsc.maven/maven-confluence-core
protected <T extends Node> void visitChildren(T node) {
for (Node child : node.getChildren()) {
child.accept(this);
}
}
代码示例来源:origin: org.bsc.maven/maven-confluence-core
@SuppressWarnings("unchecked")
protected <T extends Node> void forEachChild( T node, FindPredicate<T> cb ) {
final java.util.List<Node> children = node.getChildren();
for (int index = 0 ; index < children.size() ; ++index) {
final Node child = children.get(index);
if( !cb.f( (T)child, node, index ) ) {
return ;
}
}
}
代码示例来源:origin: gradle.plugin.com.github.qwazer/markdown-confluence-gradle-plugin
protected <T extends Node> void forEachChild(T node, FindPredicate<T> cb ) {
final List<Node> children = node.getChildren();
for (int index = 0 ; index < children.size() ; ++index) {
final Node child = children.get(index);
if( !cb.f( (T)child, node, index ) ) {
return ;
}
}
}
代码示例来源:origin: org.technbolts/gutenberg
public void processChildren(int level, Node node) {
for (Node child : node.getChildren()) {
process(level + 1, child);
}
}
代码示例来源:origin: org.concordion/concordion
private boolean firstChildIsInstanceOf(Node node, Class<?> clazz) {
return node.getChildren().size() > 0 && clazz.isAssignableFrom(firstChildOf(node).getClass());
}
代码示例来源:origin: org.technbolts/gutenberg
Node xwithIndicesShifted(Node node, int delta) {
((AbstractNode) node).shiftIndices(delta);
for (Node subNode : node.getChildren()) {
xwithIndicesShifted(subNode, delta);
}
return node;
}
}
代码示例来源:origin: org.technbolts/gutenberg
public void traverse(Node node) {
if (node instanceof ReferenceNode) {
declareReference((ReferenceNode) node);
}
for (Node child : node.getChildren()) {
traverse(child);
}
}
代码示例来源:origin: org.technbolts/gutenberg
private void declareReference(ReferenceNode node) {
TextNode text = (TextNode) node.getChildren().get(0).getChildren().get(0);
String title = node.getTitle();
String url = node.getUrl();
String key = text.getText();
Ref ref = new Ref(key, url, title);
references.put(key, ref);
}
代码示例来源:origin: org.technbolts/gutenberg
public List<Element> collectChildren(int level, Node node) {
Collector<Element> collector = new Collector<Element>();
iTextContext().pushElementConsumer(collector);
for (Node child : node.getChildren()) {
process(level + 1, child);
}
iTextContext().popElementConsumer();
return collector.getCollected();
}
内容来源于网络,如有侵权,请联系作者删除!