Java Code Examples for org.commonmark.node.Text#insertAfter()

The following examples show how to use org.commonmark.node.Text#insertAfter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmphasisDelimiterProcessor.java    From 1Rramp-Android with MIT License 6 votes vote down vote up
@Override
public void process(Text opener, Text closer, int delimiterUse) {
    String singleDelimiter = String.valueOf(getOpeningCharacter());
    Node emphasis = delimiterUse == 1
            ? new Emphasis(singleDelimiter)
            : new StrongEmphasis(singleDelimiter + singleDelimiter);

    Node tmp = opener.getNext();
    while (tmp != null && tmp != closer) {
        Node next = tmp.getNext();
        emphasis.appendChild(tmp);
        tmp = next;
    }

    opener.insertAfter(emphasis);
}
 
Example 2
Source File: SimpleExtDelimiterProcessor.java    From Markwon with Apache License 2.0 6 votes vote down vote up
@Override
public void process(Text opener, Text closer, int delimiterUse) {

    final Node node = new SimpleExtNode(spanFactory);

    Node tmp = opener.getNext();
    Node next;

    while (tmp != null && tmp != closer) {
        next = tmp.getNext();
        node.appendChild(tmp);
        tmp = next;
    }

    opener.insertAfter(node);
}
 
Example 3
Source File: EmphasisDelimiterProcessor.java    From commonmark-java with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void process(Text opener, Text closer, int delimiterUse) {
    String singleDelimiter = String.valueOf(getOpeningCharacter());
    Node emphasis = delimiterUse == 1
            ? new Emphasis(singleDelimiter)
            : new StrongEmphasis(singleDelimiter + singleDelimiter);

    Node tmp = opener.getNext();
    while (tmp != null && tmp != closer) {
        Node next = tmp.getNext();
        emphasis.appendChild(tmp);
        tmp = next;
    }

    opener.insertAfter(emphasis);
}
 
Example 4
Source File: EmojiDelimiterProcessor.java    From mvvm-template with GNU General Public License v3.0 5 votes vote down vote up
@Override public void process(Text opener, Text closer, int delimiterCount) {
    Node emoji = new Emoji();
    Node tmp = opener.getNext();
    while (tmp != null && tmp != closer) {
        Node next = tmp.getNext();
        emoji.appendChild(tmp);
        tmp = next;
    }
    opener.insertAfter(emoji);
}
 
Example 5
Source File: MentionDelimiterProcessor.java    From mvvm-template with GNU General Public License v3.0 5 votes vote down vote up
@Override public void process(Text opener, Text closer, int delimiterCount) {
    Node mention = new Mention();
    Node tmp = opener.getNext();
    while (tmp != null && tmp != closer) {
        Node next = tmp.getNext();
        mention.appendChild(tmp);
        tmp = next;
    }
    opener.insertAfter(mention);
}
 
Example 6
Source File: StrikethroughDelimiterProcessor.java    From commonmark-java with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void process(Text opener, Text closer, int delimiterCount) {
    // Wrap nodes between delimiters in strikethrough.
    Node strikethrough = new Strikethrough();

    Node tmp = opener.getNext();
    while (tmp != null && tmp != closer) {
        Node next = tmp.getNext();
        strikethrough.appendChild(tmp);
        tmp = next;
    }

    opener.insertAfter(strikethrough);
}
 
Example 7
Source File: InsDelimiterProcessor.java    From commonmark-java with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void process(Text opener, Text closer, int delimiterCount) {
    // Wrap nodes between delimiters in ins.
    Node ins = new Ins();

    Node tmp = opener.getNext();
    while (tmp != null && tmp != closer) {
        Node next = tmp.getNext();
        ins.appendChild(tmp);
        tmp = next;
    }

    opener.insertAfter(ins);
}
 
Example 8
Source File: DelimiterProcessorTest.java    From commonmark-java with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void process(Text opener, Text closer, int delimiterUse) {
    UpperCaseNode content = new UpperCaseNode();
    Node tmp = opener.getNext();
    while (tmp != null && tmp != closer) {
        Node next = tmp.getNext();
        content.appendChild(tmp);
        tmp = next;
    }
    opener.insertAfter(content);
}
 
Example 9
Source File: DelimiterProcessorTest.java    From commonmark-java with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void process(Text opener, Text closer, int delimiterUse) {
    opener.insertAfter(new Text("(1)"));
    closer.insertBefore(new Text("(/1)"));
}
 
Example 10
Source File: DelimiterProcessorTest.java    From commonmark-java with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void process(Text opener, Text closer, int delimiterUse) {
    opener.insertAfter(new Text("(2)"));
    closer.insertBefore(new Text("(/2)"));
}