improved markdown support in table generator

This commit is contained in:
Grahame Grieve 2020-10-29 14:00:21 +11:00
parent 14cc22f9a2
commit 49fbc739fd
1 changed files with 14 additions and 0 deletions

View File

@ -240,6 +240,7 @@ public class HierarchicalTableGenerator extends TranslatingUtilities {
pieces.add(piece);
return this;
}
public Cell addMarkdown(String md) {
try {
Parser parser = Parser.builder().build();
@ -253,6 +254,19 @@ public class HierarchicalTableGenerator extends TranslatingUtilities {
return this;
}
public Cell addMarkdownNoPara(String md) {
try {
Parser parser = Parser.builder().build();
Node document = parser.parse(md);
HtmlRenderer renderer = HtmlRenderer.builder().escapeHtml(true).build();
String html = renderer.render(document);
pieces.addAll(htmlToParagraphPieces(html));
} catch (Exception e) {
e.printStackTrace();
}
return this;
}
private List<Piece> htmlToParagraphPieces(String html) {
List<Piece> myPieces = new ArrayList<Piece>();
try {