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


Java Extensions类代码示例

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


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

示例1: processBody

import org.pegdown.Extensions; //导入依赖的package包/类
@Override
public void processBody(final ParserContext context) {
    String[] mdExts = context.getConfig().getStringArray("markdown.extensions");

    int extensions = Extensions.NONE;
    if (mdExts.length > 0) {
        for (int index = 0; index < mdExts.length; index++) {
            String ext = mdExts[index];
            if (ext.startsWith("-")) {
  ext = ext.substring(1);
                extensions=removeExtension(extensions, extensionFor(ext));
            } else {
                if (ext.startsWith("+")) {
    ext = ext.substring(1);
                }
                extensions=addExtension(extensions, extensionFor(ext));
            }
        }
    }
    
    long maxParsingTime = context.getConfig().getLong("markdown.maxParsingTimeInMillis", PegDownProcessor.DEFAULT_MAX_PARSING_TIME);
    
    PegDownProcessor pegdownProcessor = new PegDownProcessor(extensions, maxParsingTime);
    context.setBody(pegdownProcessor.markdownToHtml(context.getBody()));
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:26,代码来源:MarkdownEngine.java

示例2: toHTML

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

示例3: MarkdownService

import org.pegdown.Extensions; //导入依赖的package包/类
public MarkdownService () {
	markdownFileExtensions.add("md");
	markdownFileExtensions.add("txt");
	markdownFileExtensions.add("markdown");
	
	processor = new PegDownProcessor(
			Extensions.AUTOLINKS | Extensions.TABLES
			| Extensions.FENCED_CODE_BLOCKS | Extensions.STRIKETHROUGH
			| Extensions.ATXHEADERSPACE | Extensions.TASKLISTITEMS);
	
	// read style sheet
	InputStream inputStream = MarkdownService.class.getResourceAsStream(STYLE_SHEET_FILE);
	
	StringWriter writer = new StringWriter();
	
	try {
		IOUtils.copy(inputStream, writer, "UTF-8");
		styleSheet = writer.toString();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:windsource,项目名称:evernote-markdown-sync,代码行数:23,代码来源:MarkdownService.java

示例4: check

import org.pegdown.Extensions; //导入依赖的package包/类
private void check(PegDownPlugins.Builder extraPluginsBuilder, String markdown, String expectedAst) {
    Reference<Parser> parserRef = new Reference<Parser>();

    PegDownPlugins plugins =
            (extraPluginsBuilder == null ? PegDownPlugins.builder() : extraPluginsBuilder)
                    .withPlugin(GenericBoxPlugin.class, parserRef)
                    .build();

    // ---

    PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
    parserRef.set(processor.parser);

    RootNode rootNode = processor.parseMarkdown(normalize(markdown).toCharArray());

    String s = dumpAST(rootNode);
    System.out.println("GenericBoxPluginTest.check::" + s);
    assertThat(normalize(s.trim())).isEqualTo(normalize(expectedAst));
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:20,代码来源:GenericBoxPluginTest.java

示例5: check

import org.pegdown.Extensions; //导入依赖的package包/类
private void check(String markdown, String expectedAst) {
    Reference<Parser> parserRef = new Reference<Parser>();

    PegDownPlugins plugins =
            PegDownPlugins.builder()
                    .withPlugin(LinkContentPlugin.class, parserRef)
                    .build();

    // ---

    PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
    parserRef.set(processor.parser);

    RootNode rootNode = processor.parseMarkdown(normalize(markdown).toCharArray());

    String s = dumpAST(rootNode);
    assertThat(normalize(s.trim())).isEqualTo(normalize(expectedAst));
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:19,代码来源:LinkContentPluginTest.java

示例6: astBuild_simpleCase

import org.pegdown.Extensions; //导入依赖的package包/类
@Test
public void astBuild_simpleCase() throws IOException {
    String mkd = loadResource("attributesText-simple.md").trim();
    String ast = loadResource("attributesText-simple.ast").trim();

    PegDownPlugins plugins = PegDownPlugins
            .builder()
            .withPlugin(AttributesPlugin.class)
            .build();

    PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
    RootNode rootNode = processor.parseMarkdown(normalize(mkd).toCharArray());

    String s = dumpAST(rootNode);
    assertThat(normalize(s.trim())).isEqualTo(normalize(ast));
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:17,代码来源:AttributesPluginTest.java

示例7: astBuild_advancedCase

import org.pegdown.Extensions; //导入依赖的package包/类
@Test
public void astBuild_advancedCase() throws IOException {
    String mkd = loadResource("attributesText.md").trim();
    String ast = loadResource("attributesText.ast").trim();

    PegDownPlugins plugins = PegDownPlugins
            .builder()
            .withPlugin(AttributesPlugin.class)
            .build();

    PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
    RootNode rootNode = processor.parseMarkdown(normalize(mkd).toCharArray());

    String s = dumpAST(rootNode);
    assertThat(normalize(s.trim())).isEqualTo(normalize(ast));
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:17,代码来源:AttributesPluginTest.java

示例8: processString

import org.pegdown.Extensions; //导入依赖的package包/类
private void processString(String usecase, String mkd, Function<InvocationContext, InvocationContext> customizer) throws Exception {
    Reference<Parser> parserRef = new Reference<Parser>();
    ITextContext iTextContext = openDocument(usecase);

    PegDownPlugins plugins = PegDownPlugins
            .builder()
            .withPlugin(AttributesPlugin.class)
            .withPlugin(GenericBoxPlugin.class, parserRef)
            .build();
    PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
    parserRef.set(processor.parser);

    RootNode rootNode = processor.parseMarkdown(mkd.toCharArray());

    InvocationContext context = customizer.apply(new InvocationContext(iTextContext));
    if (context == null) {
        fail("No context");
        return;
    }

    context.process(0, rootNode);
    context.flushPendingChapter();
    iTextContext.close();
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:25,代码来源:PegdownPdfTest.java

示例9: parseDoc

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

示例10: process

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

示例11: shouldHighlightMarkdown

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

示例12: extensions

import org.pegdown.Extensions; //导入依赖的package包/类
public static int extensions() {

        int EXT = Extensions.NONE;

        EXT |= Extensions.FENCED_CODE_BLOCKS;
        EXT |= Extensions.TABLES;
        EXT |= Extensions.STRIKETHROUGH;
        // EXT |= Extensions.SMARTS; // Breaks link including a dash -

        return EXT;
    }
 
开发者ID:bsorrentino,项目名称:maven-confluence-plugin,代码行数:12,代码来源:ToConfluenceSerializer.java

示例13: test

import org.pegdown.Extensions; //导入依赖的package包/类
@Test
public void test() throws IOException {
    try {
        PegDownProcessor processor = new PegDownProcessor(Extensions.FENCED_CODE_BLOCKS);
        RootNode rootNode = processor.parseMarkdown(FileUtils.readFileToString(new File("README.tmpl.md")).toCharArray());
        rootNode.accept(new DocTestingVisitor());
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }
}
 
开发者ID:sillelien,项目名称:dollar-core,代码行数:12,代码来源:DocTest.java

示例14: execute

import org.pegdown.Extensions; //导入依赖的package包/类
@Override
public String execute(Map parameters, String body, ConversionContext context) throws MacroExecutionException {
    String enablePegDownExtensions = parameters.containsKey("enable-pegdown-extensions") ?
            (String) parameters.get("enable-pegdown-extensions") : "true";
    Boolean extensionsEnabled = BooleanUtils.toBoolean(enablePegDownExtensions);

    return this.getProcessor(extensionsEnabled ? Extensions.ALL : Extensions.NONE).markdownToHtml(body);
}
 
开发者ID:CSharpRU,项目名称:simple-markdown,代码行数:9,代码来源:MarkdownMacro.java

示例15: compile

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


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