hail2u / node-inlining

Inline external CSS files referenced by link element to the HTML file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inlining

Inline external CSS files referenced by link element to the HTML file.

SYNOPSIS

Sometimes we need to embed styles inline for an HTML email. This package reads an HTML file, extract all <link rel="stylesheet">, and embed inline. So, you can write HTML email same as normal HTML document.

If you have following HTML file:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Inlining</title>
    <link href="test.css" rel="stylesheet">
  </head>
  <body>
    <p class="test">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
  </body>
</html>

And following CSS file:

.test {
  color: green;
}

You will get this HTML code with this package:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Inlining</title>
  </head>
  <body>
    <p class="test" style="color:green;">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
  </body>
</html>

INSTALL

$ echo @hail2u:registry=https://npm.pkg.github.com >> .npmrc
$ npm install -g @hail2u/inlining

USAGE

$ inlining input.html > output.html

Use single dash for reading HTML from a standard input:

$ cat input.html | inlining - > output.html

LICENSE

MIT

About

Inline external CSS files referenced by link element to the HTML file


Languages

Language:HTML 65.6%Language:JavaScript 28.2%Language:CSS 6.2%