use of com.vladsch.flexmark.ast.Node in project flexmark-java by vsch.
the class Macro method getAttributes.
public Map<String, String> getAttributes() {
final Map<String, String> attributes = new LinkedHashMap<String, String>();
Node child = getFirstChild();
while (child != null) {
if (child instanceof MacroAttribute) {
MacroAttribute attribute = (MacroAttribute) child;
attributes.put(attribute.getAttribute().toString(), attribute.getValue().toString());
}
child = child.getNext();
}
return attributes;
}
use of com.vladsch.flexmark.ast.Node in project flexmark-java by vsch.
the class Macro method getMacroContentChars.
public BasedSequence getMacroContentChars() {
Node lastChild = getLastChild();
int startOffset = getClosingMarker().getEndOffset();
int endOffset = lastChild == null || lastChild instanceof MacroAttribute ? getEndOffset() : lastChild.getStartOffset();
return isClosedTag() ? BasedSequence.NULL : getChars().baseSubSequence(startOffset, endOffset);
}
use of com.vladsch.flexmark.ast.Node in project flexmark-java by vsch.
the class MacroBlock method getMacroContentChars.
public BasedSequence getMacroContentChars() {
Node firstChild = getFirstChild();
Node lastChild = getLastChild();
Node firstContentNode = firstChild.getNext();
Node lastContentNode = lastChild instanceof MacroClose ? lastChild.getPrevious() : lastChild;
// noinspection UnnecessaryLocalVariable
BasedSequence contentChars = Node.spanningChars(firstContentNode == null || firstContentNode instanceof MacroClose ? BasedSequence.NULL : firstContentNode.getChars(), lastContentNode == null || lastContentNode == firstChild ? BasedSequence.NULL : lastContentNode.getChars());
return contentChars;
}
use of com.vladsch.flexmark.ast.Node in project flexmark-java by vsch.
the class Delimiter method moveNodesBetweenDelimitersTo.
public void moveNodesBetweenDelimitersTo(DelimitedNode delimitedNode, Delimiter closer) {
Node tmp = getNode().getNext();
while (tmp != null && tmp != closer.getNode()) {
Node next = tmp.getNext();
((Node) delimitedNode).appendChild(tmp);
tmp = next;
}
delimitedNode.setText(input.subSequence(getEndIndex(), closer.getStartIndex()));
getNode().insertAfter((Node) delimitedNode);
}
use of com.vladsch.flexmark.ast.Node in project flexmark-java by vsch.
the class TextNodeConverter method insertMergedAfter.
// insert and clear list
public void insertMergedAfter(Node sibling) {
mergeList();
for (Node node : list) {
sibling.insertAfter(node);
sibling = node;
}
clear();
}
Aggregations