css_inline 0.23.1 → 0.25.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a6d9890334533f3c323b4035c9c6284512d5343af3eb6e8b7fd1180c086b25f
4
- data.tar.gz: ffcfe2dfe78b198a2214337cbd2de034b06a21e3fab7614551668e2b39070e1a
3
+ metadata.gz: c4e01ba7b32825f524ebea632f191fead2e634a870435606632b6f5397d07c98
4
+ data.tar.gz: 4ea255343e0fc9ece7ce88e8b23b1ca7a94385ee689cf498d73ecf4ea1db21fb
5
5
  SHA512:
6
- metadata.gz: f63528f54aeca352d5bb2f843f136dfba65baaa6227cf138dd7cbf96d9a7dba94614337d2c946126a761480eb1365be5e7fa014b34468a28ad86c76dddbb7370
7
- data.tar.gz: fd50571a5e2a4aaa11c20a67381730238df21e263e87e1b9b73a0c6165a1b3e1f6c38ec610b62817fe17b8d9a7698a5973f3c6d63ac1de95486540304ca22cbd
6
+ metadata.gz: 48d57f08f5a27aecfec67e50c33095c13234cec05aac5f9f040818057a102b12a292b5a644ed76a474d7f46d3dfb54108a1610fc4fc334d9ae828b3c919bf0fa
7
+ data.tar.gz: cfb46ddc6b9615d4835054ec06b13cd7cc5cc80384d438b52be1fd8deb9b03f44a3158e65227e8fc3cd29c8f3055c6909d77521cf9f9b82c700e5cb710d8980d
data/README.md CHANGED
@@ -3,7 +3,6 @@
3
3
  [<img alt="build status" src="https://img.shields.io/github/actions/workflow/status/Stranger6667/css-inline/build.yml?style=flat-square&labelColor=555555&logo=github" height="20">](https://github.com/Stranger6667/css-inline/actions/workflows/build.yml)
4
4
  [<img alt="ruby gems" src="https://img.shields.io/gem/v/css_inline?logo=ruby&style=flat-square" height="20">](https://rubygems.org/gems/css_inline)
5
5
  [<img alt="codecov.io" src="https://img.shields.io/codecov/c/gh/Stranger6667/css-inline?logo=codecov&style=flat-square&token=tOzvV4kDY0" height="20">](https://app.codecov.io/github/Stranger6667/css-inline)
6
- [<img alt="gitter" src="https://img.shields.io/gitter/room/Stranger6667/css-inline?style=flat-square" height="20">](https://gitter.im/Stranger6667/css-inline)
7
6
 
8
7
  `css_inline` moves CSS from `<style>` and `<link>` tags into HTML `style` attributes.
9
8
  Use it to prepare HTML emails or to embed HTML into third-party web pages.
@@ -151,7 +150,7 @@ The module functions accept the same keyword arguments, for example `CSSInline.i
151
150
  - `inline_style_tags`. Inline CSS from `style` tags. Default: `true`
152
151
  - `keep_style_tags`. Keep `style` tags after inlining. Default: `false`
153
152
  - `keep_link_tags`. Keep `link` tags after inlining. Default: `false`
154
- - `keep_at_rules`. Keep at-rules (starting with `@`) after inlining. Default: `false`
153
+ - `keep_at_rules`. Keep at-rules (starting with `@`) after inlining. Errors in fragment inlining. Default: `false`
155
154
  - `minify_css`. Remove trailing semicolons and spaces between properties and values. Default: `false`
156
155
  - `base_url`. Base URL for resolving relative URLs. Use the `file://` scheme to load stylesheets from the filesystem. Default: `nil`
157
156
  - `load_remote_stylesheets`. Load stylesheets from `link` tags, over the network or from `file://` paths. Default: `true`
@@ -162,6 +161,9 @@ The module functions accept the same keyword arguments, for example `CSSInline.i
162
161
  - `apply_width_attributes`. Add `width` HTML attributes from CSS `width` properties on `table`, `td`, `th` and `img`. Default: `false`
163
162
  - `apply_height_attributes`. Add `height` HTML attributes from CSS `height` properties on `table`, `td`, `th` and `img`. Default: `false`
164
163
  - `resolve_css_variables`. Replace `var()` references with the values of the custom properties they refer to and drop the `--*` declarations. Default: `false`
164
+ - `media_type`. Inline rules from `@media` blocks whose query lists this media type or `all`, e.g. `@media print` or `@media screen, print` for `print`. Queries with media features, such as `print and (min-width: 600px)`, never apply. An inlined block is not kept as an at-rule. Ignored when `keep_at_rules` is enabled and `inline_style_tags` is disabled. Default: `nil`
165
+ - `keep_classes`. Keep `class` attributes in the output. When disabled, class selectors in kept `<style>` blocks and at-rules match nothing. Default: `true`
166
+ - `remove_unused_at_rules`. Remove rules that match no element from kept at-rules (`@media`, `@supports`, ...), along with blocks left empty. Needs `keep_at_rules` or `remove_inlined_selectors`. Matching ignores `:hover`, `::before` and similar. This also removes rules that target markup injected by an email client (e.g. Gmail's `u ~ div .x`). Default: `false`
165
167
 
166
168
  To skip CSS inlining for an HTML tag, add the `data-css-inline="ignore"` attribute to it:
167
169
 
@@ -11,6 +11,12 @@ dependencies = [
11
11
  "memchr",
12
12
  ]
13
13
 
14
+ [[package]]
15
+ name = "allocator-api2"
16
+ version = "0.2.21"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
19
+
14
20
  [[package]]
15
21
  name = "atomic-waker"
16
22
  version = "1.1.2"
@@ -154,9 +160,9 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
154
160
 
155
161
  [[package]]
156
162
  name = "css-inline"
157
- version = "0.23.1"
163
+ version = "0.25.0"
158
164
  source = "registry+https://github.com/rust-lang/crates.io-index"
159
- checksum = "c357d136b76b660cf6024f37871b9c39f4f31e63cc7e548c81579cae22bbd45b"
165
+ checksum = "d6e74c3b82760bba679830a24c099276d77873f55095e2dc047be13cf188546c"
160
166
  dependencies = [
161
167
  "cssparser",
162
168
  "hashbrown",
@@ -175,7 +181,7 @@ dependencies = [
175
181
 
176
182
  [[package]]
177
183
  name = "css-inline-ruby"
178
- version = "0.23.1"
184
+ version = "0.25.0"
179
185
  dependencies = [
180
186
  "css-inline",
181
187
  "magnus",
@@ -258,6 +264,12 @@ version = "1.15.0"
258
264
  source = "registry+https://github.com/rust-lang/crates.io-index"
259
265
  checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
260
266
 
267
+ [[package]]
268
+ name = "equivalent"
269
+ version = "1.0.3"
270
+ source = "registry+https://github.com/rust-lang/crates.io-index"
271
+ checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
272
+
261
273
  [[package]]
262
274
  name = "fastrand"
263
275
  version = "2.3.0"
@@ -357,6 +369,8 @@ version = "0.17.1"
357
369
  source = "registry+https://github.com/rust-lang/crates.io-index"
358
370
  checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
359
371
  dependencies = [
372
+ "allocator-api2",
373
+ "equivalent",
360
374
  "foldhash",
361
375
  ]
362
376
 
@@ -1076,9 +1090,9 @@ dependencies = [
1076
1090
 
1077
1091
  [[package]]
1078
1092
  name = "rustls"
1079
- version = "0.23.45"
1093
+ version = "0.23.46"
1080
1094
  source = "registry+https://github.com/rust-lang/crates.io-index"
1081
- checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634"
1095
+ checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf"
1082
1096
  dependencies = [
1083
1097
  "once_cell",
1084
1098
  "ring",
@@ -1202,13 +1216,14 @@ dependencies = [
1202
1216
 
1203
1217
  [[package]]
1204
1218
  name = "selectors"
1205
- version = "0.41.0"
1219
+ version = "0.43.0"
1206
1220
  source = "registry+https://github.com/rust-lang/crates.io-index"
1207
- checksum = "8322aebea94a6cc288ff884e8a49bdbceef60206c400c6c46d22e62fc4fd91a6"
1221
+ checksum = "474a2075f58859e8482495e1a2ae9634754ee383ad09a3c4093b8d9a51910fa3"
1208
1222
  dependencies = [
1209
1223
  "bitflags",
1210
1224
  "cssparser",
1211
1225
  "derive_more",
1226
+ "hashbrown",
1212
1227
  "log",
1213
1228
  "new_debug_unreachable",
1214
1229
  "precomputed-hash",
@@ -1261,9 +1276,9 @@ dependencies = [
1261
1276
 
1262
1277
  [[package]]
1263
1278
  name = "servo_arc"
1264
- version = "0.5.0"
1279
+ version = "0.6.0"
1265
1280
  source = "registry+https://github.com/rust-lang/crates.io-index"
1266
- checksum = "b4eceb519ec34d8290aaf6e46f435102f2bfa63f22b05a144fb16ab266d3b198"
1281
+ checksum = "9f121f129345b5201873a0e253f630413d750b9d799613e2873fb768e592c2a7"
1267
1282
  dependencies = [
1268
1283
  "stable_deref_trait",
1269
1284
  ]
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "css-inline-ruby"
3
- version = "0.23.1"
3
+ version = "0.25.0"
4
4
  authors = ["Dmitry Dygalo <dmitry@dygalo.dev>"]
5
5
  edition = "2024"
6
6
  readme = "README.rdoc"
@@ -9,7 +9,7 @@ repository = "https://github.com/Stranger6667/css-inline"
9
9
  keywords = ["css", "html", "email", "stylesheet", "inlining"]
10
10
  categories = ["web-programming"]
11
11
  license = "MIT"
12
- rust-version = "1.85"
12
+ rust-version = "1.88"
13
13
 
14
14
  [lib]
15
15
  name = "css_inline"
@@ -21,7 +21,7 @@ magnus = "0.9"
21
21
  rayon = "1"
22
22
 
23
23
  [dependencies.css-inline]
24
- version = "0.23.1"
24
+ version = "0.25.0"
25
25
  default-features = false
26
26
  features = ["http", "file", "stylesheet-cache"]
27
27
 
data/src/lib.rs CHANGED
@@ -76,6 +76,12 @@ struct Options {
76
76
  /// Substitute `var()` references with the values of the custom properties they refer to
77
77
  /// and drop the `--*` declarations from the inlined styles.
78
78
  resolve_css_variables: Option<bool>,
79
+ /// Inline rules from `@media` blocks that apply to this media type.
80
+ media_type: Option<String>,
81
+ /// Keep `class` attributes in the output.
82
+ keep_classes: Option<bool>,
83
+ /// Remove rules that match no element from the conditional at-rules (`@media`, `@supports`, ...) kept in the output.
84
+ remove_unused_at_rules: Option<bool>,
79
85
  }
80
86
 
81
87
  impl TryConvert for Options {
@@ -103,6 +109,10 @@ impl TryConvert for Options {
103
109
  .aref::<_, Option<bool>>(ruby.to_symbol("apply_height_attributes"))?,
104
110
  resolve_css_variables: h
105
111
  .aref::<_, Option<bool>>(ruby.to_symbol("resolve_css_variables"))?,
112
+ media_type: h.aref::<_, Option<String>>(ruby.to_symbol("media_type"))?,
113
+ keep_classes: h.aref::<_, Option<bool>>(ruby.to_symbol("keep_classes"))?,
114
+ remove_unused_at_rules: h
115
+ .aref::<_, Option<bool>>(ruby.to_symbol("remove_unused_at_rules"))?,
106
116
  })
107
117
  }
108
118
  }
@@ -129,6 +139,9 @@ fn parse_options<Req>(
129
139
  apply_width_attributes: kwargs.apply_width_attributes.unwrap_or(false),
130
140
  apply_height_attributes: kwargs.apply_height_attributes.unwrap_or(false),
131
141
  resolve_css_variables: kwargs.resolve_css_variables.unwrap_or(false),
142
+ media_type: kwargs.media_type,
143
+ keep_classes: kwargs.keep_classes.unwrap_or(true),
144
+ remove_unused_at_rules: kwargs.remove_unused_at_rules.unwrap_or(false),
132
145
  })
133
146
  }
134
147
 
@@ -176,7 +189,8 @@ impl From<InlineErrorWrapper> for magnus::Error {
176
189
  rust_inline::InlineError::ParseError(message) => {
177
190
  magnus::Error::new(ruby.exception_arg_error(), message.to_string())
178
191
  }
179
- rust_inline::InlineError::MissingStyleSheet { .. } => {
192
+ rust_inline::InlineError::MissingStyleSheet { .. }
193
+ | rust_inline::InlineError::UnsupportedFragmentOption => {
180
194
  magnus::Error::new(ruby.exception_arg_error(), error.0.to_string())
181
195
  }
182
196
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css_inline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.1
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Dygalo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-27 00:00:00.000000000 Z
11
+ date: 2026-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys