use of org.commonmark.renderer.html.HtmlRenderer in project lavagna by digitalfondue.
the class MailTicketService method sendEmail.
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);
}
use of org.commonmark.renderer.html.HtmlRenderer in project mdw-designer by CenturyLinkCloud.
the class MarkdownRenderer method renderHtml.
public String renderHtml() {
if (markdown == null || markdown.trim().isEmpty())
return "";
else {
Parser parser = Parser.builder().build();
Node document = parser.parse(markdown);
HtmlRenderer renderer = HtmlRenderer.builder().build();
return "<div style=\"height:100%;overflow:auto;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif\">" + renderer.render(document) + "</div>";
}
}
use of org.commonmark.renderer.html.HtmlRenderer in project MagiskManager by topjohnwu.
the class MarkDownWindow method doInBackground.
@Override
protected String doInBackground(Void... voids) {
MagiskManager mm = MagiskManager.get();
String md;
if (mUrl != null) {
md = WebService.getString(mUrl);
} else {
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
ShellUtils.pump(is, out);
md = out.toString();
is.close();
} catch (IOException e) {
e.printStackTrace();
return "";
}
}
String css;
try (InputStream in = mm.getResources().openRawResource(mm.isDarkTheme ? R.raw.dark : R.raw.light);
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
ShellUtils.pump(in, out);
css = out.toString();
in.close();
} catch (IOException e) {
e.printStackTrace();
return "";
}
Parser parser = Parser.builder().build();
HtmlRenderer renderer = HtmlRenderer.builder().build();
Node doc = parser.parse(md);
return String.format("<style>%s</style>%s", css, renderer.render(doc));
}
use of org.commonmark.renderer.html.HtmlRenderer in project tale by otale.
the class TaleUtils method mdToHtml.
/**
* markdown转换为html
*/
public static String mdToHtml(String markdown) {
if (StringKit.isBlank(markdown)) {
return "";
}
List<Extension> extensions = Collections.singletonList(TablesExtension.create());
Parser parser = Parser.builder().extensions(extensions).build();
Node document = parser.parse(markdown);
HtmlRenderer renderer = HtmlRenderer.builder().attributeProviderFactory(context -> new LinkAttributeProvider()).extensions(extensions).build();
String content = renderer.render(document);
content = Commons.emoji(content);
// 支持网易云音乐输出
if (TaleConst.BCONF.getBoolean(ENV_SUPPORT_163_MUSIC, true) && content.contains(MP3_PREFIX)) {
content = content.replaceAll(MUSIC_REG_PATTERN, MUSIC_IFRAME);
}
// 支持gist代码输出
if (TaleConst.BCONF.getBoolean(ENV_SUPPORT_GIST, true) && content.contains(GIST_PREFIX_URL)) {
content = content.replaceAll(GIST_REG_PATTERN, GIST_REPLATE_PATTERN);
}
return content;
}
use of org.commonmark.renderer.html.HtmlRenderer in project TOSCAna by StuPro-TOSCAna.
the class ReadmeBuilder method toString.
@Override
public String toString() {
Parser markdownParser = Parser.builder().build();
Node markdownDocument = markdownParser.parse(this.markdownText);
HtmlRenderer renderer = HtmlRenderer.builder().build();
return TEMPLATE.replace(README_TEMPLATE_TITLE_KEY, this.pageTitle).replace(README_TEMPLATE_BODY_KEY, renderer.render(markdownDocument));
}
Aggregations