com.vladsch.flexmark.ext.emoji.internal.EmojiNodeFormatter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of flexmark-ext-emoji Show documentation
Show all versions of flexmark-ext-emoji Show documentation
flexmark-java extension for emoji shortcuts using Emoji-Cheat-Sheet.com http://www.emoji-cheat-sheet.com/
package com.vladsch.flexmark.ext.emoji.internal;
import com.vladsch.flexmark.ext.emoji.Emoji;
import com.vladsch.flexmark.formatter.*;
import com.vladsch.flexmark.util.data.DataHolder;
import java.util.HashSet;
import java.util.Set;
public class EmojiNodeFormatter implements NodeFormatter {
public EmojiNodeFormatter(DataHolder options) {
}
@Override
public Set> getNodeClasses() {
return null;
}
// only registered if assignTextAttributes is enabled
@Override
public Set> getNodeFormattingHandlers() {
HashSet> set = new HashSet>();
set.add(new NodeFormattingHandler(Emoji.class, new CustomNodeFormatter() {
@Override
public void render(Emoji node, NodeFormatterContext context, MarkdownWriter markdown) {
EmojiNodeFormatter.this.render(node, context, markdown);
}
}));
return set;
}
void render(Emoji node, NodeFormatterContext context, MarkdownWriter markdown) {
markdown.append(node.getOpeningMarker());
markdown.appendNonTranslating(node.getText());
markdown.append(node.getClosingMarker());
}
public static class Factory implements NodeFormatterFactory {
@Override
public NodeFormatter create(DataHolder options) {
return new EmojiNodeFormatter(options);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy