• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java VerbatimSerializer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.pegdown.VerbatimSerializer的典型用法代码示例。如果您正苦于以下问题:Java VerbatimSerializer类的具体用法?Java VerbatimSerializer怎么用?Java VerbatimSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VerbatimSerializer类属于org.pegdown包,在下文中一共展示了VerbatimSerializer类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: markdownToHtml

import org.pegdown.VerbatimSerializer; //导入依赖的package包/类
/**
 * Convert Markdown into HTML (just the body content) with inline styles
 * 
 * @param markdown Markdown to convert into HTML
 * @return String containing HTML (just the body content)
 * @throws MarkdownException 
 */
String markdownToHtml(String markdown) throws MarkdownException {
	Map<String, VerbatimSerializer> verbatimSerializers = new HashMap<>();
	verbatimSerializers.put(MyCustomVerbatimSerializer.DEFAULT, MyCustomVerbatimSerializer.INSTANCE);

	String htmlBody = processor.markdownToHtml(markdown.toCharArray(), new LinkRenderer(), verbatimSerializers);
	LOG.debug("Body before styles: {}",htmlBody);

	String htmlWithStyleInline = "";
	try {
		htmlWithStyleInline = new HtmlStyleSheetInliner().inlineStyleSheet(htmlBody, styleSheet);
	} catch (SAXException | IOException | TransformerException e) {
		e.printStackTrace();
		throw new MarkdownException("Could not turn Markdown to HTML");
	}
	LOG.debug("Body after styles: {}",htmlWithStyleInline);
	
	return htmlWithStyleInline;
}
 
开发者ID:windsource,项目名称:evernote-markdown-sync,代码行数:26,代码来源:MarkdownService.java


示例2: renderToHtml

import org.pegdown.VerbatimSerializer; //导入依赖的package包/类
@Override
public String renderToHtml(String markdownSource) {
    // synchronizing on pegdown instance since neither the processor nor the underlying parser is thread-safe.
    synchronized (pegdown) {
        RootNode astRoot = pegdown.parseMarkdown(markdownSource.toCharArray());
        MarkdownToHtmlSerializer serializer = new MarkdownToHtmlSerializer(new LinkRenderer(),
                Collections.singletonMap(VerbatimSerializer.DEFAULT, PrettifyVerbatimSerializer.INSTANCE));
        return serializer.toHtml(astRoot);
    }
}
 
开发者ID:microacup,项目名称:microbbs,代码行数:11,代码来源:PegdownMarkdownService.java


示例3: markdownToHtml

import org.pegdown.VerbatimSerializer; //导入依赖的package包/类
@Override
public String markdownToHtml(char[] markdownSource,
		LinkRenderer linkRenderer,
		Map<String, VerbatimSerializer> verbatimSerializerMap) {
	try {
		RootNode astRoot = parseMarkdown(markdownSource);
		return new ToHtmlNoLinkSerializer(linkRenderer,
				verbatimSerializerMap).toHtml(astRoot);
	} catch (ParsingTimeoutException e) {
		return null;
	}
}
 
开发者ID:ZapBlasterson,项目名称:crushpaper,代码行数:13,代码来源:PegDownNoLinkProcessor.java


示例4: toHtml

import org.pegdown.VerbatimSerializer; //导入依赖的package包/类
@Override
public String toHtml(String source) {
    try {
        Map<String, VerbatimSerializer> serializers = new HashMap<>();
        PlantUmlVerbatimSerializer.addToMap(serializers);
        LinkRenderer linkRenderer = new TypeLinkRenderer();
        return processor.markdownToHtml(source, linkRenderer, serializers);
    } catch (Exception e) {
        LOGGER.error("Could not convert given source to markdown: {}", source, e);
        return source;
    }
}
 
开发者ID:protostuff,项目名称:protostuff-compiler,代码行数:13,代码来源:PegDownMarkdownProcessor.java


示例5: addToMap

