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.
- checksums.yaml +4 -4
- data/Cargo.lock +276 -351
- data/README.md +31 -2
- data/ext/css_inline/Cargo.lock +276 -351
- data/ext/css_inline/Cargo.toml +5 -5
- data/ext/css_inline/src/lib.rs +77 -52
- metadata +3 -3
data/README.md
CHANGED
|
@@ -135,6 +135,8 @@ inliner.inline("...")
|
|
|
135
135
|
- `inline_style_tags`. Specifies whether to inline CSS from "style" tags. Default: `true`
|
|
136
136
|
- `keep_style_tags`. Specifies whether to keep "style" tags after inlining. Default: `false`
|
|
137
137
|
- `keep_link_tags`. Specifies whether to keep "link" tags after inlining. Default: `false`
|
|
138
|
+
- `keep_at_rules`. Specifies whether to keep "at-rules" (starting with `@`) after inlining. Default: `false`
|
|
139
|
+
- `minify_css`. Specifies whether to remove trailing semicolons and spaces between properties and values. Default: `false`
|
|
138
140
|
- `base_url`. The base URL used to resolve relative URLs. If you'd like to load stylesheets from your filesystem, use the `file://` scheme. Default: `nil`
|
|
139
141
|
- `load_remote_stylesheets`. Specifies whether remote stylesheets should be loaded. Default: `true`
|
|
140
142
|
- `cache`. Specifies caching options for external stylesheets (for example, `StylesheetCache(size: 5)`). Default: `nil`
|
|
@@ -166,7 +168,8 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
|
|
|
166
168
|
```
|
|
167
169
|
|
|
168
170
|
Alternatively, you may keep `style` from being removed by using the `data-css-inline="keep"` attribute.
|
|
169
|
-
This is useful if you want to keep `@media` queries for responsive emails in separate `style` tags
|
|
171
|
+
This is useful if you want to keep `@media` queries for responsive emails in separate `style` tags.
|
|
172
|
+
Such tags will be kept in the resulting HTML even if the `keep_style_tags` option is set to `false`.
|
|
170
173
|
|
|
171
174
|
```html
|
|
172
175
|
<head>
|
|
@@ -178,7 +181,33 @@ This is useful if you want to keep `@media` queries for responsive emails in sep
|
|
|
178
181
|
</body>
|
|
179
182
|
```
|
|
180
183
|
|
|
181
|
-
|
|
184
|
+
Another possibility is to set `keep_at_rules` option to `true`. At-rules cannot be inlined into HTML therefore they
|
|
185
|
+
get removed by default. This is useful if you want to keep at-rules, e.g. `@media` queries for responsive emails in
|
|
186
|
+
separate `style` tags but inline any styles which can be inlined.
|
|
187
|
+
Such tags will be kept in the resulting HTML even if the `keep_style_tags` option is explicitly set to `false`.
|
|
188
|
+
|
|
189
|
+
```html
|
|
190
|
+
<head>
|
|
191
|
+
<!-- With keep_at_rules=true "color:blue" will get inlined into <h1> but @media will be kept in <style> -->
|
|
192
|
+
<style>h1 { color: blue; } @media (max-width: 600px) { h1 { font-size: 18px; } }</style>
|
|
193
|
+
</head>
|
|
194
|
+
<body>
|
|
195
|
+
<h1>Big Text</h1>
|
|
196
|
+
</body>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
If you set the the `minify_css` option to `true`, the inlined styles will be minified by removing trailing semicolons
|
|
200
|
+
and spaces between properties and values.
|
|
201
|
+
|
|
202
|
+
```html
|
|
203
|
+
<head>
|
|
204
|
+
<!-- With minify_css=true, the <h1> will have `style="color:blue;font-weight:bold"` -->
|
|
205
|
+
<style>h1 { color: blue; font-weight: bold; }</style>
|
|
206
|
+
</head>
|
|
207
|
+
<body>
|
|
208
|
+
<h1>Big Text</h1>
|
|
209
|
+
</body>
|
|
210
|
+
```
|
|
182
211
|
|
|
183
212
|
If you'd like to load stylesheets from your filesystem, use the `file://` scheme:
|
|
184
213
|
|