css_inline 0.10.4 → 0.11.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: 74d59e5067f2add7bdfaba4cfa4996d23228930b37f9291765b1f67bd76bacc2
4
- data.tar.gz: 3dc31eb7364324ecc3de397dc8a2dd7fedb406a64c1160b5766b42fc4a824a1c
3
+ metadata.gz: 9981543156cb7af7056bb0c45006d3c79c189776131e9dd5af6a9aa7c483363b
4
+ data.tar.gz: 1bff0d8098d0d4f82c8e4b8fd6b82aad2a133e9c256ee57c43d2f304f5b6608e
5
5
  SHA512:
6
- metadata.gz: e283837727353d4ce91e2d60d42cdaf7000103ea8cbc6ea83330e217a60d2572953eb6501c84376d0430be199d2dfba84213d44decb89621f6ab63189925f69d
7
- data.tar.gz: 509885e47fb391530e675ff8c1e026348558ead1dcaab1361f52f039fe2d1d67f808d652b770213d12649cc88ba8f3db3f5a93b5e4a8653cd83817a7af1bee35
6
+ metadata.gz: b43e88f43f500f043f27c3c9b9acae15053ef4db67abbe46ef58d311905c355712e49f1338f09dea91715f4ea2a60864fec2dfd6727be62f87d15c2d266c88fe
7
+ data.tar.gz: 67a24501f324f2da19b169487b4f36421e6799d028a0e103fc16d5d61ca761c925608fcd732e7d2746565749ee504da94959461132f62420c0b28edf3b51e793
data/README.md CHANGED
@@ -88,12 +88,13 @@ inliner = CSSInline::CSSInliner.new(keep_style_tags: true)
88
88
  inliner.inline("...")
89
89
  ```
90
90
 
91
+ - `inline_style_tags`. Specifies whether to inline CSS from "style" tags. Default: `True`
91
92
  - `keep_style_tags`. Specifies whether to keep "style" tags after inlining. Default: `False`
92
93
  - `keep_link_tags`. Specifies whether to keep "link" tags after inlining. Default: `False`
93
94
  - `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`
94
95
  - `load_remote_stylesheets`. Specifies whether remote stylesheets should be loaded. Default: `True`
95
96
  - `extra_css`. Extra CSS to be inlined. Default: `nil`
96
- - `preallocate_node_capacity`. **Advanced**. Preallocates capacity for HTML nodes during parsing. This can improve performance when you have an estimate of the number of nodes in your HTML document. Default: `8`
97
+ - `preallocate_node_capacity`. **Advanced**. Preallocates capacity for HTML nodes during parsing. This can improve performance when you have an estimate of the number of nodes in your HTML document. Default: `32`
97
98
 
98
99
  You can also skip CSS inlining for an HTML tag by adding the `data-css-inline="ignore"` attribute to it:
99
100
 
@@ -132,15 +133,16 @@ inliner.inline("...")
132
133
  ## Performance
133
134
 
134
135
  Leveraging efficient tools from Mozilla's Servo project, this library delivers superior performance.
135
- It consistently outperforms `premailer`, offering speed increases often exceeding **40 times**.
136
+ It consistently outperforms `premailer`, offering speed increases often exceeding **50 times**.
136
137
 
137
138
  The table below provides a detailed comparison between `css_inline` and `premailer` when inlining CSS into an HTML document (like in the Usage section above):
138
139
 
139
- | | `css_inline 0.10.4` | `premailer 1.21.0 with Nokogiri 1.15.2` | Difference |
140
- |-------------------|---------------------|------------------------------------------------|------------|
141
- | Basic usage | 8.73 µs | 421.40 µs | **48.24x** |
142
- | Realistic email 1 | 172.71 µs | 9.77 ms | **56.62x** |
143
- | Realistic email 2 | 128.53 µs | Error: Cannot parse 0 calc((100% - 500px) / 2) | - |
140
+ | | Size | `css_inline 0.10.4` | `premailer 1.21.0 with Nokogiri 1.15.2` | Difference |
141
+ |-------------------|---------|---------------------|------------------------------------------------|------------|
142
+ | Basic usage | 230 B | 8.05 µs | 419.75 µs | **52.13x** |
143
+ | Realistic email 1 | 8.58 KB | 164.22 µs | 9.75 ms | **59.40x** |
144
+ | Realistic email 2 | 4.3 KB | 106.95 µs | Error: Cannot parse 0 calc((100% - 500px) / 2) | - |
145
+ | GitHub Page | 1.81 MB | 308.11 ms | 3.08 s | **9.99x** |
144
146
 
145
147
  Please refer to the `test/bench.rb` file to review the benchmark code.
146
148
  The results displayed above were measured using stable `rustc 1.71.1` on Ruby `3.2.2`.
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "css-inline-ruby"
3
- version = "0.10.4"
3
+ version = "0.11.0"
4
4
  authors = ["Dmitry Dygalo <dmitry@dygalo.dev>"]
5
5
  edition = "2021"
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.61"
12
+ rust-version = "1.63"
13
13
 
14
14
  [lib]
15
15
  name = "css_inline"
@@ -45,6 +45,7 @@ fn parse_options<Req>(
45
45
  _,
46
46
  (),
47
47
  (
48
+ Option<bool>,
48
49
  Option<bool>,
49
50
  Option<bool>,
50
51
  Option<String>,
@@ -57,6 +58,7 @@ fn parse_options<Req>(
57
58
  args.keywords,
58
59
  &[],
59
60
  &[
61
+ "inline_style_tags",
60
62
  "keep_style_tags",
61
63
  "keep_link_tags",
62
64
  "base_url",
@@ -67,12 +69,13 @@ fn parse_options<Req>(
67
69
  )?;
68
70
  let kwargs = kwargs.optional;
69
71
  Ok(rust_inline::InlineOptions {
70
- keep_style_tags: kwargs.0.unwrap_or(false),
71
- keep_link_tags: kwargs.1.unwrap_or(false),
72
- base_url: parse_url(kwargs.2)?,
73
- load_remote_stylesheets: kwargs.3.unwrap_or(true),
74
- extra_css: kwargs.4.map(Cow::Owned),
75
- preallocate_node_capacity: kwargs.5.unwrap_or(8),
72
+ inline_style_tags: kwargs.0.unwrap_or(true),
73
+ keep_style_tags: kwargs.1.unwrap_or(false),
74
+ keep_link_tags: kwargs.2.unwrap_or(false),
75
+ base_url: parse_url(kwargs.3)?,
76
+ load_remote_stylesheets: kwargs.4.unwrap_or(true),
77
+ extra_css: kwargs.5.map(Cow::Owned),
78
+ preallocate_node_capacity: kwargs.6.unwrap_or(32),
76
79
  })
77
80
  }
78
81
 
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.10.4
4
+ version: 0.11.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: 2023-08-11 00:00:00.000000000 Z
11
+ date: 2023-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -123,8 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: 3.3.26
125
125
  requirements:
126
- - Rust >= 1.61.0
127
- rubygems_version: 3.4.18
126
+ - Rust >= 1.63
127
+ rubygems_version: 3.4.19
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: High-performance library for inlining CSS into HTML 'style' attributes