@css-inline/css-inline 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -2
- package/index.d.ts +15 -10
- package/js-binding.d.ts +4 -0
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -116,6 +116,8 @@ var inlined = inlineFragment(
|
|
|
116
116
|
- `inlineStyleTags`. Specifies whether to inline CSS from "style" tags. Default: `true`
|
|
117
117
|
- `keepStyleTags`. Specifies whether to keep "style" tags after inlining. Default: `false`
|
|
118
118
|
- `keepLinkTags`. Specifies whether to keep "link" tags after inlining. Default: `false`
|
|
119
|
+
- `keepAtRules`. Specifies whether to keep "at-rules" (starting with `@`) after inlining. Default: `false`
|
|
120
|
+
- `minifyCss`. Specifies whether to remove trailing semicolons and spaces between properties and values. Default: `false`
|
|
119
121
|
- `baseUrl`. The base URL used to resolve relative URLs. If you'd like to load stylesheets from your filesystem, use the `file://` scheme. Default: `null`
|
|
120
122
|
- `loadRemoteStylesheets`. Specifies whether remote stylesheets should be loaded. Default: `true`
|
|
121
123
|
- `cache`. Specifies caching options for external stylesheets (for example, `{size: 5}`). Default: `null`
|
|
@@ -148,7 +150,8 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
|
|
|
148
150
|
```
|
|
149
151
|
|
|
150
152
|
Alternatively, you may keep `style` from being removed by using the `data-css-inline="keep"` attribute.
|
|
151
|
-
This is useful if you want to keep `@media` queries for responsive emails in separate `style` tags
|
|
153
|
+
This is useful if you want to keep `@media` queries for responsive emails in separate `style` tags.
|
|
154
|
+
Such tags will be kept in the resulting HTML even if the `keep_style_tags` option is set to `false`.
|
|
152
155
|
|
|
153
156
|
```html
|
|
154
157
|
<head>
|
|
@@ -160,7 +163,33 @@ This is useful if you want to keep `@media` queries for responsive emails in sep
|
|
|
160
163
|
</body>
|
|
161
164
|
```
|
|
162
165
|
|
|
163
|
-
|
|
166
|
+
Another possibility is to set `keep_at_rules` option to `true`. At-rules cannot be inlined into HTML therefore they
|
|
167
|
+
get removed by default. This is useful if you want to keep at-rules, e.g. `@media` queries for responsive emails in
|
|
168
|
+
separate `style` tags but inline any styles which can be inlined.
|
|
169
|
+
Such tags will be kept in the resulting HTML even if the `keep_style_tags` option is explicitly set to `false`.
|
|
170
|
+
|
|
171
|
+
```html
|
|
172
|
+
<head>
|
|
173
|
+
<!-- With keep_at_rules=true "color:blue" will get inlined into <h1> but @media will be kept in <style> -->
|
|
174
|
+
<style>h1 { color: blue; } @media (max-width: 600px) { h1 { font-size: 18px; } }</style>
|
|
175
|
+
</head>
|
|
176
|
+
<body>
|
|
177
|
+
<h1>Big Text</h1>
|
|
178
|
+
</body>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
If you set the the `minify_css` option to `true`, the inlined styles will be minified by removing trailing semicolons
|
|
182
|
+
and spaces between properties and values.
|
|
183
|
+
|
|
184
|
+
```html
|
|
185
|
+
<head>
|
|
186
|
+
<!-- With minify_css=true, the <h1> will have `style="color:blue;font-weight:bold"` -->
|
|
187
|
+
<style>h1 { color: blue; font-weight: bold; }</style>
|
|
188
|
+
</head>
|
|
189
|
+
<body>
|
|
190
|
+
<h1>Big Text</h1>
|
|
191
|
+
</body>
|
|
192
|
+
```
|
|
164
193
|
|
|
165
194
|
You can also cache external stylesheets to avoid excessive network requests:
|
|
166
195
|
|
package/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
/** Inline CSS styles from <style> tags to matching elements in the HTML tree and return a string. */
|
|
4
|
+
export declare function inline(html: string, options?: Options | undefined | null): string
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
/** Inline CSS styles into an HTML fragment. */
|
|
7
|
+
export declare function inlineFragment(html: string, css: string, options?: Options | undefined | null): string
|
|
5
8
|
|
|
6
|
-
export interface StylesheetCache {
|
|
7
|
-
/** Cache size. */
|
|
8
|
-
size: number
|
|
9
|
-
}
|
|
10
9
|
export interface Options {
|
|
11
10
|
/**
|
|
12
11
|
* Whether to inline CSS from "style" tags.
|
|
@@ -19,6 +18,10 @@ export interface Options {
|
|
|
19
18
|
keepStyleTags?: boolean
|
|
20
19
|
/** Keep "link" tags after inlining. */
|
|
21
20
|
keepLinkTags?: boolean
|
|
21
|
+
/** Keep "at-rules" after inlining. */
|
|
22
|
+
keepAtRules?: boolean
|
|
23
|
+
/** Remove trailing semicolons and spaces between properties and values. */
|
|
24
|
+
minifyCss?: boolean
|
|
22
25
|
/** Used for loading external stylesheets via relative URLs. */
|
|
23
26
|
baseUrl?: string
|
|
24
27
|
/** Whether remote stylesheets should be loaded or not. */
|
|
@@ -33,9 +36,11 @@ export interface Options {
|
|
|
33
36
|
*/
|
|
34
37
|
preallocateNodeCapacity?: number
|
|
35
38
|
}
|
|
36
|
-
|
|
37
|
-
export
|
|
38
|
-
/**
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
export interface StylesheetCache {
|
|
41
|
+
/** Cache size. */
|
|
42
|
+
size: number
|
|
43
|
+
}
|
|
44
|
+
|
|
40
45
|
/** Get the package version. */
|
|
41
46
|
export declare function version(): string
|
package/js-binding.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ export interface Options {
|
|
|
19
19
|
keepStyleTags?: boolean
|
|
20
20
|
/** Keep "link" tags after inlining. */
|
|
21
21
|
keepLinkTags?: boolean
|
|
22
|
+
/** Keep "at-rules" after inlining. */
|
|
23
|
+
keepAtRules?: boolean
|
|
24
|
+
/** Remove trailing semicolons and spaces between properties and values. */
|
|
25
|
+
minifyCss?: boolean
|
|
22
26
|
/** Used for loading external stylesheets via relative URLs. */
|
|
23
27
|
baseUrl?: string
|
|
24
28
|
/** Whether remote stylesheets should be loaded or not. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@css-inline/css-inline",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "High-performance library for inlining CSS into HTML 'style' attributes",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "https://github.com/Stranger6667/css-inline",
|
|
@@ -99,16 +99,16 @@
|
|
|
99
99
|
},
|
|
100
100
|
"packageManager": "yarn@4.9.2",
|
|
101
101
|
"optionalDependencies": {
|
|
102
|
-
"@css-inline/css-inline-win32-x64-msvc": "0.
|
|
103
|
-
"@css-inline/css-inline-darwin-x64": "0.
|
|
104
|
-
"@css-inline/css-inline-linux-x64-gnu": "0.
|
|
105
|
-
"@css-inline/css-inline-darwin-arm64": "0.
|
|
106
|
-
"@css-inline/css-inline-android-arm64": "0.
|
|
107
|
-
"@css-inline/css-inline-win32-arm64-msvc": "0.
|
|
108
|
-
"@css-inline/css-inline-linux-arm64-gnu": "0.
|
|
109
|
-
"@css-inline/css-inline-linux-arm64-musl": "0.
|
|
110
|
-
"@css-inline/css-inline-linux-arm-gnueabihf": "0.
|
|
111
|
-
"@css-inline/css-inline-linux-x64-musl": "0.
|
|
112
|
-
"@css-inline/css-inline-android-arm-eabi": "0.
|
|
102
|
+
"@css-inline/css-inline-win32-x64-msvc": "0.18.0",
|
|
103
|
+
"@css-inline/css-inline-darwin-x64": "0.18.0",
|
|
104
|
+
"@css-inline/css-inline-linux-x64-gnu": "0.18.0",
|
|
105
|
+
"@css-inline/css-inline-darwin-arm64": "0.18.0",
|
|
106
|
+
"@css-inline/css-inline-android-arm64": "0.18.0",
|
|
107
|
+
"@css-inline/css-inline-win32-arm64-msvc": "0.18.0",
|
|
108
|
+
"@css-inline/css-inline-linux-arm64-gnu": "0.18.0",
|
|
109
|
+
"@css-inline/css-inline-linux-arm64-musl": "0.18.0",
|
|
110
|
+
"@css-inline/css-inline-linux-arm-gnueabihf": "0.18.0",
|
|
111
|
+
"@css-inline/css-inline-linux-x64-musl": "0.18.0",
|
|
112
|
+
"@css-inline/css-inline-android-arm-eabi": "0.18.0"
|
|
113
113
|
}
|
|
114
114
|
}
|