當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。