本文整理汇总了Java中org.pegdown.ToHtmlSerializer类的典型用法代码示例。如果您正苦于以下问题:Java ToHtmlSerializer类的具体用法?Java ToHtmlSerializer怎么用?Java ToHtmlSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ToHtmlSerializer类属于org.pegdown包,在下文中一共展示了ToHtmlSerializer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: markdownToHtml
import org.pegdown.ToHtmlSerializer; //导入依赖的package包/类
protected String markdownToHtml(boolean modified, RootNode rootNode) {
if (rootNode == null) {
return "<strong>Parser timed out</strong>";
} else {
if (modified) {
MultiMarkdownToHtmlSerializer htmlSerializer = new MultiMarkdownToHtmlSerializer(project, document, linkRendererModified);
if (!isWikiDocument) {
htmlSerializer.setFlag(MultiMarkdownToHtmlSerializer.NO_WIKI_LINKS);
}
return htmlSerializer.toHtml(rootNode);
} else {
return new ToHtmlSerializer(linkRendererNormal).toHtml(rootNode).replace("<br/>", "<br/>\n");
}
}
}
示例2: markdownToHtml
import org.pegdown.ToHtmlSerializer; //导入依赖的package包/类
protected String markdownToHtml(boolean modified, RootNode rootNode) {
if (rootNode == null) {
return "<strong>Parser timed out</strong>";
} else {
if (modified) {
MultiMarkdownToHtmlSerializer htmlSerializer = new MultiMarkdownToHtmlSerializer(project, document, linkRendererModified);
if (!isWikiDocument) {
htmlSerializer.setFlag(MultiMarkdownToHtmlSerializer.NO_WIKI_LINKS);
}
return htmlSerializer.toHtml(rootNode).replace("<br/>", "<br/>\n");
} else {
return new ToHtmlSerializer(linkRendererNormal).toHtml(rootNode).replace("<br/>", "<br/>\n");
}
}
}
示例3: markdownToDocHtml
import org.pegdown.ToHtmlSerializer; //导入依赖的package包/类
public byte[] markdownToDocHtml(String md, String charEnc) throws UnsupportedEncodingException {
RootNode root = parseMarkdown(md);
String title = findTitle(root);
StringBuilder html = new StringBuilder();
html.append("<html>");
html.append("<head>");
if (!Strings.isNullOrEmpty(title)) {
html.append("<title>").append(title).append("</title>");
}
html.append("<style type=\"text/css\">\n");
if (css != null) {
html.append(css);
} else {
html.append(readCSS());
}
html.append("\n</style>");
html.append("</head>");
html.append("<body>\n");
html.append(new ToHtmlSerializer(new LinkRenderer()).toHtml(root));
html.append("\n</body></html>");
return html.toString().getBytes(charEnc);
}
示例4: formatHtml
import org.pegdown.ToHtmlSerializer; //导入依赖的package包/类
private String formatHtml(String text) {
if (BricABrac.isBlank(text)) {
return "";
}
PegDownProcessor markdownProcessor = configuration.getMarkdownProcessor();
RootNode astRoot = markdownProcessor.parseMarkdown(text.toCharArray());
//astRoot.accept(Visitors.dump());
List<ToHtmlSerializerPlugin> htmlPlugins = configuration.htmlSerializerPlugins();
ToHtmlSerializer htmlSerializer = new ToHtmlSerializer(new LinkRenderer(), htmlPlugins);
return htmlSerializer.toHtml(astRoot);
}
示例5: toHtml
import org.pegdown.ToHtmlSerializer; //导入依赖的package包/类
public String toHtml() {
return new ToHtmlSerializer(new MarkdownLinkRenderer()).toHtml(rootNode);
}
示例6: exec
import org.pegdown.ToHtmlSerializer; //导入依赖的package包/类
@Override
public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException
{
if (arguments.size() != 1)
{
throw new TemplateModelException("Error, method expects one argument (String)");
}
SimpleScalar freemarkerArg = (SimpleScalar) arguments.get(0);
String markdownSource = freemarkerArg.getAsString();
SoftReference<String> cachedResult = cache.get(markdownSource);
String cachedResultString;
if (cachedResult != null && (cachedResultString = cachedResult.get()) != null)
{
return cachedResultString;
}
try
{
// build the plugins object with our extensions
PegDownPlugins plugins = PegDownPlugins.builder().build();
PegDownProcessor processor = new PegDownProcessor(Extensions.FENCED_CODE_BLOCKS, MAX_PARSING_TIME_MILLIS, plugins);
// build the node and then serialize it so that we can make sure the serializer uses our plugins
RootNode outputNode = processor.parseMarkdown(markdownSource.toCharArray());
// Our plugin is also a serializer, so build a plugins list for serialization as well
List<ToHtmlSerializerPlugin> serializerPlugins = new ArrayList<>(1);
ToHtmlSerializer serializer = new ToHtmlSerializerExtended(new LinkRenderer(), Collections.<String, VerbatimSerializer> emptyMap(),
serializerPlugins);
String result = serializer.toHtml(outputNode);
cache.put(markdownSource, new SoftReference<>(result));
return result;
}
catch (Throwable t)
{
LOG.log(Level.WARNING, "Failed to parse markdown due to: " + t.getMessage() + " markdown source: " + markdownSource, t);
// Return the unformatted markdown, as this is better than failing the report completely.
return markdownSource;
}
}
示例7: createDocletSerializer
import org.pegdown.ToHtmlSerializer; //导入依赖的package包/类
/**
* Create a new serializer. If you need to further customize the HTML rendering, you
* can override this method.
*
* @return A (possibly customised) ToHtmlSerializer.
*/
protected ToHtmlSerializer createDocletSerializer() {
return new DocletSerializer(this, getLinkRenderer());
}