roadie 5.0.0 → 5.1.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: 5ba6c121fdd1072479afeee70b785db020df45cbe3b45350a20f9cfd4f8d0164
4
- data.tar.gz: bfd6faa52b576fba65b8d2281b213ceabf137f08551749dc842b9a9477566fd2
3
+ metadata.gz: 39c01590157057fcedad04740a1594a45f18150d74c7e8fe071dd3aea6908e1f
4
+ data.tar.gz: 490cc578b42057ca635ce613d8e50b05401b0a07597761f70423467aa99aa673
5
5
  SHA512:
6
- metadata.gz: 0b897b87d20fdd739110788a21f2b16c5c4a86726b876cfe2a1c815bc671341a02172eaca5bb65729e14cc10e06b7baa076832bd55cb36db927fb4c548eb117e
7
- data.tar.gz: 290845f661cf1d913fcf01b3c66eeb6e6ec096667a64c21b81fa912950e42a0d1a8294532e28b01f283cf9215a5da028c3559e2fa6cac54860d9c006bce7f401
6
+ metadata.gz: d71f85f1aba91c711351972b65074835f690f62d0cd4a0feb663f67df89a86d8acddc855fe7be4e23601fe3b0508c1558f6c18cc260c69c1ad5b1b1857ad04e2
7
+ data.tar.gz: 1d708c10a62800d44efbe825601546a8713b953f81a2549d91a23e74e26048839adc418d38c38bbd08bd885bc6504a3a07c5cca46f94d3ad147d347f3086ffaa
@@ -41,3 +41,6 @@ jobs:
41
41
  env:
42
42
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43
43
  uses: amoeba/standardrb-action@v2
44
+ permissions:
45
+ checks: write
46
+ contents: read
data/Changelog.md CHANGED
@@ -1,8 +1,21 @@
1
1
  ### dev
2
2
 
3
- [full changelog](https://github.com/Mange/roadie/compare/v5.0.0...master)
3
+ [full changelog](https://github.com/Mange/roadie/compare/v5.1.0...master)
4
4
 
5
- Nothing yet.
5
+ ### 5.1.0
6
+
7
+ [full changelog](https://github.com/Mange/roadie/compare/v5.0.1...v5.1.0)
8
+
9
+ * Support passing serialization options to Nokogiri with `serialization_options=` method -
10
+ [Dmytro Savochkin](https://github.com/dmytro-savochkin). (#171)
11
+
12
+ ### 5.0.1
13
+
14
+ [full changelog](https://github.com/Mange/roadie/compare/v5.0.0...v5.0.1)
15
+
16
+ * Don't try to inline [the `:host`
17
+ pseudo-class](https://developer.mozilla.org/en-US/docs/Web/CSS/:host) -
18
+ [viamin (Bart Agapinan)](https://github.com/viamin). (#170)
6
19
 
7
20
  ### 5.0.0
8
21
 
data/README.md CHANGED
@@ -94,6 +94,8 @@ Your document instance can be configured with several options:
94
94
  * `external_asset_providers` - A list of asset providers that are invoked when absolute CSS URLs are referenced. See below.
95
95
  * `before_transformation` - A callback run before transformation starts.
96
96
  * `after_transformation` - A callback run after transformation is completed.
97
+ * `serialization_options` - An integer bitmap of options passed along to Nokogiri during serialization.
98
+ By default it's `Nokogiri::XML::Node::SaveOptions::NO_DECLARATION | Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS`.
97
99
 
98
100
  ### Making URLs absolute ###
99
101
 
@@ -42,6 +42,10 @@ module Roadie
42
42
  # which would change the styling on the page
43
43
  attr_accessor :merge_media_queries
44
44
 
45
+ # Integer representing a bitmap set of options used by Nokogiri during serialization.
46
+ # For the complete set of available options look into +Nokogiri::XML::Node::SaveOptions+.
47
+ attr_reader :serialization_options
48
+
45
49
  # The mode to generate markup in. Valid values are `:html` (default) and `:xhtml`.
46
50
  attr_reader :mode
47
51
 
@@ -49,6 +53,9 @@ module Roadie
49
53
  def initialize(html)
50
54
  @keep_uninlinable_css = true
51
55
  @merge_media_queries = true
56
+ @serialization_options =
57
+ Nokogiri::XML::Node::SaveOptions::NO_DECLARATION |
58
+ Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS
52
59
  @html = html
53
60
  @asset_providers = ProviderList.wrap(FilesystemProvider.new)
54
61
  @external_asset_providers = ProviderList.empty
@@ -137,6 +144,13 @@ module Roadie
137
144
  @external_asset_providers = ProviderList.wrap(list)
138
145
  end
139
146
 
147
+ # Integer representing a bitmap set of options used by Nokogiri during serialization.
148
+ # For the complete set of available options look into +Nokogiri::XML::Node::SaveOptions+.
149
+ # (To change the mode in which the document is generated use {#mode=} however.)
150
+ def serialization_options=(options)
151
+ @serialization_options = options || 0
152
+ end
153
+
140
154
  # Change the mode. The mode affects how the resulting markup is generated.
141
155
  #
142
156
  # Valid modes:
@@ -187,13 +201,7 @@ module Roadie
187
201
  xml: save_options::AS_XML
188
202
  }.fetch(mode)
189
203
 
190
- dom.dup.to_html(
191
- save_with: (
192
- save_options::NO_DECLARATION |
193
- save_options::NO_EMPTY_TAGS |
194
- format
195
- )
196
- )
204
+ dom.dup.to_html(save_with: (serialization_options | format))
197
205
  end
198
206
 
199
207
  def make_url_rewriter
@@ -70,6 +70,7 @@ module Roadie
70
70
  :-ms-input-placeholder :-moz-placeholder
71
71
  :before :after
72
72
  :enabled :disabled :checked
73
+ :host
73
74
  ].freeze
74
75
 
75
76
  def pseudo_element?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Roadie
4
- VERSION = "5.0.0"
4
+ VERSION = "5.1.0"
5
5
  end
@@ -398,6 +398,38 @@ describe "Roadie functionality" do
398
398
  expect(actual_result).to eq(expected_result)
399
399
  end
400
400
 
401
+ it "adds XML declaration into XHTML with no serialization options prohibiting it" do
402
+ document = Roadie::Document.new <<-HTML
403
+ <html>
404
+ <head>
405
+ <title>Greetings</title>
406
+ </head>
407
+ </html>
408
+ HTML
409
+
410
+ document.mode = :xhtml
411
+ document.serialization_options = 0
412
+ result = document.transform
413
+
414
+ expect(result).to match(/\A<\?xml[^>]*?>/i)
415
+ end
416
+
417
+ it "does not add XML declaration into XHTML with serialization options prohibiting it" do
418
+ document = Roadie::Document.new <<-HTML
419
+ <html>
420
+ <head>
421
+ <title>Greetings</title>
422
+ </head>
423
+ </html>
424
+ HTML
425
+
426
+ document.mode = :xhtml
427
+ document.serialization_options = Nokogiri::XML::Node::SaveOptions::NO_DECLARATION
428
+ result = document.transform
429
+
430
+ expect(result).not_to match(/\A<\?xml[^>]*?>/i)
431
+ end
432
+
401
433
  describe "if merge_media_queries is set to false" do
402
434
  it "doesn't group non-inlineable media queries in the head" do
403
435
  document = Roadie::Document.new <<-HTML
@@ -17,6 +17,16 @@ module Roadie
17
17
  expect(document.url_options).to eq({host: "foo.bar"})
18
18
  end
19
19
 
20
+ it "has an accessor for serialization options" do
21
+ serialization_options = Nokogiri::XML::Node::SaveOptions::FORMAT |
22
+ Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS
23
+ document.serialization_options = serialization_options
24
+ expect(document.serialization_options).to eq(serialization_options)
25
+
26
+ document.serialization_options = nil
27
+ expect(document.serialization_options).to eq(0)
28
+ end
29
+
20
30
  it "has a setting for keeping uninlinable styles" do
21
31
  expect(document.keep_uninlinable_css).to be true
22
32
  document.keep_uninlinable_css = false
@@ -27,6 +27,7 @@ module Roadie
27
27
  p:enabled
28
28
  p:disabled
29
29
  p:checked
30
+ p:host
30
31
  ].each do |bad_selector|
31
32
  expect(Selector.new(bad_selector)).not_to be_inlinable
32
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roadie
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus Bergmark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-02 00:00:00.000000000 Z
11
+ date: 2022-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  - !ruby/object:Gem::Version
198
198
  version: '0'
199
199
  requirements: []
200
- rubygems_version: 3.0.9
200
+ rubygems_version: 3.3.7
201
201
  signing_key:
202
202
  specification_version: 4
203
203
  summary: Making HTML emails comfortable for the Ruby rockstars