Search in sources :

Example 76 with Node

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;
}
Also used : Node(com.vladsch.flexmark.ast.Node) CustomNode(com.vladsch.flexmark.ast.CustomNode) LinkedHashMap(java.util.LinkedHashMap)

Example 77 with Node

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);
}
Also used : Node(com.vladsch.flexmark.ast.Node) CustomNode(com.vladsch.flexmark.ast.CustomNode)

Example 78 with Node

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;
}
Also used : Node(com.vladsch.flexmark.ast.Node) BasedSequence(com.vladsch.flexmark.util.sequence.BasedSequence)

Example 79 with Node

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);
}
Also used : Node(com.vladsch.flexmark.ast.Node) DelimitedNode(com.vladsch.flexmark.ast.DelimitedNode)

Example 80 with Node

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();
}
Also used : Node(com.vladsch.flexmark.ast.Node)

Aggregations

Node (com.vladsch.flexmark.ast.Node)87 Parser (com.vladsch.flexmark.parser.Parser)29 HtmlRenderer (com.vladsch.flexmark.html.HtmlRenderer)21 Test (org.junit.Test)19 MutableDataSet (com.vladsch.flexmark.util.options.MutableDataSet)14 DataHolder (com.vladsch.flexmark.util.options.DataHolder)11 List (java.util.List)8 BasedSequence (com.vladsch.flexmark.util.sequence.BasedSequence)6 MutableDataHolder (com.vladsch.flexmark.util.options.MutableDataHolder)5 Text (com.vladsch.flexmark.ast.Text)3 TextCollectingVisitor (com.vladsch.flexmark.ast.util.TextCollectingVisitor)3 Extension (com.vladsch.flexmark.Extension)2 Block (com.vladsch.flexmark.ast.Block)2 CustomNode (com.vladsch.flexmark.ast.CustomNode)2 Document (com.vladsch.flexmark.ast.Document)2 Heading (com.vladsch.flexmark.ast.Heading)2 DocxRenderer (com.vladsch.flexmark.docx.converter.internal.DocxRenderer)2 MacroClose (com.vladsch.flexmark.ext.xwiki.macros.MacroClose)2 AstCollectingVisitor (com.vladsch.flexmark.test.AstCollectingVisitor)2 Attributes (com.vladsch.flexmark.util.html.Attributes)2