From 49fbc739fd3ad619224798566f184619d2407a62 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 29 Oct 2020 14:00:21 +1100 Subject: [PATCH] improved markdown support in table generator --- .../xhtml/HierarchicalTableGenerator.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/HierarchicalTableGenerator.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/HierarchicalTableGenerator.java index 8edbee65b..94e337d33 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/HierarchicalTableGenerator.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/HierarchicalTableGenerator.java @@ -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 htmlToParagraphPieces(String html) { List myPieces = new ArrayList(); try {