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); } } }
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; }
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; }
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; }
int col = 0; int offset = node.getStartIndex();
int col = 0; int offset = node.getStartIndex();
int col = 0; int offset = node.getStartIndex();