css_inline 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc02b5a44a61e246ee0e04baa7d9c897809e7bcb3777e8b8cf1987d40d12835e
4
- data.tar.gz: 2f2bbd666aece18451648ba7404dcabffa7cc4ce5bbca67295281d0e0907032c
3
+ metadata.gz: ecc6091cab3a8511eb3e5135f0028488cb11eebcdcc64efaababbe404a154aff
4
+ data.tar.gz: e0c4874267b3455c13f04321a56c5ff526b903acdc517adafdb4a73731598339
5
5
  SHA512:
6
- metadata.gz: a2864e5df1bf930aa1f662acdfc3ce6e77e2c624cf858165fd2cfb37180e6a3123baad36acc57806652c1fe55de63e694ea520b6cf38eda3fd2bd2608361b1da
7
- data.tar.gz: df08a979dbc4e4c033f4ec99b73e6d6cedb1e8ec6c172a224fa54287a67b6cbfec5f2448900719ff6fccc756dfaffbcfb32012147978c70151ee78f6a13e2757
6
+ metadata.gz: 6c9d1fd5e9c7a81680e19ff417bdc57f815b22399887cf84441d4f03bf6ccd6ce7f96da6555054fddecc9a396de22f76a2e0705f3b3f030db6863994f5a3e8b3
7
+ data.tar.gz: c16c50735d1f2dc40691a1c74f9688147818a0d78005549df819044ad6beb0fc11339feb2faf7148c69f78b3dd44108e9cfd604a6904d4ec8953df5ead5f6049
data/README.md CHANGED
@@ -13,12 +13,12 @@ For instance, the library transforms HTML like this:
13
13
 
14
14
  ```html
15
15
  <html>
16
- <head>
17
- <style>h1 { color:blue; }</style>
18
- </head>
19
- <body>
20
- <h1>Big Text</h1>
21
- </body>
16
+ <head>
17
+ <style>h1 { color:blue; }</style>
18
+ </head>
19
+ <body>
20
+ <h1>Big Text</h1>
21
+ </body>
22
22
  </html>
23
23
  ```
24
24
 
@@ -26,10 +26,10 @@ into:
26
26
 
27
27
  ```html
28
28
  <html>
29
- <head></head>
30
- <body>
31
- <h1 style="color:blue;">Big Text</h1>
32
- </body>
29
+ <head></head>
30
+ <body>
31
+ <h1 style="color:blue;">Big Text</h1>
32
+ </body>
33
33
  </html>
34
34
  ```
35
35
 
@@ -41,6 +41,10 @@ into:
41
41
  - Works on Linux, Windows, and macOS
42
42
  - Supports HTML5 & CSS3
43
43
 
44
+ ## Playground
45
+
46
+ If you'd like to try `css-inline`, you can check the WebAssembly-powered [playground](https://css-inline.org/) to see the results instantly.
47
+
44
48
  ## Installation
45
49
 
46
50
  Add this line to your application's `Gemfile`:
@@ -100,11 +104,11 @@ You can also skip CSS inlining for an HTML tag by adding the `data-css-inline="i
100
104
 
101
105
  ```html
102
106
  <head>
103
- <style>h1 { color:blue; }</style>
107
+ <style>h1 { color:blue; }</style>
104
108
  </head>
105
109
  <body>
106
- <!-- The tag below won't receive additional styles -->
107
- <h1 data-css-inline="ignore">Big Text</h1>
110
+ <!-- The tag below won't receive additional styles -->
111
+ <h1 data-css-inline="ignore">Big Text</h1>
108
112
  </body>
109
113
  ```
110
114
 
@@ -112,11 +116,11 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
112
116
 
113
117
  ```html
114
118
  <head>
115
- <!-- Styles below are ignored -->
116
- <style data-css-inline="ignore">h1 { color:blue; }</style>
119
+ <!-- Styles below are ignored -->
120
+ <style data-css-inline="ignore">h1 { color:blue; }</style>
117
121
  </head>
118
122
  <body>
119
- <h1>Big Text</h1>
123
+ <h1>Big Text</h1>
120
124
  </body>
121
125
  ```
122
126
 
@@ -137,15 +141,15 @@ It consistently outperforms `premailer`, offering speed increases often exceedin
137
141
 
138
142
  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):
139
143
 
140
- | | Size | `css_inline 0.11.1` | `premailer 1.21.0 with Nokogiri 1.15.2` | Difference |
144
+ | | Size | `css_inline 0.11.2` | `premailer 1.21.0 with Nokogiri 1.15.2` | Difference |
141
145
  |-------------------|---------|---------------------|------------------------------------------------|------------|
142
- | Basic usage | 230 B | 8.23 µs | 415.18 µs | **50.93x** |
143
- | Realistic email 1 | 8.58 KB | 162.69 µs | 10.12 ms | **62.21x** |
144
- | Realistic email 2 | 4.3 KB | 116.01 µs | Error: Cannot parse 0 calc((100% - 500px) / 2) | - |
145
- | GitHub Page | 1.81 MB | 308.11 ms | 3.08 s | **9.99x** |
146
+ | Basic usage | 230 B | 8.27 µs | 433.55 µs | **52.35x** |
147
+ | Realistic email 1 | 8.58 KB | 159.20 µs | 9.88 ms | **62.10x** |
148
+ | Realistic email 2 | 4.3 KB | 103.41 µs | Error: Cannot parse 0 calc((100% - 500px) / 2) | - |
149
+ | GitHub Page | 1.81 MB | 301.66 ms | 3.08 s | **10.24x** |
146
150
 
147
151
  Please refer to the `test/bench.rb` file to review the benchmark code.
148
- The results displayed above were measured using stable `rustc 1.74.0` on Ruby `3.2.2`.
152
+ The results displayed above were measured using stable `rustc 1.74.1` on Ruby `3.2.2`.
149
153
 
150
154
  ## Ruby support
151
155
 
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "css-inline-ruby"
3
- version = "0.11.1"
3
+ version = "0.12.0"
4
4
  authors = ["Dmitry Dygalo <dmitry@dygalo.dev>"]
5
5
  edition = "2021"
6
6
  readme = "README.rdoc"
@@ -92,9 +92,10 @@ impl From<InlineErrorWrapper> for magnus::Error {
92
92
  rust_inline::InlineError::IO(error) => {
93
93
  magnus::Error::new(magnus::exception::arg_error(), error.to_string())
94
94
  }
95
- rust_inline::InlineError::Network(error) => {
96
- magnus::Error::new(magnus::exception::arg_error(), error.to_string())
97
- }
95
+ rust_inline::InlineError::Network { error, location } => magnus::Error::new(
96
+ magnus::exception::arg_error(),
97
+ format!("{error}: {location}"),
98
+ ),
98
99
  rust_inline::InlineError::ParseError(message) => {
99
100
  magnus::Error::new(magnus::exception::arg_error(), message.to_string())
100
101
  }
@@ -105,17 +106,23 @@ impl From<InlineErrorWrapper> for magnus::Error {
105
106
  }
106
107
  }
107
108
 
108
- struct UrlError(rust_inline::ParseError);
109
+ struct UrlError {
110
+ error: rust_inline::ParseError,
111
+ url: String,
112
+ }
109
113
 
110
114
  impl From<UrlError> for magnus::Error {
111
115
  fn from(error: UrlError) -> magnus::Error {
112
- magnus::Error::new(magnus::exception::arg_error(), error.0.to_string())
116
+ magnus::Error::new(
117
+ magnus::exception::arg_error(),
118
+ format!("{}: {}", error.error, error.url),
119
+ )
113
120
  }
114
121
  }
115
122
 
116
123
  fn parse_url(url: Option<String>) -> RubyResult<Option<rust_inline::Url>> {
117
124
  Ok(if let Some(url) = url {
118
- Some(rust_inline::Url::parse(url.as_str()).map_err(UrlError)?)
125
+ Some(rust_inline::Url::parse(url.as_str()).map_err(|error| UrlError { error, url })?)
119
126
  } else {
120
127
  None
121
128
  })
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.11.1
4
+ version: 0.12.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-12-09 00:00:00.000000000 Z
11
+ date: 2023-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  version: 3.3.26
125
125
  requirements:
126
126
  - Rust >= 1.65
127
- rubygems_version: 3.4.22
127
+ rubygems_version: 3.4.10
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: High-performance library for inlining CSS into HTML 'style' attributes