Skip to content

Commit

Permalink
Update html-minifier options (#1002)
Browse files Browse the repository at this point in the history
- don't remove closing slash from tags like <br/> (since XHTML requires them)
- parse using HTML 4 instead of 5 since XHTML is more like HTML 4 than 5

Fixes #1001
  • Loading branch information
cmoesel authored Jan 5, 2022
1 parent 0ae2aac commit 2f6adfd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/fhirtypes/ElementDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,12 @@ export class ElementDefinition {
} else if (type == 'xhtml' && this.checkXhtml(value)) {
this.assignFHIRValue(`"${value}"`, value, exactly, type);
// If we got here, the assigned value is valid. Replace the XML with a minimized version.
this[exactly ? 'fixedXhtml' : 'patternXhtml'] = minify(value, { collapseWhitespace: true });
// For minimizer options, see: https://www.npmjs.com/package/html-minifier#options-quick-reference
this[exactly ? 'fixedXhtml' : 'patternXhtml'] = minify(value, {
collapseWhitespace: true,
html5: false,
keepClosingSlash: true
});
} else {
throw new MismatchedTypeError('string', value, type);
}
Expand Down

0 comments on commit 2f6adfd

Please sign in to comment.