style_inliner 0.0.1 → 0.0.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
  SHA1:
3
- metadata.gz: d7481c1d3452a48020915539d4244a6458c097e9
4
- data.tar.gz: 3f348b7b787d8f67cb81270766046f5aa11cdf44
3
+ metadata.gz: cf6243cd2ac843cb80cbaac1f3e6473e8ca4ed4e
4
+ data.tar.gz: 6290a31218e4de678afdd967dadb1f9ce276c2c6
5
5
  SHA512:
6
- metadata.gz: a08494863a4a41ad2b028682d3c19ce49cef2fc7215045e0134e4b27f40d766036dca8d06a46ae58d6300d48e122ce083454862c92a7845b931286a3d1063503
7
- data.tar.gz: 9fb35e3c483ca933539082f5e5f66d544f52636a68f828b0675837e6520befed1ffccc5d76f6df138f1038807f578e1223d711ece804ad060174baf92c457b8e
6
+ metadata.gz: 3d3cf33a841c8c575764192957a001dbacc2c78a11168523f24dbfa069ac69645575a9900500cfb1bb64bc07568c07ffab1ab5ba77d7cf0cf0153c99c518b906
7
+ data.tar.gz: 3a0a85c2414583ad78efa39a10cab66ac9b6ded0aa302cc912125e87a2111f9efb34d7c3fed0d448b316500401098a086eff9d9d9480f1394c9e3828ab03863f
@@ -1,2 +1,5 @@
1
+ ## 0.0.2
2
+ - Add `:replace_properties_to_attributes` option
3
+
1
4
  ## 0.0.1
2
5
  - 1st release :tada:
data/README.md CHANGED
@@ -31,15 +31,24 @@ html = <<-EOS
31
31
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
32
32
  <style>
33
33
  body {
34
- background: red;
34
+ background-color: red;
35
+ }
36
+
37
+ td {
38
+ background-color: blue
35
39
  }
36
40
  </style>
37
41
  </head>
38
42
  <body>
43
+ <table>
44
+ <tr>
45
+ <td>example</td>
46
+ </tr>
47
+ </table>
39
48
  </body>
40
49
  </html>
41
50
  EOS
42
- puts StyleInliner::Document.new(html).inline
51
+ puts StyleInliner::Document.new(html, replace_properties_to_attributes: true).inline
43
52
  ```
44
53
 
45
54
  ```html
@@ -50,10 +59,18 @@ puts StyleInliner::Document.new(html).inline
50
59
 
51
60
  </head>
52
61
  <body style="background-color: red">
62
+ <table>
63
+ <tr>
64
+ <td bgcolor="blue">example</td>
65
+ </tr>
66
+ </table>
53
67
  </body>
54
68
  </html>
55
69
  ```
56
70
 
71
+ ## Ruby version compatibility
72
+ StyleInliner is tested on Ruby 2.2.0.
73
+
57
74
  ## Development
58
75
 
59
76
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -19,8 +19,10 @@ module StyleInliner
19
19
  )
20
20
 
21
21
  # @param html [String]
22
- def initialize(html)
22
+ # @param replace_properties_to_attributes [false, true]
23
+ def initialize(html, replace_properties_to_attributes: true)
23
24
  @html = html
25
+ @replace_properties_to_attributes = replace_properties_to_attributes
24
26
  end
25
27
 
26
28
  # @return [Nokogiri::XML::Node]
@@ -79,7 +81,7 @@ module StyleInliner
79
81
 
80
82
  def fold_style_attributes
81
83
  root.search("*[@style]").each do |node|
82
- NodeStyleFolding.new(node).call
84
+ NodeStyleFolding.new(node, replace_properties_to_attributes: @replace_properties_to_attributes).call
83
85
  end
84
86
  end
85
87
 
@@ -58,12 +58,14 @@ module StyleInliner
58
58
  )
59
59
 
60
60
  # @param node [Nokogiri::XML::Node]
61
- def initialize(node)
61
+ # @param replace_properties_to_attributes [false, true]
62
+ def initialize(node, replace_properties_to_attributes: true)
62
63
  @node = node
64
+ @replace_properties_to_attributes = replace_properties_to_attributes
63
65
  end
64
66
 
65
67
  def call
66
- update_css_compatible_attributes
68
+ update_css_compatible_attributes if @replace_properties_to_attributes
67
69
  update_style_attribute
68
70
  end
69
71
 
@@ -1,3 +1,3 @@
1
1
  module StyleInliner
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: style_inliner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura