org.commonmark.ext.ins.InsExtension Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commonmark-ext-ins Show documentation
Show all versions of commonmark-ext-ins Show documentation
commonmark-java extension for <ins> using ++
package org.commonmark.ext.ins;
import org.commonmark.Extension;
import org.commonmark.ext.ins.internal.InsDelimiterProcessor;
import org.commonmark.ext.ins.internal.InsNodeRenderer;
import org.commonmark.renderer.html.HtmlNodeRendererContext;
import org.commonmark.renderer.html.HtmlNodeRendererFactory;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;
import org.commonmark.renderer.NodeRenderer;
/**
* Extension for ins using ++
*
* Create it with {@link #create()} and then configure it on the builders
* ({@link org.commonmark.parser.Parser.Builder#extensions(Iterable)},
* {@link HtmlRenderer.Builder#extensions(Iterable)}).
*
*
* The parsed ins text regions are turned into {@link Ins} nodes.
*
*/
public class InsExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension {
private InsExtension() {
}
public static Extension create() {
return new InsExtension();
}
@Override
public void extend(Parser.Builder parserBuilder) {
parserBuilder.customDelimiterProcessor(new InsDelimiterProcessor());
}
@Override
public void extend(HtmlRenderer.Builder rendererBuilder) {
rendererBuilder.nodeRendererFactory(new HtmlNodeRendererFactory() {
@Override
public NodeRenderer create(HtmlNodeRendererContext context) {
return new InsNodeRenderer(context);
}
});
}
}