import org.pegdown.VerbatimSerializer; //导入依赖的package包/类
/**
 * Register an instance of {@link PlantUmlVerbatimSerializer} in the given serializer's map.
 */
public static void addToMap(final Map<String, VerbatimSerializer> serializerMap) {
    PlantUmlVerbatimSerializer serializer = new PlantUmlVerbatimSerializer();
    for (Type type : Type.values()) {
        String name = type.getName();
        serializerMap.put(name, serializer);
    }
}
 
开发者ID:protostuff,项目名称:protostuff-compiler,代码行数:11,代码来源:PlantUmlVerbatimSerializer.java


示例6: markdownToHtml

import org.pegdown.VerbatimSerializer; //导入依赖的package包/类
public String markdownToHtml(char[] markdownSource, LinkRenderer linkRenderer, Map<String, VerbatimSerializer> verbatimSerializerMap) {
    try {
        RootNode astRoot = parseMarkdown(markdownSource);
        return new NS2GToHtmlSerializer(linkRenderer, verbatimSerializerMap).toHtml(astRoot);
    } catch (ParsingTimeoutException e) {
        return null;
    }
}
 
开发者ID:rkfg,项目名称:ns2gather,代码行数:9,代码来源:NS2GPegDownProcessor.java


示例7: MarkdownToHtmlSerializer

import org.pegdown.VerbatimSerializer; //导入依赖的package包/类
public MarkdownToHtmlSerializer(final LinkRenderer linkRenderer, final Map<String, VerbatimSerializer> verbatimSerializers) {
    super(linkRenderer, verbatimSerializers);
}
 
开发者ID:microacup,项目名称:microbbs,代码行数:4,代码来源:MarkdownToHtmlSerializer.java


示例8: ToHtmlNoLinkSerializer

import org.pegdown.VerbatimSerializer; //导入依赖的package包/类
public ToHtmlNoLinkSerializer(LinkRenderer linkRenderer,
		Map<String, VerbatimSerializer> verbatimSerializerMap) {
	super(linkRenderer, verbatimSerializerMap);
}
 
开发者ID:ZapBlasterson,项目名称:crushpaper,代码行数:5,代码来源:ToHtmlNoLinkSerializer.java


示例9: MultiMarkdownToHtmlSerializer

import org.pegdown.VerbatimSerializer; //导入依赖的package包/类
public MultiMarkdownToHtmlSerializer(LinkRenderer linkRenderer, Map<String, VerbatimSerializer> verbatimSerializers) {
    super(linkRenderer, verbatimSerializers);
    project = null;
    document = null;
}
 
开发者ID:vsch,项目名称:idea-multimarkdown,代码行数:6,代码来源:MultiMarkdownToHtmlSerializer.java


示例10: NS2GToHtmlSerializer

import org.pegdown.VerbatimSerializer; //导入依赖的package包/类
public NS2GToHtmlSerializer(LinkRenderer linkRenderer, Map<String, VerbatimSerializer> verbatimSerializerMap) {
    super(linkRenderer, verbatimSerializerMap);
}
 
开发者ID:rkfg,项目名称:ns2gather,代码行数:4,代码来源:NS2GToHtmlSerializer.java


示例11: exec

import org.pegdown.VerbatimSerializer; //导入依赖的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


示例12: ToHtmlSerializerExtended

import org.pegdown.VerbatimSerializer; //导入依赖的package包/类
public ToHtmlSerializerExtended(LinkRenderer linkRenderer, Map<String, VerbatimSerializer> verbatimSerializers,
            List<ToHtmlSerializerPlugin> plugins)
{
    super(linkRenderer, verbatimSerializers, plugins);
}
 
开发者ID:windup,项目名称:windup,代码行数:6,代码来源:ToHtmlSerializerExtended.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ObjectIdImpl类代码示例发布时间:2022-05-22
下一篇:
Java KillJobResponsePBImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap