From 85a1256b24b9bda43ee9a2ad44fdbdff170a6080 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 2 Oct 2019 14:49:57 +1000 Subject: [PATCH] fix issues importing markdown into heirarchical tables --- .../xhtml/HierarchicalTableGenerator.java | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) 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 249409004..8f320c390 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 @@ -229,19 +229,46 @@ public class HierarchicalTableGenerator extends TranslatingUtilities { } return this; } - private List htmlToParagraphPieces(String html) throws IOException, FHIRException { + + private List htmlToParagraphPieces(String html) { List myPieces = new ArrayList(); - String[] paragraphs = html.replace("

", "").split("<\\/p>|
"); - for (int i=0;i"+html+""); + boolean first = true; + for (XhtmlNode c : node.getChildNodes()) { + if (first) { + first = false; + } else { myPieces.add(new Piece("br")); + myPieces.add(new Piece("br")); + } + if (c.getNodeType() == NodeType.Text) { + if (!Utilities.isWhitespace(c.getContent())) + addNode(myPieces, c); + } else if ("p".equals(c.getName())) { + for (XhtmlNode g : c.getChildNodes()) { + addNode(myPieces, g); + } + } else { + Piece x = new Piece(c.getName()); + x.getChildren().addAll(c.getChildNodes()); + myPieces.add(x); } - myPieces.addAll(htmlFormattingToPieces(paragraphs[i])); } +// String[] paragraphs = html.replace("

", "").split("<\\/p>|
"); +// for (int i=0;i