本文整理汇总了Java中com.vladsch.flexmark.html.HtmlRenderer类的典型用法代码示例。如果您正苦于以下问题:Java HtmlRenderer类的具体用法?Java HtmlRenderer怎么用?Java HtmlRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HtmlRenderer类属于com.vladsch.flexmark.html包,在下文中一共展示了HtmlRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseBuildAndRender
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
private String parseBuildAndRender(String text) {
Parser parser = Parser.builder(OPTIONS)
.extensions(EXTENSIONS)
.build();
HtmlRenderer renderer = HtmlRenderer.builder(OPTIONS)
.escapeHtml(mEscapeHtml)
.attributeProviderFactory(new IndependentAttributeProviderFactory() {
@Override
public AttributeProvider create(NodeRendererContext context) {
return new CustomAttributeProvider();
}
})
.nodeRendererFactory(new NodeRendererFactoryImpl())
.extensions(EXTENSIONS)
.build();
return renderer.render(parser.parse(text));
}
示例2: save
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
@Override
public JSONObject save(DocModel doc, boolean markdown) {
DocModel model = validator.isEmpty(doc.getId()) ? new DocModel() : findById(doc.getId());
model.setKey(doc.getKey());
model.setOwner(validator.isEmpty(doc.getOwner()) ? "" : doc.getOwner());
model.setAuthor(userHelper.id());
model.setScoreMin(doc.getScoreMin());
model.setScoreMax(doc.getScoreMax());
model.setSort(doc.getSort());
model.setSubject(doc.getSubject());
model.setImage(doc.getImage());
model.setThumbnail(doc.getThumbnail());
model.setSummary(doc.getSummary());
model.setLabel(doc.getLabel());
model.setSource(doc.getSource());
model.setContent(markdown ? HtmlRenderer.builder().build().render(Parser.builder().build().parse(doc.getSource())).trim() : doc.getSource());
model.setTime(dateTime.now());
model.setAudit(defaultAudit);
docDao.save(model);
clearCache(model.getId());
return toJson(model);
}
示例3: MarkdownCompiler
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
@Inject
public MarkdownCompiler(Set<Extension> extensionSet, Set<MutableDataSet> injectedOptions) {
super(900);
MutableDataSet options = new MutableDataSet();
options.set(HtmlRenderer.GENERATE_HEADER_ID, true);
options.set(HtmlRenderer.RENDER_HEADER_ID, true);
options.set(Parser.EXTENSIONS, extensionSet);
for(MutableDataSet injectedOption : injectedOptions) {
options.setAll(injectedOption);
}
parser = Parser.builder(options).build();
renderer = HtmlRenderer.builder(options).build();
}
示例4: toHtml
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
private String toHtml(boolean source) {
Node astRoot = toAstRoot();
if (astRoot == null)
return "";
HtmlRenderer.Builder builder = HtmlRenderer.builder()
.extensions(MarkdownExtensions.getFlexmarkExtensions());
if (!source)
builder.attributeProviderFactory(new MyAttributeProvider.Factory());
String html = builder.build().render(astRoot);
for (PreviewRendererAddon addon : addons)
html = addon.postRender(html, path);
return html;
}
示例5: getHTMLRenderer
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
private static synchronized HtmlRenderer getHTMLRenderer( String rootUrl, boolean hardwrapsEnabled ){
if(!currentRootUrl.equals(rootUrl) && rootUrl != null ) {
currentRootUrl = rootUrl;
RENDERER_HW = null;
RENDERER_NOHW = null;
String linkPrefix = rootUrl + "/";
optionsHardWraps.set(WikiLinkExtension.LINK_PREFIX, linkPrefix);
optionsNoHardWraps.set(WikiLinkExtension.LINK_PREFIX, linkPrefix);
}
if(hardwrapsEnabled){
if(RENDERER_HW == null){
RENDERER_HW = HtmlRenderer.builder( optionsHardWraps ).build();
}
return RENDERER_HW;
} else {
if(RENDERER_NOHW == null){
RENDERER_NOHW = HtmlRenderer.builder( optionsNoHardWraps ).build();
}
return RENDERER_NOHW;
}
}
示例6: extend
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
@Override
public void extend(HtmlRenderer.Builder rendererBuilder, String rendererType) {
switch (rendererType) {
case "HTML":
rendererBuilder.nodeRendererFactory(new LocalizationNodeRenderer.Factory());
break;
}
}
示例7: extend
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
@Override
public void extend(HtmlRenderer.Builder rendererBuilder, String rendererType) {
switch (rendererType) {
case "HTML":
rendererBuilder.nodeRendererFactory(new KeystrokeNodeRenderer.Factory());
break;
}
}
示例8: extend
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
@Override
public void extend(HtmlRenderer.Builder rendererBuilder, String rendererType) {
switch (rendererType) {
case "HTML":
rendererBuilder.nodeRendererFactory(new NodeRendererFactory() {
@Override
public NodeRenderer create(DataHolder options) {
return new MarkNodeRenderer(options);
}
});
break;
}
}
示例9: extend
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
@Override
public void extend(HtmlRenderer.Builder rendererBuilder, String rendererType) {
switch (rendererType) {
case "HTML":
rendererBuilder.nodeRendererFactory(new NodeRendererFactory() {
@Override
public NodeRenderer create(DataHolder options) {
return new MathJaxNodeRenderer(options);
}
});
break;
}
}
示例10: extend
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
@Override
public void extend(HtmlRenderer.Builder rendererBuilder, String rendererType) {
switch (rendererType) {
case "HTML":
rendererBuilder.nodeRendererFactory(new LabelNodeRenderer.Factory());
break;
}
}
示例11: render
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
@Override
public String render(String markdown, @Nullable String baseUrl, boolean postProcess) {
Preconditions.checkArgument(baseUrl == null || baseUrl.startsWith("/"));
List<Extension> extensions = new ArrayList<>();
extensions.add(AnchorLinkExtension.create());
extensions.add(TablesExtension.create());
extensions.add(TaskListExtension.create());
extensions.add(DefinitionExtension.create());
extensions.add(TocExtension.create());
extensions.add(AutolinkExtension.create());
extensions.add(new UrlResolveExtension());
extensions.addAll(contributedExtensions);
MutableDataHolder options = new MutableDataSet()
.set(HtmlRenderer.GENERATE_HEADER_ID, true)
.set(AnchorLinkExtension.ANCHORLINKS_SET_NAME, true)
.set(AnchorLinkExtension.ANCHORLINKS_ANCHOR_CLASS, "header-anchor")
.set(AnchorLinkExtension.ANCHORLINKS_TEXT_SUFFIX, "<i class='fa fa-link'></i>")
.set(Parser.SPACE_IN_LINK_URLS, true)
.setFrom(ParserEmulationProfile.GITHUB_DOC)
.set(TablesExtension.COLUMN_SPANS, false)
.set(TablesExtension.APPEND_MISSING_COLUMNS, true)
.set(TablesExtension.DISCARD_EXTRA_COLUMNS, true)
.set(TablesExtension.HEADER_SEPARATOR_COLUMN_MATCH, true)
.set(UrlResolveExtension.BASE_URL, baseUrl)
.set(Parser.EXTENSIONS, extensions);
Parser parser = Parser.builder(options).build();
HtmlRenderer htmlRenderer = HtmlRenderer.builder(options).build();
Node document = parser.parse(markdown);
String html = htmlRenderer.render(document);
if (postProcess)
html = postProcess(html);
return html;
}
示例12: Markdown2Html
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
public Markdown2Html() {
MutableDataSet options = new MutableDataSet();
// uncomment to set optional extensions
//options.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create(), StrikethroughExtension.create()));
// uncomment to convert soft-breaks to hard breaks
//options.set(HtmlRenderer.SOFT_BREAK, "<br />\n");
// options.set(HtmlRenderer.SOFT_BREAK, "<br />\n");
options.set(HtmlRenderer.ESCAPE_HTML_BLOCKS, true);
this.parser = Parser.builder(options).build();
}
示例13: MarkdownAssetsServlet
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
/**
* Construct a {@link MarkdownAssetsServlet} configured with provided parameters, having a wrapped default
* {@link AssetServlet} for fulfilling non-markdown asset requests.
* <p>
* {@code MarkdownAssetsServlet} and {@link AssetServlet} serve static assets loaded from {@code resourceURL}
* (typically a file: or jar: URL). The assets are served at URIs rooted at {@code uriPath}. For
* example, given a {@code resourceURL} of {@code "file:/data/assets"} and a {@code uriPath} of
* {@code "/js"}, an {@code AssetServlet} would serve the contents of {@code
* /data/assets/example.js} in response to a request for {@code /js/example.js}. If a directory
* is requested and {@code indexFile} is defined, then {@code AssetServlet} will attempt to
* serve a file with that name in that directory.
* @param resourcePath the base URL from which assets are loaded
* @param uriPath the URI path fragment in which all requests are rooted
* @param indexFile the filename to use when directories are requested
* @param defaultCharset the default character set
* @param configuration environment-specific configuration properties
* @param extensions Flexmark-Java markdown rendering extensions to use
* @param options Flexmark-Java markdown rendering options
* @param cacheBuilderSpec {@link CacheBuilderSpec} for rendered pages
*/
public MarkdownAssetsServlet(@NotNull String resourcePath,
@NotNull String uriPath,
@NotNull String indexFile,
@NotNull Charset defaultCharset,
@NotNull MarkdownAssetsConfiguration configuration,
@NotNull List<Extension> extensions,
@NotNull DataHolder options,
@NotNull CacheBuilderSpec cacheBuilderSpec) {
this.resourcePath = resourcePath;
this.uriPath = uriPath;
this.indexFile = indexFile;
this.defaultCharset = defaultCharset;
this.configuration = configuration;
parser = Parser.builder(options).extensions(extensions).build();
renderer = HtmlRenderer.builder(options).extensions(extensions).build();
assetServlet = new AssetServlet(resourcePath, uriPath, indexFile, defaultCharset);
pageCache = CacheBuilder.from(cacheBuilderSpec)
.build(new CacheLoader<URL, CachedPage>() {
@Override
public CachedPage load(@NotNull URL key) throws Exception {
return renderPage(key);
}
});
try {
URL resource = this.getClass().getResource(resourcePath);
Preconditions.checkNotNull(resource, "Resource root URL (" + resourcePath + ") was not found");
resourceRootURL = resource.toURI();
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Resource root URL (" + resourcePath + ") was ind", e);
}
}
示例14: parseBuildAndRender
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
private String parseBuildAndRender(String text) {
Parser parser = Parser.builder(OPTIONS).extensions(EXTENSIONS).build();
HtmlRenderer renderer = HtmlRenderer.builder(OPTIONS).escapeHtml(mEscapeHtml)
.attributeProviderFactory(new IndependentAttributeProviderFactory() {
public AttributeProvider create(NodeRendererContext context) {
return new CustomAttributeProvider();
}
}).nodeRendererFactory(
new MarkdownView.NodeRendererFactoryImpl())
.extensions(EXTENSIONS).build();
return renderer.render(parser.parse(text));
}
示例15: wikiFormat
import com.vladsch.flexmark.html.HtmlRenderer; //导入依赖的package包/类
public static String wikiFormat(String text, boolean useHardWraps, String rootUrl){
try {
Node document = MARKDOWN_PARSER.parse( text );
HtmlRenderer renderer = getHTMLRenderer(rootUrl, useHardWraps);
return renderer.render(document);
// + "<!--end-->"; //This forces an unclosed HTML-comment in the rendered output to be closed. This fixes the issue where commonmark may escape a closing `-->` when a blank line exists in the HTML comment.
// return processor.markdownToHtml( processVerbatim(text), getLinkRenderer( rootUrl ) );
} catch (Exception e) {
Logger.error(e);
return errorMessage(text);
}
}