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


Java HtmlRenderer.render方法代码示例

本文整理汇总了Java中org.commonmark.renderer.html.HtmlRenderer.render方法的典型用法代码示例。如果您正苦于以下问题:Java HtmlRenderer.render方法的具体用法?Java HtmlRenderer.render怎么用?Java HtmlRenderer.render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.commonmark.renderer.html.HtmlRenderer的用法示例。


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

示例1: markdownToHtml

import org.commonmark.renderer.html.HtmlRenderer; //导入方法依赖的package包/类
/**
 * Converts a markdown buffer to a Html buffer
 * 
 * @param buffer
 * @return String
 */
private String markdownToHtml(String buffer) {
    Parser parser = Parser.builder().build();
    Node document = parser.parse(buffer);
    HtmlRenderer renderer = HtmlRenderer.builder().build();
    String asHtml = renderer.render(document);
    return asHtml;
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:14,代码来源:MarkdownViewer.java

示例2: mdToHtml

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

示例3: htmlRendererTest

import org.commonmark.renderer.html.HtmlRenderer; //导入方法依赖的package包/类
@Test
public void htmlRendererTest() throws Exception {
    Parser parser = Parser.builder().build();
    HtmlRenderer renderer = HtmlRenderer.builder().build();

    String renderedString = renderer.render(parser.parse(spec));

    assertNotNull(renderedString);
}
 
开发者ID:atlassian,项目名称:commonmark-java,代码行数:10,代码来源:AndroidSupportTest.java

示例4: parseWithExtensionsTest

import org.commonmark.renderer.html.HtmlRenderer; //导入方法依赖的package包/类
private void parseWithExtensionsTest(Extension extension) throws Exception {
    Parser parser = Parser.builder()
            .extensions(Collections.singletonList(extension))
            .build();

    Node document = parser.parse(spec);
    assertNotNull(document);

    HtmlRenderer renderer = HtmlRenderer.builder()
            .extensions(Collections.singletonList(extension))
            .build();

    String renderedString = renderer.render(document);
    assertNotNull(renderedString);
}
 
开发者ID:atlassian,项目名称:commonmark-java,代码行数:16,代码来源:AndroidSupportTest.java

示例5: attributeProviderIsApplied

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

示例6: parseMarkdown2html

import org.commonmark.renderer.html.HtmlRenderer; //导入方法依赖的package包/类
public static String parseMarkdown2html(String markdown){
    Parser parser = Parser.builder().build();
    Node document = parser.parse(markdown);
    HtmlRenderer renderer = HtmlRenderer.builder().build();

    return renderer.render(document);
}
 
开发者ID:happut,项目名称:feihome,代码行数:8,代码来源:MarkdownUtils.java

示例7: sendEmail

import org.commonmark.renderer.html.HtmlRenderer; //导入方法依赖的package包/类
private void sendEmail(String to, String name, Card createdCard, Board board, ProjectMailTicketConfig config, ProjectMailTicket ticketConfig) {
    String cardId = board.getShortName() + "-" + createdCard.getSequence();
    String subjectTemplate = "" + (ticketConfig.getNotificationOverride() ? ticketConfig.getSubject() : config.getSubject());
    String bodyTemplate = "" + (ticketConfig.getNotificationOverride() ? ticketConfig.getBody() : config.getBody());

    String subject = subjectTemplate.replaceAll("\\{\\{card}}", cardId);
    String body = bodyTemplate.replaceAll("\\{\\{card}}", cardId).replaceAll("\\{\\{name}}", name != null ? name : to);

    Parser parser = Parser.builder().build();
    Node document = parser.parse(body);
    HtmlRenderer htmlRenderer = HtmlRenderer.builder().build();
    TextContentRenderer textRendered = TextContentRenderer.builder().build();

    String htmlText = htmlRenderer.render(document);
    String plainText = textRendered.render(document);


    ProjectMailTicketConfigData configData = config.getConfig();
    MailConfig mailConfig = new MailConfig(configData.getOutboundServer(),
        configData.getOutboundPort(),
        configData.getOutboundProtocol(),
        configData.getOutboundUser(),
        configData.getOutboundPassword(),
        ticketConfig.getSendByAlias() ? ticketConfig.getAlias() : configData.getOutboundAddress(),
        configData.getOutboundProperties());

    mailConfig.send(to, subject, plainText, htmlText);
}
 
开发者ID:digitalfondue,项目名称:lavagna,代码行数:29,代码来源:MailTicketService.java

示例8: process

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

示例9: useCommonMark

import org.commonmark.renderer.html.HtmlRenderer; //导入方法依赖的package包/类
private String useCommonMark(String text) {
	Parser parser = Parser.builder().build();
	Node document = parser.parse(text);
	HtmlRenderer renderer = HtmlRenderer.builder().build();
	return renderer.render(document);
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:7,代码来源:FluentMkConverter.java

示例10: doRender

import org.commonmark.renderer.html.HtmlRenderer; //导入方法依赖的package包/类
private String doRender(HtmlRenderer renderer, String text) {
    return renderer.render(PARSER.parse(text));
}
 
开发者ID:atlassian,项目名称:commonmark-java,代码行数:4,代码来源:HeadingAnchorConfigurationTest.java

示例11: processCommonMark

import org.commonmark.renderer.html.HtmlRenderer; //导入方法依赖的package包/类
private String processCommonMark(String source) {
  Parser parser = Parser.builder().build();
  Node document = parser.parse(source);
  HtmlRenderer renderer = HtmlRenderer.builder().build();
  return renderer.render(document);  
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:7,代码来源:MarkDownProcessor.java

示例12: getHTMLUserGuide

import org.commonmark.renderer.html.HtmlRenderer; //导入方法依赖的package包/类
private String getHTMLUserGuide() {

        StringBuilder result = new StringBuilder();

        try(InputStream stream = CloudTrailViewer.class.getResourceAsStream("/docs/UserGuide.md")) {

            if (stream != null) {

                InputStreamReader io = new InputStreamReader(stream);
                BufferedReader br = new BufferedReader(io);

                String line;
                while ((line = br.readLine()) != null) {
                    result.append(line).append("\n");
                }

                Parser parser = Parser.builder().build();
                Node document = parser.parse(result.toString());
                HtmlRenderer renderer = HtmlRenderer.builder().build();

                return renderer.render(document);

            } else {
                DialogUtils.showAlertDialog("CloudTrail Viewer", "Application Error", "Unable to load User Guide.", Alert.AlertType.ERROR);
                return null;
            }

        } catch (IOException ioe) {

            DialogUtils.showAlertDialog("CloudTrail Viewer", "Application Error", "Unable to load User Guide.", Alert.AlertType.ERROR);
            return null;
        }

    }
 
开发者ID:githublemming,项目名称:CloudTrailViewer,代码行数:35,代码来源:HelpMenuController.java


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