
org.commonmark.ext.gfm.strikethrough.internal.StrikethroughNodeRenderer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commonmark-ext-gfm-strikethrough Show documentation
Show all versions of commonmark-ext-gfm-strikethrough Show documentation
commonmark-java extension for GFM strikethrough using ~~ (GitHub Flavored Markdown)
package org.commonmark.ext.gfm.strikethrough.internal;
import org.commonmark.ext.gfm.strikethrough.Strikethrough;
import org.commonmark.html.HtmlWriter;
import org.commonmark.html.renderer.NodeRenderer;
import org.commonmark.html.renderer.NodeRendererContext;
import org.commonmark.node.Node;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
public class StrikethroughNodeRenderer implements NodeRenderer {
private final NodeRendererContext context;
private final HtmlWriter html;
public StrikethroughNodeRenderer(NodeRendererContext context) {
this.context = context;
this.html = context.getHtmlWriter();
}
@Override
public Set> getNodeTypes() {
return Collections.>singleton(Strikethrough.class);
}
@Override
public void render(Node node) {
Map attributes = context.extendAttributes(node, Collections.emptyMap());
html.tag("del", attributes);
renderChildren(node);
html.tag("/del");
}
private void renderChildren(Node parent) {
Node node = parent.getFirstChild();
while (node != null) {
Node next = node.getNext();
context.render(node);
node = next;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy