gulp-inline-css
gulp-inline-css copied to clipboard
Not preserving XHTML
I'm attempting to use this to inline styles in an XSL template. In order for the XSLT processor to operate correctly, it requires strict XHTML with proper closing tags. For example:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Becomes
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Without the closing tag. This is not legal XML, therefore fails processing.
Is there a way to output as XHTML with closing tags everywhere?
No, not currently. It would require significant changes to the codebase.
@jonkemp Could you point out roughly what would have to change to prevent this library from invalidates our XML so we can come up with a pull request?
@yn5 well, this plugin doesn't actually handle transforming the output. It goes through another module called inline-css.
https://github.com/jonkemp/inline-css
inline-css uses cheerio to do the html parsing, and cheerio uses another module called htmlparser2. If the issue is the XML being mangled then I would look there. htmlparser2 says it can handle XML.
https://github.com/cheeriojs/cheerio https://github.com/fb55/htmlparser2/
I use gulp-htmltidy for emails to convert HTML to XHTML again with this doctype option:
export function build() {
return src("temp/*.html")
.pipe(plugins.inlineCss())
.pipe(plugins.htmltidy({
doctype: "Transitional",
hideComments: false,
indent: false
}))
.pipe(plugins.htmlBeautify())
.pipe(dest("dist/"));
}