org.commonmark.ext.gfm.tables.internal.TableNodeRenderer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commonmark-ext-gfm-tables Show documentation
Show all versions of commonmark-ext-gfm-tables Show documentation
commonmark-java extension for GFM tables using "|" pipes (GitHub Flavored Markdown)
package org.commonmark.ext.gfm.tables.internal;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.commonmark.ext.gfm.tables.TableBlock;
import org.commonmark.ext.gfm.tables.TableBody;
import org.commonmark.ext.gfm.tables.TableCell;
import org.commonmark.ext.gfm.tables.TableHead;
import org.commonmark.ext.gfm.tables.TableRow;
import org.commonmark.node.Node;
import org.commonmark.renderer.NodeRenderer;
abstract class TableNodeRenderer implements NodeRenderer {
@Override
public Set> getNodeTypes() {
return new HashSet<>(Arrays.asList(
TableBlock.class,
TableHead.class,
TableBody.class,
TableRow.class,
TableCell.class
));
}
@Override
public void render(Node node) {
if (node instanceof TableBlock) {
renderBlock((TableBlock) node);
} else if (node instanceof TableHead) {
renderHead((TableHead) node);
} else if (node instanceof TableBody) {
renderBody((TableBody) node);
} else if (node instanceof TableRow) {
renderRow((TableRow) node);
} else if (node instanceof TableCell) {
renderCell((TableCell) node);
}
}
protected abstract void renderBlock(TableBlock node);
protected abstract void renderHead(TableHead node);
protected abstract void renderBody(TableBody node);
protected abstract void renderRow(TableRow node);
protected abstract void renderCell(TableCell node);
}