css_inline 0.10.0 → 0.10.2

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: fcc13ef01a093e818ec9c59f51cb12ba17cbbbe1a79a956886ef6f939e10a62e
4
- data.tar.gz: 424e2bf2134c3235169724bb8c257e4193945bafe2e647c01471c184ea72c30e
3
+ metadata.gz: b2bee3426a27caa1fd94d837cc8f9178d78167bffd47cd4f9fbe967683a737be
4
+ data.tar.gz: eafaddb32401278885056597da4dab0403a5cc902e3acbf5e0bf279c4083fb30
5
5
  SHA512:
6
- metadata.gz: 186dfcbb167e301066f1b05897a3292655b0266de28e98e30cbb3450a25dcf34f9940162abe1cd625c5695000b2871efc98792fdd2722f921bb1ef3dc862809a
7
- data.tar.gz: 67ae8e3ee7ab80a6b222df1d613f7d549b1ff94e750674928cf3e0310652808213781c19ca18bb87b11f5baef40bf11dc47c89cd12423ab92732deaa52b54454
6
+ metadata.gz: fcf9fde86b859f76c7b2259a5ceb3c1f49cb5dd3a66efa5b25f2582da9c40330535d78495d8eecbb331defaf68d48bf99fde24854d11eec2e8e1862be5aa63ba
7
+ data.tar.gz: 5b31912053524cfff826837921316ebcac19ce8ed85b49886260d506fcd4619f25dde8a8e40eb98aa6e06fe37a9f462f14da12de2022cb6342f41c0ec3a64ec8
data/README.md CHANGED
@@ -5,16 +5,15 @@
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
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
7
 
8
- `css_inline` inlines CSS into HTML documents, using components from Mozilla's Servo project.
8
+ `css_inline` is a high-performance library for inlining CSS into HTML 'style' attributes.
9
9
 
10
- This process is essential for sending HTML emails as you need to use "style" attributes instead of "style" tags.
10
+ This library is designed for scenarios such as preparing HTML emails or embedding HTML into third-party web pages.
11
11
 
12
12
  For instance, the library transforms HTML like this:
13
13
 
14
14
  ```html
15
15
  <html>
16
16
  <head>
17
- <title>Test</title>
18
17
  <style>h1 { color:blue; }</style>
19
18
  </head>
20
19
  <body>
@@ -27,16 +26,14 @@ into:
27
26
 
28
27
  ```html
29
28
  <html>
30
- <head>
31
- <title>Test</title>
32
- </head>
29
+ <head></head>
33
30
  <body>
34
31
  <h1 style="color:blue;">Big Text</h1>
35
32
  </body>
36
33
  </html>
37
34
  ```
38
35
 
39
- - Uses reliable components from Mozilla's Servo
36
+ - Uses reliable components from Mozilla's Servo project
40
37
  - Inlines CSS from `style` and `link` tags
41
38
  - Removes `style` and `link` tags
42
39
  - Resolves external stylesheets (including local files)
@@ -66,6 +63,20 @@ puts inlined
66
63
  # Outputs: "<html><head></head><body><h1 style=\"color:blue;\">Big Text</h1></body></html>"
67
64
  ```
68
65
 
66
+ When there is a need to inline multiple HTML documents simultaneously, `css_inline` offers the `inline_many` function.
67
+ This feature allows for concurrent processing of several inputs, significantly improving performance when dealing with a large number of documents.
68
+
69
+ ```ruby
70
+ require 'css_inline'
71
+
72
+ inlined = CSSInline.inline_many(["...", "..."])
73
+ ```
74
+
75
+ Under the hood, `inline_many`, spawns threads at the Rust layer to handle the parallel processing of inputs.
76
+ This results in faster execution times compared to employing parallel processing techniques at the Ruby level.
77
+
78
+ **Note**: To fully benefit from `inline_many`, you should run your application on a multicore machine.
79
+
69
80
  ## Configuration
70
81
 
71
82
  For customization options use the `CSSInliner` class:
@@ -88,7 +99,6 @@ You can also skip CSS inlining for an HTML tag by adding the `data-css-inline="i
88
99
 
89
100
  ```html
90
101
  <head>
91
- <title>Test</title>
92
102
  <style>h1 { color:blue; }</style>
93
103
  </head>
94
104
  <body>
@@ -101,7 +111,6 @@ The `data-css-inline="ignore"` attribute also allows you to skip `link` and `sty
101
111
 
102
112
  ```html
103
113
  <head>
104
- <title>Test</title>
105
114
  <!-- Styles below are ignored -->
106
115
  <style data-css-inline="ignore">h1 { color:blue; }</style>
107
116
  </head>
@@ -129,9 +138,9 @@ The table below provides a detailed comparison between `css_inline` and `premail
129
138
 
130
139
  | | `css_inline 0.10.0` | `premailer 1.21.0 with Nokogiri 1.15.2` | Difference |
131
140
  |-------------------|---------------------|------------------------------------------------|------------|
132
- | Basic usage | 11 µs | 448 µs | **40.6x** |
133
- | Realistic email 1 | 290 µs | 9.72 ms | **33.5x** |
134
- | Realistic email 2 | 167.50 µs | Error: Cannot parse 0 calc((100% - 500px) / 2) | - |
141
+ | Basic usage | 9.77 µs | 414.42 µs | **42.42x** |
142
+ | Realistic email 1 | 249.62 µs | 10.75 ms | **42.97x** |
143
+ | Realistic email 2 | 162.33 µs | Error: Cannot parse 0 calc((100% - 500px) / 2) | - |
135
144
 
136
145
  Please refer to the `test/bench.rb` file to review the benchmark code.
137
146
  The results displayed above were measured using stable `rustc 1.70` on Ruby `3.2.2`.
@@ -140,7 +149,7 @@ The results displayed above were measured using stable `rustc 1.70` on Ruby `3.2
140
149
 
141
150
  `css_inline` supports Ruby 2.7 and 3.2.
142
151
 
143
- ## Extra materials
152
+ ## Further reading
144
153
 
145
154
  If you want to know how this library was created & how it works internally, you could take a look at these articles:
146
155
 
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "css-inline-ruby"
3
- version = "0.10.0"
3
+ version = "0.10.2"
4
4
  authors = ["Dmitry Dygalo <dadygalo@gmail.com>"]
5
5
  edition = "2021"
6
6
  readme = "README.rdoc"
@@ -16,13 +16,16 @@
16
16
  missing_debug_implementations,
17
17
  trivial_casts,
18
18
  trivial_numeric_casts,
19
+ unreachable_pub,
19
20
  unused_extern_crates,
20
21
  unused_import_braces,
21
22
  unused_qualifications,
22
23
  variant_size_differences,
23
24
  rust_2018_idioms,
24
- rust_2018_compatibility
25
+ rust_2018_compatibility,
26
+ rust_2021_compatibility
25
27
  )]
28
+ #[allow(clippy::module_name_repetitions)]
26
29
  use css_inline as rust_inline;
27
30
  use magnus::{
28
31
  class, define_module, function, method,
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.0
4
+ version: 0.10.2
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-06-16 00:00:00.000000000 Z
11
+ date: 2023-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler