本文整理汇总了Java中org.commonmark.renderer.NodeRenderer类的典型用法代码示例。如果您正苦于以下问题:Java NodeRenderer类的具体用法?Java NodeRenderer怎么用?Java NodeRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeRenderer类属于org.commonmark.renderer包,在下文中一共展示了NodeRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HtmlRenderer
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
private HtmlRenderer(Builder builder) {
this.softbreak = builder.softbreak;
this.escapeHtml = builder.escapeHtml;
this.percentEncodeUrls = builder.percentEncodeUrls;
this.attributeProviderFactories = new ArrayList<>(builder.attributeProviderFactories);
this.nodeRendererFactories = new ArrayList<>(builder.nodeRendererFactories.size() + 1);
this.nodeRendererFactories.addAll(builder.nodeRendererFactories);
// Add as last. This means clients can override the rendering of core nodes if they want.
this.nodeRendererFactories.add(new HtmlNodeRendererFactory() {
@Override
public NodeRenderer create(HtmlNodeRendererContext context) {
return new CoreHtmlNodeRenderer(context);
}
});
}
示例2: overrideNodeRender
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
@Test
public void overrideNodeRender() {
HtmlNodeRendererFactory nodeRendererFactory = new HtmlNodeRendererFactory() {
@Override
public NodeRenderer create(final HtmlNodeRendererContext context) {
return new NodeRenderer() {
@Override
public Set<Class<? extends Node>> getNodeTypes() {
return Collections.<Class<? extends Node>>singleton(Link.class);
}
@Override
public void render(Node node) {
context.getWriter().text("test");
}
};
}
};
HtmlRenderer renderer = HtmlRenderer.builder().nodeRendererFactory(nodeRendererFactory).build();
String rendered = renderer.render(parse("foo [bar](/url)"));
assertEquals("<p>foo test</p>\n", rendered);
}
示例3: extend
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
@Override
public void extend(HtmlRenderer.Builder rendererBuilder) {
rendererBuilder.nodeRendererFactory(new HtmlNodeRendererFactory() {
@Override
public NodeRenderer create(HtmlNodeRendererContext context) {
return new StrikethroughHtmlNodeRenderer(context);
}
});
}
示例4: extend
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
@Override
public void extend(HtmlRenderer.Builder rendererBuilder) {
rendererBuilder.nodeRendererFactory(new HtmlNodeRendererFactory() {
@Override
public NodeRenderer create(HtmlNodeRendererContext context) {
return new InsNodeRenderer(context);
}
});
}
示例5: TextContentRenderer
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
private TextContentRenderer(Builder builder) {
this.stripNewlines = builder.stripNewlines;
this.nodeRendererFactories = new ArrayList<>(builder.nodeRendererFactories.size() + 1);
this.nodeRendererFactories.addAll(builder.nodeRendererFactories);
// Add as last. This means clients can override the rendering of core nodes if they want.
this.nodeRendererFactories.add(new TextContentNodeRendererFactory() {
@Override
public NodeRenderer create(TextContentNodeRendererContext context) {
return new CoreTextContentNodeRenderer(context);
}
});
}
示例6: RendererContext
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
private RendererContext(TextContentWriter textContentWriter) {
this.textContentWriter = textContentWriter;
// The first node renderer for a node type "wins".
for (int i = nodeRendererFactories.size() - 1; i >= 0; i--) {
TextContentNodeRendererFactory nodeRendererFactory = nodeRendererFactories.get(i);
NodeRenderer nodeRenderer = nodeRendererFactory.create(this);
nodeRendererMap.add(nodeRenderer);
}
}
示例7: RendererContext
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
private RendererContext(HtmlWriter htmlWriter) {
this.htmlWriter = htmlWriter;
attributeProviders = new ArrayList<>(attributeProviderFactories.size());
for (AttributeProviderFactory attributeProviderFactory : attributeProviderFactories) {
attributeProviders.add(attributeProviderFactory.create(this));
}
// The first node renderer for a node type "wins".
for (int i = nodeRendererFactories.size() - 1; i >= 0; i--) {
HtmlNodeRendererFactory nodeRendererFactory = nodeRendererFactories.get(i);
NodeRenderer nodeRenderer = nodeRendererFactory.create(this);
nodeRendererMap.add(nodeRenderer);
}
}
示例8: customizeRendering
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
@Test
public void customizeRendering() {
Parser parser = Parser.builder().build();
HtmlRenderer renderer = HtmlRenderer.builder()
.nodeRendererFactory(new HtmlNodeRendererFactory() {
public NodeRenderer create(HtmlNodeRendererContext context) {
return new IndentedCodeBlockNodeRenderer(context);
}
})
.build();
Node document = parser.parse("Example:\n\n code");
assertEquals("<p>Example:</p>\n<pre>code\n</pre>\n", renderer.render(document));
}
示例9: extend
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
@Override
public void extend(HtmlRenderer.Builder rendererBuilder) {
rendererBuilder.nodeRendererFactory(new HtmlNodeRendererFactory() {
@Override
public NodeRenderer create(HtmlNodeRendererContext context) {
return new TableHtmlNodeRenderer(context);
}
});
}
示例10: create
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
@Override
public NodeRenderer create(HtmlNodeRendererContext context) {
// Compact paragraphs
return new DashCompactHtmlRenderer(context);
}
示例11: create
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
@Override
public NodeRenderer create(HtmlNodeRendererContext context) {
return new CompactHtmlRenderer(context);
}
示例12: create
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
@Override
public NodeRenderer create(HtmlNodeRendererContext context) {
return new BlockRenderer(
context);
}
示例13: add
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
public void add(NodeRenderer nodeRenderer) {
for (Class<? extends Node> nodeType : nodeRenderer.getNodeTypes()) {
// Overwrite existing renderer
renderers.put(nodeType, nodeRenderer);
}
}
示例14: render
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
public void render(Node node) {
NodeRenderer nodeRenderer = renderers.get(node.getClass());
if (nodeRenderer != null) {
nodeRenderer.render(node);
}
}
示例15: create
import org.commonmark.renderer.NodeRenderer; //导入依赖的package包/类
@Override
public NodeRenderer create(HtmlNodeRendererContext context) {
return new UpperCaseNodeRenderer(context);
}