mjml-rb 0.2.22 → 0.2.24
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 +4 -4
- data/lib/mjml-rb/parser.rb +7 -3
- data/lib/mjml-rb/renderer.rb +9 -1
- data/lib/mjml-rb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4840c5584afa1ff603e996338a128d5808ae46742f084d03c0e34391259616f9
|
|
4
|
+
data.tar.gz: ef16089bc907e5e5f649e10adac5389b27a25c63f3ee20aea3cb28db0e78da82
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d378634ab4a2905f65e3831292cb0b55ae22dca61a310bb4c6bf62e77610dfec609cd3d130324c99836a37fc61a34a64c0433fd80729ffcaa9073f528c8c1bee
|
|
7
|
+
data.tar.gz: ea309a490a424440393727cd6e022f4c7372449e6e4f22a7506e8593051b7544d3a96e4af87846fc2d38a472c03aa97fe13fcc9c2ddfb8761912138238dc8210
|
data/lib/mjml-rb/parser.rb
CHANGED
|
@@ -92,9 +92,13 @@ module MjmlRb
|
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
def normalize_html_void_tags(content)
|
|
95
|
-
#
|
|
96
|
-
#
|
|
97
|
-
content = content.gsub(
|
|
95
|
+
# Legacy mail templates sometimes emit invalid closing </br> tags.
|
|
96
|
+
# Browser-style recovery treats them as actual line breaks, so preserve that.
|
|
97
|
+
content = content.gsub(%r{</br\s*>}i, "<br />")
|
|
98
|
+
|
|
99
|
+
# Remove other closing tags for void elements (e.g. </hr>, </img>).
|
|
100
|
+
# These are invalid in both HTML and XML and HTML5 recovery drops them.
|
|
101
|
+
content = content.gsub(/<\/(#{(HTML_VOID_TAGS - ["br"]).join("|")})\s*>/i, "")
|
|
98
102
|
|
|
99
103
|
# Self-close opening void tags that aren't already self-closed.
|
|
100
104
|
pattern = /<(#{HTML_VOID_TAGS.join("|")})(\s[^<>]*?)?>/i
|
data/lib/mjml-rb/renderer.rb
CHANGED
|
@@ -279,7 +279,7 @@ module MjmlRb
|
|
|
279
279
|
css_blocks = unique_strings(context[:inline_styles]).reject { |css| css.nil? || css.strip.empty? }
|
|
280
280
|
return html if css_blocks.empty?
|
|
281
281
|
|
|
282
|
-
document =
|
|
282
|
+
document = parse_html_document(html)
|
|
283
283
|
parse_inline_css_rules(css_blocks.join("\n")).each do |selector, declarations|
|
|
284
284
|
next if selector.empty? || declarations.empty?
|
|
285
285
|
|
|
@@ -291,6 +291,14 @@ module MjmlRb
|
|
|
291
291
|
document.to_html
|
|
292
292
|
end
|
|
293
293
|
|
|
294
|
+
def parse_html_document(html)
|
|
295
|
+
if defined?(Nokogiri::HTML5)
|
|
296
|
+
Nokogiri::HTML5(html)
|
|
297
|
+
else
|
|
298
|
+
Nokogiri::HTML(html)
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
|
|
294
302
|
def select_nodes(document, selector)
|
|
295
303
|
document.css(selector)
|
|
296
304
|
rescue Nokogiri::CSS::SyntaxError, Nokogiri::XML::XPath::SyntaxError
|
data/lib/mjml-rb/version.rb
CHANGED