Search in sources :

Example 1 with Text

use of com.vladsch.flexmark.ast.Text in project flexmark-java by vsch.

the class Delimiter method convertDelimitersToText.

public void convertDelimitersToText(int delimitersUsed, Delimiter closer) {
    Text openerText = new Text();
    openerText.setChars(getTailChars(delimitersUsed));
    Text closerText = new Text();
    closerText.setChars(closer.getLeadChars(delimitersUsed));
    getNode().insertAfter(openerText);
    closer.getNode().insertBefore(closerText);
}
Also used : Text(com.vladsch.flexmark.ast.Text)

Example 2 with Text

use of com.vladsch.flexmark.ast.Text in project flexmark-java by vsch.

the class TextNodeConverter method mergeList.

private void mergeList() {
    if (!remainingChars.isEmpty()) {
        list.add(new Text(remainingChars));
        remainingChars = BasedSequence.NULL;
    }
}
Also used : Text(com.vladsch.flexmark.ast.Text)

Example 3 with Text

use of com.vladsch.flexmark.ast.Text in project flexmark-java by vsch.

the class TextNodeConverter method appendChild.

public void appendChild(Node child) {
    BasedSequence childChars = child.getChars();
    assert nodeChars.containsAllOf(childChars) : "child " + child.toAstString(false) + " is not within parent sequence " + Node.toSegmentSpan(nodeChars, null);
    assert remainingChars.containsAllOf(childChars) : "child " + child.toAstString(false) + " is not within remaining sequence " + Node.toSegmentSpan(remainingChars, null);
    child.unlink();
    if (!(child instanceof Text)) {
        if (remainingChars.getStartOffset() < childChars.getStartOffset()) {
            // add preceding chars as Text
            list.add(new Text(remainingChars.subSequence(0, childChars.getStartOffset() - remainingChars.getStartOffset())));
        }
        // punch out remaining node chars
        remainingChars = remainingChars.subSequence(childChars.getEndOffset() - remainingChars.getStartOffset());
        list.add(child);
    }
}
Also used : BasedSequence(com.vladsch.flexmark.util.sequence.BasedSequence) Text(com.vladsch.flexmark.ast.Text)

Example 4 with Text

use of com.vladsch.flexmark.ast.Text in project jspwiki by apache.

the class LocalFootnoteRefLinkNodePostProcessorState method process.

/**
 * {@inheritDoc}
 *
 * @see NodePostProcessorState#process(NodeTracker, JSPWikiLink)
 */
@Override
public void process(final NodeTracker state, final JSPWikiLink link) {
    link.setUrl(CharSubSequence.of(wikiContext.getURL(WikiContext.VIEW, link.getUrl().toString())));
    final Text opBracket = new Text(CharSubSequence.of("["));
    final Text clBracket = new Text(CharSubSequence.of("]"));
    link.prependChild(opBracket);
    link.appendChild(clBracket);
    state.nodeAdded(opBracket);
    state.nodeAdded(clBracket);
}
Also used : Text(com.vladsch.flexmark.ast.Text)

Example 5 with Text

use of com.vladsch.flexmark.ast.Text in project flexmark-java by vsch.

the class YouTubeLinkNodePostProcessor method process.

@Override
public void process(NodeTracker state, Node node) {
    if (node instanceof Link) {
        Node previous = node.getPrevious();
        if (previous instanceof Text) {
            final BasedSequence chars = previous.getChars();
            if (chars.endsWith("@") && chars.isContinuedBy(node.getChars())) {
                // trim previous chars to remove '@'
                previous.setChars(chars.subSequence(0, chars.length() - 1));
                YouTubeLink youTubeLink = new YouTubeLink((Link) node);
                youTubeLink.takeChildren(node);
                node.unlink();
                previous.insertAfter(youTubeLink);
                state.nodeRemoved(node);
                state.nodeAddedWithChildren(youTubeLink);
            }
        }
    }
}
Also used : YouTubeLink(com.vladsch.flexmark.ext.youtube.embedded.YouTubeLink) Node(com.vladsch.flexmark.ast.Node) BasedSequence(com.vladsch.flexmark.util.sequence.BasedSequence) Text(com.vladsch.flexmark.ast.Text) Link(com.vladsch.flexmark.ast.Link) YouTubeLink(com.vladsch.flexmark.ext.youtube.embedded.YouTubeLink)

Aggregations

Text (com.vladsch.flexmark.ast.Text)8 Node (com.vladsch.flexmark.ast.Node)3 BasedSequence (com.vladsch.flexmark.util.sequence.BasedSequence)2 Link (com.vladsch.flexmark.ast.Link)1 AttributesNode (com.vladsch.flexmark.ext.attributes.AttributesNode)1 EnumeratedReferenceText (com.vladsch.flexmark.ext.enumerated.reference.EnumeratedReferenceText)1 YouTubeLink (com.vladsch.flexmark.ext.youtube.embedded.YouTubeLink)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 Relationship (org.docx4j.relationships.Relationship)1 org.docx4j.wml (org.docx4j.wml)1