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


Java AttributeProviderContext类代码示例

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


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

示例1: extend

import org.commonmark.renderer.html.AttributeProviderContext; //导入依赖的package包/类
@Override
public void extend(HtmlRenderer.Builder rendererBuilder) {
    rendererBuilder.attributeProviderFactory(new AttributeProviderFactory() {
        @Override
        public AttributeProvider create(AttributeProviderContext context) {
            return HeadingIdAttributeProvider.create(defaultId, idPrefix, idSuffix);
        }
    });
}
 
开发者ID:atlassian,项目名称:commonmark-java,代码行数:10,代码来源:HeadingAnchorExtension.java

示例2: attributeProviderIsApplied

import org.commonmark.renderer.html.AttributeProviderContext; //导入依赖的package包/类
@Test
public void attributeProviderIsApplied() {
    AttributeProviderFactory factory = new AttributeProviderFactory() {
        @Override
        public AttributeProvider create(AttributeProviderContext context) {
            return new AttributeProvider() {
                @Override
                public void setAttributes(Node node, String tagName, Map<String, String> attributes) {
                    if (node instanceof TableBlock) {
                        attributes.put("test", "block");
                    } else if (node instanceof TableHead) {
                        attributes.put("test", "head");
                    } else if (node instanceof TableBody) {
                        attributes.put("test", "body");
                    } else if (node instanceof TableRow) {
                        attributes.put("test", "row");
                    } else if (node instanceof TableCell) {
                        attributes.put("test", "cell");
                    }
                }
            };
        }
    };
    HtmlRenderer renderer = HtmlRenderer.builder()
            .attributeProviderFactory(factory)
            .extensions(EXTENSIONS)
            .build();
    String rendered = renderer.render(PARSER.parse("Abc|Def\n---|---\n1|2"));
    assertThat(rendered, is("<table test=\"block\">\n" +
            "<thead test=\"head\">\n" +
            "<tr test=\"row\"><th test=\"cell\">Abc</th><th test=\"cell\">Def</th></tr>\n" +
            "</thead>\n" +
            "<tbody test=\"body\">\n" +
            "<tr test=\"row\"><td test=\"cell\">1</td><td test=\"cell\">2</td></tr>\n" +
            "</tbody>\n" +
            "</table>\n"));
}
 
开发者ID:atlassian,项目名称:commonmark-java,代码行数:38,代码来源:TablesTest.java

示例3: process

import org.commonmark.renderer.html.AttributeProviderContext; //导入依赖的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

示例4: create

import org.commonmark.renderer.html.AttributeProviderContext; //导入依赖的package包/类
@Override
public AttributeProvider create(AttributeProviderContext context) {
	return this;
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:5,代码来源:CommonmarkPreviewRenderer.java


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