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

Java PegDownPlugins类代码示例

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

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



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

示例1: check

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


示例2: check

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


示例3: attributesPlugin

import org.pegdown.plugins.PegDownPlugins; //导入依赖的package包/类
@Theory
public void attributesPlugin(@ForAll @InRange(minInt = 0, maxInt = 0x0000FFFF) int extensions) 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, plugins);
    RootNode rootNode = processor.parseMarkdown(normalize(mkd).toCharArray());

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


示例4: astBuild_simpleCase

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


示例5: astBuild_advancedCase

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


示例6: processString

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


示例7: PegdownParser

import org.pegdown.plugins.PegDownPlugins; //导入依赖的package包/类
public PegdownParser() {
  PegDownPlugins plugins = new PegDownPlugins.Builder()
      .withPlugin(PegdownYumlPlugin.class)
      .withPlugin(PegdownWebSequencelPlugin.class)
      .build();
  processor = new PegDownProcessor(OPTIONS, PARSING_TIMEOUT_AS_MILLIS, plugins);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:8,代码来源:PegdownParser.java


示例8: processMarkup

import org.pegdown.plugins.PegDownPlugins; //导入依赖的package包/类
@Override
public void processMarkup() throws IOException {
    // load file into a string
    StringBuilder sb = new StringBuilder();
    try (BufferedReader reader = Files.newBufferedReader(sourceFilePath, Charset.defaultCharset())) {
        for (; ; ) {
            String line = reader.readLine();
            if (line == null) {
                break;
            }
            sb.append(line);
            sb.append('\n');
        }
        sb.append("\n\n");
    }

    // parse it
    /*
    PegDownPlugins.Builder pluginBuilder = PegDownPlugins.builder();
    Parser parser = Parboiled.createParser(Parser.class, Extensions.FENCED_CODE_BLOCKS | Extensions.WIKILINKS,
            1000L, Parser.DefaultParseRunnerProvider, pluginBuilder.build());
    */

    Parser parser = Parboiled.createParser(Parser.class, Extensions.FENCED_CODE_BLOCKS | Extensions.WIKILINKS,
            1000L, Parser.DefaultParseRunnerProvider, PegDownPlugins.builder().withPlugin(PluginParser.class)
                    .build());
    rootNode = parser.parse(sb.toString().toCharArray());
    loadTitle();
}
 
开发者ID:nicolaschriste,项目名称:docdown,代码行数:30,代码来源:PegdownDoc.java


示例9: generixBox_with_attributes_ast_build

import org.pegdown.plugins.PegDownPlugins; //导入依赖的package包/类
@Test
public void generixBox_with_attributes_ast_build() throws IOException {
    String mkd = loadResource("genericBox-with-attributesText.md").trim();
    String ast = loadResource("genericBox-with-attributesText.ast").trim();
    PegDownPlugins.Builder plugins = PegDownPlugins
            .builder()
            .withPlugin(AttributesPlugin.class);
    check(plugins, mkd, ast);
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:10,代码来源:GenericBoxPluginTest.java


示例10: parseMarkdown

import org.pegdown.plugins.PegDownPlugins; //导入依赖的package包/类
private RootNode parseMarkdown(String resourcePath) throws IOException {
    String mkd = loadResource(resourcePath).trim();

    PegDownPlugins plugins = PegDownPlugins
            .builder()
            .withPlugin(AttributesPlugin.class)
            .build();
    PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
    return processor.parseMarkdown(mkd.toCharArray());
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:11,代码来源:ReferencesTest.java


示例11: usecase__sibling_then_of_type

import org.pegdown.plugins.PegDownPlugins; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void usecase__sibling_then_of_type() throws Exception {
    String mkd = loadResource("image-04-ref.md").trim();

    PegDownPlugins plugins = PegDownPlugins
            .builder()
            .withPlugin(AttributesPlugin.class)
            .build();
    PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
    RootNode rootNode = processor.parseMarkdown(mkd.toCharArray());

    TreeNavigation nav;
    nav = new TreeNavigation();
    nav.push(rootNode);
    nav.pushChild(3);

    assertThat(nav.peek()).isInstanceOf(ParaNode.class);

    //
    //
    Optional<TreeNavigation> result =
            siblingBefore()
                    .then(ofType(AttributesNode.class))
                    .query(nav);
    assertThat(result.isPresent()).isTrue();
    assertThat(result.get().peek()).isInstanceOf(AttributesNode.class);
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:29,代码来源:TreeNavigationTest.java


示例12: setUp

import org.pegdown.plugins.PegDownPlugins; //导入依赖的package包/类
@Before
public void setUp() {
    PegDownPlugins plugins = PegDownPlugins
            .builder()
            .withPlugin(NamedBlockCurlyBracePlugin.class)
            .build();
    processor = new PegDownProcessor(Extensions.TABLES, plugins);
}
 
开发者ID:Arnauld,项目名称:cucumber-contrib,代码行数:9,代码来源:NamedBlockCurlyBracePluginTest.java


示例13: PegdownWebSequencelPlugin

import org.pegdown.plugins.PegDownPlugins; //导入依赖的package包/类
public PegdownWebSequencelPlugin(Integer opts, Long millis, ParseRunnerProvider provider,
                                 PegDownPlugins plugins) {
  super(opts, millis, provider, plugins);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:5,代码来源:PegdownWebSequencelPlugin.java


示例14: PegdownYumlPlugin

import org.pegdown.plugins.PegDownPlugins; //导入依赖的package包/类
public PegdownYumlPlugin(Integer options,
                         Long maxParsingTimeInMillis,
                         ParseRunnerProvider parseRunnerProvider,
                         PegDownPlugins plugins) {
  super(options, maxParsingTimeInMillis, parseRunnerProvider, plugins);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:7,代码来源:PegdownYumlPlugin.java


示例15: usecase__ancestor_sibling_and_of_type

import org.pegdown.plugins.PegDownPlugins; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void usecase__ancestor_sibling_and_of_type() throws Exception {
    String mkd = loadResource("image-04-ref.md").trim();

    PegDownPlugins plugins = PegDownPlugins
            .builder()
            .withPlugin(AttributesPlugin.class)
            .build();
    PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
    RootNode rootNode = processor.parseMarkdown(mkd.toCharArray());

    TreeNavigation nav;
    nav = new TreeNavigation();
    nav.push(rootNode);
    nav.pushChild(3);
    nav.pushChild();
    nav.pushChild();
    assertThat(nav.peek()).isInstanceOf(RefImageNode.class);

    //
    //
    Optional<TreeNavigation> result1 =
            ancestor(RefImageNode.class, SuperNode.class, ParaNode.class)
                    .query(nav);
    assertThat(result1.isPresent()).isTrue();
    assertThat(result1.get().peek()).isInstanceOf(ParaNode.class);

    //
    //
    Optional<TreeNavigation> result2 =
            ancestor(RefImageNode.class, SuperNode.class, ParaNode.class)
                    .then(siblingBefore())
                    .query(nav);
    assertThat(result2.isPresent()).isTrue();
    assertThat(result2.get().peek()).isInstanceOf(AttributesNode.class);

    //
    //
    Optional<TreeNavigation> result3 =
            firstAncestorOfType(ParaNode.class)
                    .then(siblingBefore())
                    .query(nav);
    assertThat(result3.isPresent()).isTrue();
    assertThat(result3.get().peek()).isInstanceOf(AttributesNode.class);

    //System.out.println("TreeNavigationTest.usecase" + dumpAST(rootNode));
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:49,代码来源:TreeNavigationTest.java


示例16: CustomMarkdownParser

import org.pegdown.plugins.PegDownPlugins; //导入依赖的package包/类
public CustomMarkdownParser() {
    super(Extensions.ALL - Extensions.HARDWRAPS - Extensions.EXTANCHORLINKS,
            PegDownProcessor.DEFAULT_MAX_PARSING_TIME,
            Parser.DefaultParseRunnerProvider,
            PegDownPlugins.NONE);
}
 
开发者ID:voostindie,项目名称:magisto,代码行数:7,代码来源:CustomMarkdownParser.java


示例17: exec

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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