jonkemp / gulp-inline-css

Inline linked css in an html file. Useful for emails.
MIT License
272 stars 29 forks source link

Not preserving XHTML #22

Open Saltallica opened 9 years ago

Saltallica commented 9 years ago

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?

jonkemp commented 9 years ago

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

yn5 commented 8 years ago

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

jonkemp commented 8 years ago

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

BroFox86 commented 4 years ago

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