当前位置: 首页>>代码示例>>Java>>正文


Java ToHtmlSerializer类代码示例

本文整理汇总了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");
        }
    }
}
 
开发者ID:vsch,项目名称:idea-multimarkdown,代码行数:18,代码来源:MultiMarkdownPreviewEditor.java

示例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");
        }
    }
}
 
开发者ID:vsch,项目名称:idea-multimarkdown,代码行数:19,代码来源:MultiMarkdownFxPreviewEditor.java

示例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);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:24,代码来源:MarkdownFormatter.java

示例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);
}
 
开发者ID:Arnauld,项目名称:cucumber-contrib,代码行数:14,代码来源:MarkdownEmitter.java

示例5: toHtml

import org.pegdown.ToHtmlSerializer; //导入依赖的package包/类
public String toHtml() {
    return new ToHtmlSerializer(new MarkdownLinkRenderer()).toHtml(rootNode);
}
 
开发者ID:voostindie,项目名称:magisto,代码行数:4,代码来源:MarkdownDocument.java

示例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;
    }
}
 
开发者ID:windup,项目名称:windup,代码行数:43,代码来源:MarkdownToHtmlMethod.java

示例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());
}
 
开发者ID:Abnaxos,项目名称:markdown-doclet,代码行数:10,代码来源:Options.java


注:本文中的org.pegdown.ToHtmlSerializer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。