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


Java TablesExtension类代码示例

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


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

示例1: render

import org.commonmark.ext.gfm.tables.TablesExtension; //导入依赖的package包/类
protected static void render(@NonNull TextView textView, String markdown, int width) {
    List<Extension> extensions = Arrays.asList(
            StrikethroughExtension.create(),
            AutolinkExtension.create(),
            TablesExtension.create(),
            InsExtension.create(),
            EmojiExtension.create(),
            MentionExtension.create(),
            YamlFrontMatterExtension.create());
    Parser parser = Parser.builder()
            .extensions(extensions)
            .build();
    try {
        Node node = parser.parse(markdown);
        String rendered = HtmlRenderer
                .builder()
                .extensions(extensions)
                .build()
                .render(node);
        HtmlHelper.htmlIntoTextView(textView, rendered, (width - (textView.getPaddingStart() + textView.getPaddingEnd())));
    } catch (Exception ignored) {
        HtmlHelper.htmlIntoTextView(textView, markdown, (width - (textView.getPaddingStart() + textView.getPaddingEnd())));
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:25,代码来源:MarkDownProvider.java

示例2: generateContents

import org.commonmark.ext.gfm.tables.TablesExtension; //导入依赖的package包/类
public String generateContents(Page page) throws IOException {
    List<Extension> extensions = Collections.singletonList(TablesExtension.create());

    Parser parser = Parser
            .builder()
            .extensions(extensions)
            .build();

    HtmlRenderer renderer = HtmlRenderer
            .builder()
            .attributeProvider((node, attributes) -> {
                if (node instanceof TableBlock) {
                    attributes.put("class", "table");
                }
            })
            .extensions(extensions)
            .build();

    Node document = parser.parseReader(new FileReader(page.getFile()));

    return renderer.render(document);
}
 
开发者ID:UniversalMinecraftAPI,项目名称:UniversalMinecraftAPI,代码行数:23,代码来源:PageGenerator.java

示例3: mdToHtml

import org.commonmark.ext.gfm.tables.TablesExtension; //导入依赖的package包/类
/**
 * markdown转换为html
 *
 * @param markdown
 * @return
 */
public static String mdToHtml(String markdown) {
    if (StringUtils.isBlank(markdown)) {
        return "";
    }
    java.util.List<Extension> extensions = Arrays.asList(TablesExtension.create());
    Parser parser = Parser.builder().extensions(extensions).build();
    Node document = parser.parse(markdown);
    HtmlRenderer renderer = HtmlRenderer.builder().extensions(extensions).build();
    String content = renderer.render(document);
    content = Commons.emoji(content);
    return content;
}
 
开发者ID:ZHENFENG13,项目名称:My-Blog,代码行数:19,代码来源:TaleUtils.java

示例4: createParser

import org.commonmark.ext.gfm.tables.TablesExtension; //导入依赖的package包/类
/**
 * Helper method to obtain a Parser with registered strike-through &amp; table extensions
 * &amp; task lists (added in 1.0.1)
 *
 * @return a Parser instance that is supported by this library
 * @since 1.0.0
 */
@NonNull
public static Parser createParser() {
    return new Parser.Builder()
            .extensions(Arrays.asList(
                    StrikethroughExtension.create(),
                    TablesExtension.create(),
                    TaskListExtension.create()
            ))
            .build();
}
 
开发者ID:noties,项目名称:Markwon,代码行数:18,代码来源:Markwon.java

示例5: markdownToHTML

import org.commonmark.ext.gfm.tables.TablesExtension; //导入依赖的package包/类
private String markdownToHTML(String md) {
	List<Extension> extensions = Arrays.asList(TablesExtension.create());

	final Parser parser = Parser.builder().extensions(extensions).build();
	final Node doc = parser.parse(md);
	final HtmlRenderer renderer = HtmlRenderer.builder().extensions(extensions).build();
	return renderer.render(doc);
}
 
开发者ID:phon-ca,项目名称:phon,代码行数:9,代码来源:NodeWizardReportGenerator.java

示例6: CommonMarkUtils

import org.commonmark.ext.gfm.tables.TablesExtension; //导入依赖的package包/类
public CommonMarkUtils () {
    List<Extension> extensions = Arrays.asList(TablesExtension.create(), StrikethroughExtension.create(), HeadingAnchorExtension.create(), InsExtension.create());
    parser = Parser.builder().extensions(extensions).build();
    renderer = HtmlRenderer.builder().extensions(extensions).build();
}
 
开发者ID:progwml6,项目名称:FTBCurseBot,代码行数:6,代码来源:CommonMarkUtils.java

示例7: process

import org.commonmark.ext.gfm.tables.TablesExtension; //导入依赖的package包/类
public MarkdownProcessorResult process(String markdownContent, List<Visitor> visitors) {
    List<Extension> extensions = Arrays.asList(TablesExtension.create(), YamlFrontMatterExtension.create());

    Parser parser = Parser.builder().extensions(extensions).build();
    
    Node document = parser.parse(markdownContent);
    
    YamlFrontMatterVisitor yamlVisitor = new YamlFrontMatterVisitor();
    document.accept(yamlVisitor);
    
    Set<String> linkTargets = new HashSet<>();

    // Modify listing headings
    for (Visitor visitor : visitors) {
    		document.accept(visitor); // new NavigationLinkInjector(siblingPages, subCategories));
    }
    
    // Fix links to *.md to go to *.html instead
    document.accept(new AbstractVisitor() {
        @Override
        public void visit(Link link) {
            URI uri = URI.create(link.getDestination());
            linkTargets.add(link.getDestination());
            link.setDestination(MarkdownUtils.renameFilenameForMarkdownPage(link.getDestination()));
            visitChildren(link);
        }
    });
    
    MarkdownTocGenerator tocGenerator = new MarkdownTocGenerator();

    HtmlRenderer renderer = HtmlRenderer.builder().extensions(extensions).attributeProviderFactory(new AttributeProviderFactory() {
        @Override
        public AttributeProvider create(AttributeProviderContext context) {
            return tocGenerator;
        }
    }).build();

    String renderedContent = renderer.render(document);

    MarkdownProcessorResult result = new MarkdownProcessorResult(renderedContent, tocGenerator.getToc(), yamlVisitor.getData());
    result.getLinkTargets().addAll(linkTargets);
    return result;
}
 
开发者ID:mattsheppard,项目名称:markdown-static-site-generator,代码行数:44,代码来源:MarkdownProcessor.java

示例8: tablesExtensionTest

import org.commonmark.ext.gfm.tables.TablesExtension; //导入依赖的package包/类
@Test
public void tablesExtensionTest() throws Exception {
    parseWithExtensionsTest(TablesExtension.create());
}
 
开发者ID:atlassian,项目名称:commonmark-java,代码行数:5,代码来源:AndroidSupportTest.java


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