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


Java PegDownProcessor.markdownToHtml方法代码示例

本文整理汇总了Java中org.pegdown.PegDownProcessor.markdownToHtml方法的典型用法代码示例。如果您正苦于以下问题:Java PegDownProcessor.markdownToHtml方法的具体用法?Java PegDownProcessor.markdownToHtml怎么用?Java PegDownProcessor.markdownToHtml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pegdown.PegDownProcessor的用法示例。


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

示例1: toHTML

import org.pegdown.PegDownProcessor; //导入方法依赖的package包/类
/**
 * Converts the specified markdown text to HTML.
 *
 * @param markdownText
 *            the specified markdown text
 * @return converted HTML, returns {@code null} if the specified markdown
 *         text is "" or {@code null}, returns "Markdown error" if exception
 */
public static String toHTML(final String markdownText) {
	if (StringUtils.isBlank(markdownText)) {
		return "";
	}

	final PegDownProcessor pegDownProcessor = new PegDownProcessor(
			Extensions.ALL_OPTIONALS | Extensions.ALL_WITH_OPTIONALS, 5000);
	String ret = pegDownProcessor.markdownToHtml(markdownText);

	if (!StringUtils.startsWith(ret, "<p>")) {
		ret = "<p>" + ret + "</p>";
	}

	return ret;
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:24,代码来源:Markdowns.java

示例2: parseDoc

import org.pegdown.PegDownProcessor; //导入方法依赖的package包/类
private static void parseDoc(@NotNull String page, @NotNull File outDir) throws IOException {
    outDir.mkdirs();
    String source = CharStreams.toString(
            new InputStreamReader(ParseDocs.class.getResourceAsStream("/pages/" + page + ".md")));
    String toParse;
    if (source.startsWith("#!")) {
        toParse = "\n" + source.substring(source.indexOf("\n"));
    } else {
        toParse = source;
    }
    new DollarParserImpl(new ParserOptions()).parseMarkdown(toParse);
    PegDownProcessor pegDownProcessor = new PegDownProcessor(Extensions.FENCED_CODE_BLOCKS);
    String result = pegDownProcessor.markdownToHtml(toParse);
    Files.write(new File(outDir, page + ".html").toPath(), result.getBytes());
    Files.write(new File(outDir, page + ".md").toPath(), toParse.getBytes());
    System.exit(0);
}
 
开发者ID:sillelien,项目名称:dollar,代码行数:18,代码来源:ParseDocs.java

示例3: process

import org.pegdown.PegDownProcessor; //导入方法依赖的package包/类
public String process(String itemContent) {
    itemContent = new MarkdownFootnotesProcessor(itemContent).process();
    ParsedContent parsed = parseOutRawHtml(itemContent);
    PegDownProcessor pegdownProcessor = new PegDownProcessor(
            Extensions.FENCED_CODE_BLOCKS |
                    Extensions.AUTOLINKS |
                    Extensions.STRIKETHROUGH |
                    Extensions.TABLES |
                    Extensions.QUOTES |
                    Extensions.SMARTS
    );
    itemContent = pegdownProcessor.markdownToHtml(parsed.content);
    itemContent = swapInRawHtml(itemContent, parsed);
    return itemContent;
}
 
开发者ID:StallionCMS,项目名称:stallion-core,代码行数:16,代码来源:Markdown.java

示例4: render

import org.pegdown.PegDownProcessor; //导入方法依赖的package包/类
@Override
public String render(final Template template, final Model model) {
    final PegDownProcessor pegDownProcessor = new PegDownProcessor();
    final String markdown = template.getContent().getText();
    final String html = pegDownProcessor.markdownToHtml(markdown);

    return freemarkerRenderer.renderLayout(template, html, model);
}
 
开发者ID:marcobehler,项目名称:saito,代码行数:9,代码来源:MarkdownRenderer.java

示例5: shouldHighlightMarkdown

import org.pegdown.PegDownProcessor; //导入方法依赖的package包/类
@Test
public void shouldHighlightMarkdown() throws IOException {
    PegDownProcessor processor = new PegDownProcessor(Extensions.FENCED_CODE_BLOCKS);
    byte[] bytes = Files.readAllBytes(Paths.get("src/test/resources/markdown", "java1.md"));
    String markdown = new String(bytes, StandardCharsets.UTF_8);
    String html = processor.markdownToHtml(markdown);
    System.out.println(html);
}
 
开发者ID:ops4j,项目名称:org.ops4j.ramler,代码行数:9,代码来源:MarkdownTest.java

示例6: compile

import org.pegdown.PegDownProcessor; //导入方法依赖的package包/类
public static String compile(String src) {
  PegDownProcessor processor = new PegDownProcessor(Extensions.AUTOLINKS | Extensions.FENCED_CODE_BLOCKS);
  String replaced = expandSpaceForLi(src);
  String html = processor.markdownToHtml(replaced);
  String cleanedHtml = Jsoup.clean(html, Whitelist.relaxed());
  return cleanedHtml;
}
 
开发者ID:kamegu,项目名称:git-webapp,代码行数:8,代码来源:Markdown.java

示例7: usePegDown

import org.pegdown.PegDownProcessor; //导入方法依赖的package包/类
private String usePegDown(String text) {
	PegDownProcessor pegdown = new PegDownProcessor();
	return pegdown.markdownToHtml(text);
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:5,代码来源:FluentMkConverter.java

示例8: fileResourceProcessor

import org.pegdown.PegDownProcessor; //导入方法依赖的package包/类
private static Function<FileResourceParameters, FileResourceProcessorOutput> fileResourceProcessor() {
  
  PegDownProcessor pegDownProcessor = new PegDownProcessor(Extensions.ALL);
  return params -> new FileResourceProcessorOutput(pegDownProcessor.markdownToHtml(params.fileResource.getContent().orElseThrow(IllegalArgumentException::new)), params.fileResource.getPath(), "markdown", params.locale);
}
 
开发者ID:digitalfondue,项目名称:stampo,代码行数:6,代码来源:MarkdownRenderer.java


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