use of com.vladsch.flexmark.ext.youtube.embedded.YouTubeLink 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