css_inline 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +19 -10
  3. data/ext/css_inline/src/lib.rs +4 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcc13ef01a093e818ec9c59f51cb12ba17cbbbe1a79a956886ef6f939e10a62e
4
- data.tar.gz: 424e2bf2134c3235169724bb8c257e4193945bafe2e647c01471c184ea72c30e
3
+ metadata.gz: 34222fdeb2fa9df7a85ceff2a636e270547dc019f802acf44463e5664bb262f9
4
+ data.tar.gz: 691c0db63a192755607370a42bc0a852816c6c9bc376932abc4a2a6c0ff18864
5
5
  SHA512:
6
- metadata.gz: 186dfcbb167e301066f1b05897a3292655b0266de28e98e30cbb3450a25dcf34f9940162abe1cd625c5695000b2871efc98792fdd2722f921bb1ef3dc862809a
7
- data.tar.gz: 67ae8e3ee7ab80a6b222df1d613f7d549b1ff94e750674928cf3e0310652808213781c19ca18bb87b11f5baef40bf11dc47c89cd12423ab92732deaa52b54454
6
+ metadata.gz: 5674f13869ba479c6332af0f1e6e346bc17571f69cb51a8181bcfdb1c77e246c1e76029f818b14f3b0c686633ad9a752d30a0bef129b835c2715ba0647e77d98
7
+ data.tar.gz: 34715818a75ffc5f1862faf6138981e997c499d0073604af74f073314938f1cd081dbc4c3efe14c19fbc0781a4550db016dbbe4d259cdaff58ccfd91d73995e8
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>
@@ -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
 
@@ -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.1
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-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler