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);
}
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;
}
}
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);
}
}
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);
}
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);
}
}
}
}
Aggregations