use of org.pegdown.ToHtmlSerializer in project gerrit by GerritCodeReview.
the class MarkdownFormatter method markdownToDocHtml.
public byte[] markdownToDocHtml(String md, String charEnc) throws UnsupportedEncodingException {
RootNode root = parseMarkdown(md);
String title = findTitle(root);
StringBuilder html = new StringBuilder();
html.append("<html>");
html.append("<head>");
if (!Strings.isNullOrEmpty(title)) {
html.append("<title>").append(title).append("</title>");
}
html.append("<style type=\"text/css\">\n");
if (css != null) {
html.append(css);
} else {
html.append(readCSS());
}
html.append("\n</style>");
html.append("</head>");
html.append("<body>\n");
html.append(new ToHtmlSerializer(new LinkRenderer()).toHtml(root));
html.append("\n</body></html>");
return html.toString().getBytes(charEnc);
}
Aggregations