@css-inline/css-inline 0.16.0 → 0.17.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 +17 -2
- package/index.d.ts +13 -10
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -116,6 +116,7 @@ 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`
|
|
119
120
|
- `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
121
|
- `loadRemoteStylesheets`. Specifies whether remote stylesheets should be loaded. Default: `true`
|
|
121
122
|
- `cache`. Specifies caching options for external stylesheets (for example, `{size: 5}`). Default: `null`
|
|
@@ -148,7 +149,8 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
|
|
|
148
149
|
```
|
|
149
150
|
|
|
150
151
|
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
|
|
152
|
+
This is useful if you want to keep `@media` queries for responsive emails in separate `style` tags.
|
|
153
|
+
Such tags will be kept in the resulting HTML even if the `keep_style_tags` option is set to `false`.
|
|
152
154
|
|
|
153
155
|
```html
|
|
154
156
|
<head>
|
|
@@ -160,7 +162,20 @@ This is useful if you want to keep `@media` queries for responsive emails in sep
|
|
|
160
162
|
</body>
|
|
161
163
|
```
|
|
162
164
|
|
|
163
|
-
|
|
165
|
+
Another possibility is to set `keep_at_rules` option to `true`. At-rules cannot be inlined into HTML therefore they
|
|
166
|
+
get removed by default. This is useful if you want to keep at-rules, e.g. `@media` queries for responsive emails in
|
|
167
|
+
separate `style` tags but inline any styles which can be inlined.
|
|
168
|
+
Such tags will be kept in the resulting HTML even if the `keep_style_tags` option is explicitly set to `false`.
|
|
169
|
+
|
|
170
|
+
```html
|
|
171
|
+
<head>
|
|
172
|
+
<!-- With keep_at_rules=true "color:blue" will get inlined into <h1> but @media will be kept in <style> -->
|
|
173
|
+
<style>h1 { color: blue; } @media (max-width: 600px) { h1 { font-size: 18px; } }</style>
|
|
174
|
+
</head>
|
|
175
|
+
<body>
|
|
176
|
+
<h1>Big Text</h1>
|
|
177
|
+
</body>
|
|
178
|
+
```
|
|
164
179
|
|
|
165
180
|
You can also cache external stylesheets to avoid excessive network requests:
|
|
166
181
|
|
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,8 @@ 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
|
|
22
23
|
/** Used for loading external stylesheets via relative URLs. */
|
|
23
24
|
baseUrl?: string
|
|
24
25
|
/** Whether remote stylesheets should be loaded or not. */
|
|
@@ -33,9 +34,11 @@ export interface Options {
|
|
|
33
34
|
*/
|
|
34
35
|
preallocateNodeCapacity?: number
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
export
|
|
38
|
-
/**
|
|
39
|
-
|
|
37
|
+
|
|
38
|
+
export interface StylesheetCache {
|
|
39
|
+
/** Cache size. */
|
|
40
|
+
size: number
|
|
41
|
+
}
|
|
42
|
+
|
|
40
43
|
/** Get the package version. */
|
|
41
44
|
export declare function version(): string
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@css-inline/css-inline",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.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.17.0",
|
|
103
|
+
"@css-inline/css-inline-darwin-x64": "0.17.0",
|
|
104
|
+
"@css-inline/css-inline-linux-x64-gnu": "0.17.0",
|
|
105
|
+
"@css-inline/css-inline-darwin-arm64": "0.17.0",
|
|
106
|
+
"@css-inline/css-inline-android-arm64": "0.17.0",
|
|
107
|
+
"@css-inline/css-inline-win32-arm64-msvc": "0.17.0",
|
|
108
|
+
"@css-inline/css-inline-linux-arm64-gnu": "0.17.0",
|
|
109
|
+
"@css-inline/css-inline-linux-arm64-musl": "0.17.0",
|
|
110
|
+
"@css-inline/css-inline-linux-arm-gnueabihf": "0.17.0",
|
|
111
|
+
"@css-inline/css-inline-linux-x64-musl": "0.17.0",
|
|
112
|
+
"@css-inline/css-inline-android-arm-eabi": "0.17.0"
|
|
113
113
|
}
|
|
114
114
|
}
|