gulp-inline-css icon indicating copy to clipboard operation
gulp-inline-css copied to clipboard

Not preserving XHTML

Open Saltallica opened this issue 9 years ago • 4 comments

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?

Saltallica avatar May 11 '15 20:05 Saltallica

No, not currently. It would require significant changes to the codebase.

jonkemp avatar May 12 '15 14:05 jonkemp

@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 avatar Sep 05 '16 14:09 yn5

@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/

jonkemp avatar Sep 05 '16 17:09 jonkemp

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/"));
}

BroFox86 avatar Jan 26 '20 21:01 BroFox86