more work on forcing valid html generation
This commit is contained in:
parent
f9ed8dc348
commit
71e8a8294a
|
@ -233,7 +233,7 @@ public class NarrativeGenerationTests {
|
|||
@ParameterizedTest(name = "{index}: file {0}")
|
||||
@MethodSource("data")
|
||||
public void test(String id, TestDetails test) throws Exception {
|
||||
XhtmlNode.setCheckPara(true);
|
||||
XhtmlNode.setCheckParaGeneral(true);
|
||||
if (test.getRegister() != null) {
|
||||
if (test.getRegister().endsWith(".json")) {
|
||||
context.cacheResource(new JsonParser().parse(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getRegister())));
|
||||
|
|
|
@ -157,6 +157,7 @@ public class I18nConstants {
|
|||
public static final String CONCEPTMAP_SHAREABLE_MISSING = "CONCEPTMAP_SHAREABLE_MISSING";
|
||||
public static final String CONCEPTMAP_SHAREABLE_MISSING_HL7 = "CONCEPTMAP_SHAREABLE_MISSING_HL7";
|
||||
public static final String CONCEPTMAP_VS_CONCEPT_CODE_UNKNOWN_SYSTEM = "CONCEPTMAP_VS_CONCEPT_CODE_UNKNOWN_SYSTEM";
|
||||
public static final String CONCEPTMAP_VS_CONCEPT_CODE_UNKNOWN_SYSTEM_VERSION = "CONCEPTMAP_VS_CONCEPT_CODE_UNKNOWN_SYSTEM_VERSION";
|
||||
public static final String CONCEPTMAP_VS_INVALID_CONCEPT_CODE = "CONCEPTMAP_VS_INVALID_CONCEPT_CODE";
|
||||
public static final String CONCEPTMAP_VS_INVALID_CONCEPT_CODE_VER = "CONCEPTMAP_VS_INVALID_CONCEPT_CODE_VER";
|
||||
public static final String CONCEPTMAP_VS_TOO_MANY_CODES = "CONCEPTMAP_VS_TOO_MANY_CODES";
|
||||
|
|
|
@ -72,7 +72,9 @@ public class XhtmlNode extends XhtmlFluent implements IBaseXhtml {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean checkPara = false;
|
||||
private static boolean checkParaGeneral = false;
|
||||
private boolean checkParaTree = false;
|
||||
|
||||
public static final String NBSP = Character.toString((char)0xa0);
|
||||
public static final String XMLNS = "http://www.w3.org/1999/xhtml";
|
||||
private static final String DECL_XMLNS = " xmlns=\""+XMLNS+"\"";
|
||||
|
@ -91,6 +93,7 @@ public class XhtmlNode extends XhtmlFluent implements IBaseXhtml {
|
|||
|
||||
public XhtmlNode() {
|
||||
super();
|
||||
checkParaTree = checkParaGeneral;
|
||||
}
|
||||
|
||||
|
||||
|
@ -119,7 +122,7 @@ public class XhtmlNode extends XhtmlFluent implements IBaseXhtml {
|
|||
|
||||
public XhtmlNode setName(String name) {
|
||||
assert name.contains(":") == false : "Name should not contain any : but was " + name;
|
||||
if (checkPara && "p".equals(name)) {
|
||||
if (checkParaTree && "p".equals(name)) {
|
||||
isInPara = true;
|
||||
}
|
||||
this.name = name;
|
||||
|
@ -1160,7 +1163,8 @@ public class XhtmlNode extends XhtmlFluent implements IBaseXhtml {
|
|||
|
||||
|
||||
private void checkWhenAddingNode(XhtmlNode node) {
|
||||
if (checkPara) {
|
||||
node.checkParaTree = checkParaTree;
|
||||
if (checkParaTree) {
|
||||
if (isInPara) {
|
||||
if (Utilities.existsInList(node.name, "div", "blockquote", "table", "ol", "ul", "p")) {
|
||||
throw new Error("Error: attempt to add "+node.name+" inside an html paragraph");
|
||||
|
@ -1176,13 +1180,23 @@ public class XhtmlNode extends XhtmlFluent implements IBaseXhtml {
|
|||
}
|
||||
|
||||
|
||||
public static boolean isCheckPara() {
|
||||
return checkPara;
|
||||
public static boolean isCheckParaGeneral() {
|
||||
return checkParaGeneral;
|
||||
}
|
||||
|
||||
|
||||
public static void setCheckPara(boolean checkPara) {
|
||||
XhtmlNode.checkPara = checkPara;
|
||||
public static void setCheckParaGeneral(boolean checkParaGeneral) {
|
||||
XhtmlNode.checkParaGeneral = checkParaGeneral;
|
||||
}
|
||||
|
||||
|
||||
public boolean isCheckParaTree() {
|
||||
return checkParaTree;
|
||||
}
|
||||
|
||||
|
||||
public void setCheckParaTree(boolean checkParaTree) {
|
||||
this.checkParaTree = checkParaTree;
|
||||
}
|
||||
|
||||
}
|
|
@ -500,6 +500,7 @@ public class XhtmlParser {
|
|||
if ((entryName != null) && !n.getName().equals(entryName))
|
||||
throw new FHIRFormatError("Unable to Parse HTML - starts with '"+n+"' not '"+entryName+"'"+descLoc());
|
||||
XhtmlNode root = result.addTag(n.getName());
|
||||
root.setCheckParaTree(false);
|
||||
root.setLocation(markLocation());
|
||||
parseAttributes(root);
|
||||
markLocation();
|
||||
|
|
Loading…
Reference in New Issue