inky-rb 1.3.6.3 → 1.3.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile.lock +3 -5
  4. data/inky.gemspec +1 -0
  5. data/lib/component_factory.rb +34 -33
  6. data/lib/inky.rb +7 -9
  7. data/lib/inky/rails/version.rb +2 -1
  8. data/spec/cases/button/no_link.inky +1 -0
  9. data/spec/cases/button/with_expand_class.inky +3 -0
  10. data/spec/cases/button/with_image.inky +3 -0
  11. data/spec/cases/button/with_link.inky +3 -0
  12. data/spec/cases/button/with_tricky_class.inky +19 -0
  13. data/spec/cases/callout/basic.inky +1 -0
  14. data/spec/cases/callout/with_attributes.inky +3 -0
  15. data/spec/cases/general/multiple_root.inky +2 -0
  16. data/spec/cases/general/no_tag.inky +1 -0
  17. data/spec/cases/general/root_within_text.inky +3 -0
  18. data/spec/cases/general/void_html_elements.inky +6 -0
  19. data/spec/cases/grid/columns.inky +1 -0
  20. data/spec/cases/grid/container.inky +1 -0
  21. data/spec/cases/grid/container_with_align.inky +1 -0
  22. data/spec/cases/grid/row.inky +1 -0
  23. data/spec/cases/grid/row_with_columns.inky +5 -0
  24. data/spec/cases/menu/item.inky +1 -0
  25. data/spec/cases/menu/menu.inky +1 -0
  26. data/spec/cases/menu/menu_with_align.inky +1 -0
  27. data/spec/cases/menu/menu_with_items.inky +5 -0
  28. data/spec/cases/spacer/basic.inky +5 -0
  29. data/spec/cases/spacer/with_size.inky +5 -0
  30. data/spec/cases/spacer/with_size_lg.inky +4 -0
  31. data/spec/cases/spacer/with_size_sm.inky +5 -0
  32. data/spec/cases/spacer/with_size_sm_and_lg.inky +5 -0
  33. data/spec/cases/wrapper/basic.inky +1 -0
  34. data/spec/cases/wrapper/with_align.inky +1 -0
  35. data/spec/cases/wrapper/with_attributes.inky +1 -0
  36. data/spec/cases_spec.rb +55 -0
  37. data/spec/components_spec.rb +1 -3
  38. data/spec/grid_spec.rb +4 -4
  39. data/spec/spec_helper.rb +12 -5
  40. metadata +61 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71ce8013a2662a04d29f602103e3469f8b643438
4
- data.tar.gz: 72256f8875d40b80943cb5cb77d9eb437e76c649
3
+ metadata.gz: 4a4008c29bb92a467214a676eb6dfa34286f7333
4
+ data.tar.gz: 2a5e4bf73fe574f8d952aed07ad6324c7aecfdad
5
5
  SHA512:
6
- metadata.gz: 05a783f3a2966497ec8894945c7f389c4a76b9f16d5e70e0b50b9afc3f67877ba1976988911ed8aca605391e64c1f2ed1fb476c671b21257fb733251d07d8c9c
7
- data.tar.gz: d17d71d531bd72f64d08d72e2ab1f97348ce41f1b240f1182998c6ec58bd5a4a979d0fb4971d70201923775a1bda15d455302cd7ae64002ca8cbd39b31c288d0
6
+ metadata.gz: 0c67e33eb5035b4e02333642e3781eb70292bb7b1b2dcdf3fc3af6d54c8802f7085f232cbef1bb9198f3a0f048b2b926b510631aa72f8c841d95d594c14a5bef
7
+ data.tar.gz: 6f1d96ad26149214322c00e279f8ffbea12c531f9d30848c1d43af5b5beec3d08187580c82e9b90f34dcd8269c945d6090d7a47f66664aa9d01b311639def83b
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  *.swp
2
2
  pkg
3
+ spec/_cases_output
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- inky-rb (1.3.6.3)
4
+ inky-rb (1.3.7.0)
5
5
  foundation_emails (~> 2)
6
6
  nokogiri
7
7
 
@@ -10,14 +10,12 @@ GEM
10
10
  specs:
11
11
  ast (2.3.0)
12
12
  diff-lcs (1.2.5)
13
- foundation_emails (2.2.0.0)
13
+ foundation_emails (2.2.1.0)
14
14
  mini_portile2 (2.1.0)
15
- nokogiri (1.6.8)
15
+ nokogiri (1.6.8.1)
16
16
  mini_portile2 (~> 2.1.0)
17
- pkg-config (~> 1.1.7)
18
17
  parser (2.3.1.4)
19
18
  ast (~> 2.2)
20
- pkg-config (1.1.7)
21
19
  powerpack (0.1.1)
22
20
  rainbow (2.1.0)
23
21
  rake (11.2.2)
data/inky.gemspec CHANGED
@@ -9,6 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.description = 'Inky is an HTML-based templating language that converts simple HTML into complex, responsive email-ready HTML. Designed for Foundation for Emails, a responsive email framework from ZURB. '
10
10
  s.authors = ["ZURB"]
11
11
  s.email = ['foundation@zurb.com']
12
+ s.homepage = 'https://github.com/zurb/inky-rb'
12
13
 
13
14
  s.files = `git ls-files -z`.split("\x0")
14
15
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -4,7 +4,7 @@ module ComponentFactory
4
4
  # TODO: Handle changed names
5
5
  transform_method = :"_transform_#{component_lookup[elem.name]}"
6
6
  return unless respond_to?(transform_method)
7
- Nokogiri::XML(send(transform_method, elem, inner)).root
7
+ send(transform_method, elem, inner)
8
8
  end
9
9
 
10
10
  tags = %w[class id href size large no-expander small target]
@@ -18,13 +18,16 @@ module ComponentFactory
18
18
  end
19
19
 
20
20
  def _has_class(elem, klass)
21
- (elem.attr('class') || '').include?(klass)
21
+ elem.attr('class') =~ /(^|\s)#{klass}($|\s)/
22
22
  end
23
23
 
24
- def _class_array(elem, defaults = [])
25
- classes = elem['class']
26
- defaults.concat(classes.split(' ')) if classes
27
- defaults
24
+ def _combine_classes(elem, extra_classes)
25
+ [elem['class'], extra_classes].join(' ')
26
+ end
27
+
28
+ def _combine_attributes(elem, extra_classes = nil)
29
+ classes = _combine_classes(elem, extra_classes)
30
+ [_pass_through_attributes(elem), classes && %{class="#{classes}"}].join
28
31
  end
29
32
 
30
33
  def _target_attribute(elem)
@@ -40,30 +43,30 @@ module ComponentFactory
40
43
  end
41
44
  inner = "<center>#{inner}</center>" if expand
42
45
 
43
- classes = _class_array(component, ['button'])
46
+ classes = _combine_classes(component, 'button')
44
47
  expander = '<td class="expander"></td>' if expand
45
- %{<table class="#{classes.join(' ')}"><tr><td><table><tr><td>#{inner}</td></tr></table></td>#{expander}</tr></table>}
48
+ %{<table class="#{classes}"><tr><td><table><tr><td>#{inner}</td></tr></table></td>#{expander}</tr></table>}
46
49
  end
47
50
 
48
51
  def _transform_menu(component, inner)
49
- classes = _class_array(component, ['menu'])
50
- %{<table class="#{classes.join(' ')}"><tr><td><table><tr>#{inner}</tr></table></td></tr></table>}
52
+ attributes = _combine_attributes(component, 'menu')
53
+ %{<table #{attributes}><tr><td><table><tr>#{inner}</tr></table></td></tr></table>}
51
54
  end
52
55
 
53
56
  def _transform_menu_item(component, inner)
54
57
  target = _target_attribute(component)
55
- %{<th class="menu-item"><a href="#{component.attr('href')}"#{target}>#{inner}</a></th>}
58
+ attributes = _combine_attributes(component, 'menu-item')
59
+ %{<th #{attributes}><a href="#{component.attr('href')}"#{target}>#{inner}</a></th>}
56
60
  end
57
61
 
58
62
  def _transform_container(component, inner)
59
- classes = _class_array(component, ['container'])
60
- %{<table class="#{classes.join(' ')}"><tbody><tr><td>#{inner}</td></tr></tbody></table>}
63
+ attributes = _combine_attributes(component, 'container')
64
+ %{<table #{attributes} align="center"><tbody><tr><td>#{inner}</td></tr></tbody></table>}
61
65
  end
62
66
 
63
67
  def _transform_row(component, inner)
64
- classes = _class_array(component, ['row'])
65
- attrs = _pass_through_attributes(component)
66
- %{<table #{attrs}class="#{classes.join(' ')}"><tbody><tr>#{inner}</tr></tbody></table>}
68
+ attributes = _combine_attributes(component, 'row')
69
+ %{<table #{attributes}><tbody><tr>#{inner}</tr></tbody></table>}
67
70
  end
68
71
 
69
72
  # in inky.js this is factored out into makeClumn. TBD if we need that here.
@@ -76,20 +79,20 @@ module ComponentFactory
76
79
  small_size = small_val || column_count
77
80
  large_size = large_val || small_val || (column_count / col_count).to_i
78
81
 
79
- classes = _class_array(component, ["small-#{small_size}", "large-#{large_size}", "columns"])
82
+ classes = _combine_classes(component, "small-#{small_size} large-#{large_size} columns")
80
83
 
81
- classes.push('first') unless component.previous_element
82
- classes.push('last') unless component.next_element
84
+ classes << ' first' unless component.previous_element
85
+ classes << ' last' unless component.next_element
83
86
 
84
87
  subrows = component.elements.css(".row").to_a.concat(component.elements.css("row").to_a)
85
88
  expander = %{<th class="expander"></th>} if large_size.to_i == column_count && subrows.empty?
86
89
 
87
- %{<th class="#{classes.join(' ')}" #{_pass_through_attributes(component)}><table><tr><th>#{inner}</th>#{expander}</tr></table></th>}
90
+ %{<th class="#{classes}" #{_pass_through_attributes(component)}><table><tr><th>#{inner}</th>#{expander}</tr></table></th>}
88
91
  end
89
92
 
90
93
  def _transform_block_grid(component, inner)
91
- classes = _class_array(component, ['block-grid', "up-#{component.attr('up')}"])
92
- %{<table class="#{classes.join(' ')}"><tr>#{inner}</tr></table>}
94
+ classes = _combine_classes(component, "block-grid up-#{component.attr('up')}")
95
+ %{<table class="#{classes}"><tr>#{inner}</tr></table>}
93
96
  end
94
97
 
95
98
  def _transform_center(component, _inner)
@@ -97,25 +100,24 @@ module ComponentFactory
97
100
  # sometimes appears to miss elements that show up in size
98
101
  component.elements.each do |child|
99
102
  child['align'] = 'center'
100
- child_classes = _class_array(child, ['float-center'])
101
- child['class'] = child_classes.join(' ')
103
+ child['class'] = _combine_classes(child, 'float-center')
102
104
  items = component.elements.css(".menu-item").to_a.concat(component.elements.css("item").to_a)
103
105
  items.each do |item|
104
- item_classes = _class_array(item, ['float-center'])
105
- item['class'] = item_classes.join(' ')
106
+ item['class'] = _combine_classes(item, 'float-center')
106
107
  end
107
108
  end
108
109
  component.to_s
109
110
  end
110
111
 
111
112
  def _transform_callout(component, inner)
112
- classes = _class_array(component, ['callout-inner'])
113
- %{<table class="callout"><tr><th class="#{classes.join(' ')}">#{inner}</th><th class="expander"></th></tr></table>}
113
+ classes = _combine_classes(component, 'callout-inner')
114
+ attributes = _pass_through_attributes(component)
115
+ %{<table #{attributes}class="callout"><tr><th class="#{classes}">#{inner}</th><th class="expander"></th></tr></table>}
114
116
  end
115
117
 
116
118
  def _transform_spacer(component, _inner)
117
- classes = _class_array(component, ['spacer'])
118
- build_table = ->(size, extra) { %{<table class="#{classes.join(' ')} #{extra}"><tbody><tr><td height="#{size}px" style="font-size:#{size}px;line-height:#{size}px;">&#xA0;</td></tr></tbody></table>} }
119
+ classes = _combine_classes(component, 'spacer')
120
+ build_table = ->(size, extra) { %{<table class="#{classes} #{extra}"><tbody><tr><td height="#{size}px" style="font-size:#{size}px;line-height:#{size}px;">&#xA0;</td></tr></tbody></table>} }
119
121
  size = component.attr('size')
120
122
  size_sm = component.attr('size-sm')
121
123
  size_lg = component.attr('size-lg')
@@ -123,7 +125,6 @@ module ComponentFactory
123
125
  html = ''
124
126
  html << build_table[size_sm, 'hide-for-large'] if size_sm
125
127
  html << build_table[size_lg, 'show-for-large'] if size_lg
126
- html = "<span>#{html}</span>" if size_sm && size_lg
127
128
  html
128
129
  else
129
130
  build_table[size || 16, nil]
@@ -131,7 +132,7 @@ module ComponentFactory
131
132
  end
132
133
 
133
134
  def _transform_wrapper(component, inner)
134
- classes = _class_array(component, ['wrapper'])
135
- %{<table class="#{classes.join(' ')}" align="center"><tr><td class="wrapper-inner">#{inner}</td></tr></table>}
135
+ attributes = _combine_attributes(component, 'wrapper')
136
+ %{<table #{attributes} align="center"><tr><td class="wrapper-inner">#{inner}</td></tr></table>}
136
137
  end
137
138
  end
data/lib/inky.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Inky
2
2
  class Core
3
3
  require 'nokogiri'
4
- require 'component_factory'
4
+ require_relative 'component_factory'
5
5
  attr_accessor :components, :column_count, :component_lookup, :component_tags
6
6
 
7
7
  include ComponentFactory
@@ -31,17 +31,15 @@ module Inky
31
31
  def release_the_kraken(xml_string)
32
32
  xml_string = xml_string.gsub(/doctype/i, 'DOCTYPE')
33
33
  raws, str = Inky::Core.extract_raws(xml_string)
34
- xml_doc = Nokogiri::XML(str)
35
- transform_doc(xml_doc.root) if components_exist?(xml_doc)
36
- string = xml_doc.to_s
37
- string.sub!(/^<\?xml.*\?>\n/, '')
34
+ parse_cmd = str =~ /<html/i ? :parse : :fragment
35
+ html = Nokogiri::HTML.public_send(parse_cmd, str)
36
+ html.elements.each do |elem|
37
+ transform_doc(elem)
38
+ end
39
+ string = html.to_html(encoding: 'US-ASCII')
38
40
  Inky::Core.re_inject_raws(string, raws)
39
41
  end
40
42
 
41
- def components_exist?(_xml_doc)
42
- true
43
- end
44
-
45
43
  def transform_doc(elem)
46
44
  if elem.respond_to?(:children)
47
45
  elem.children.each do |child|
@@ -1,5 +1,6 @@
1
1
  module Inky
2
2
  module Rails
3
- VERSION = "1.3.6.3".freeze
3
+ VERSION = "1.3.7.0".freeze
4
4
  end
5
+ NODE_VERSION, GEM_VERSION = Rails::VERSION.rpartition('.').map(&:freeze)
5
6
  end
@@ -0,0 +1 @@
1
+ <button>I'm missing an href</button>
@@ -0,0 +1,3 @@
1
+ <button href="http://example.com" class="expand foo">
2
+ A label
3
+ </button>
@@ -0,0 +1,3 @@
1
+ <button href="#">
2
+ <img src="http://www.example.com/" width="600" height="400"/>
3
+ </button>
@@ -0,0 +1,3 @@
1
+ <button href="http://example.com" class="some classes" foo="bar">
2
+ A label
3
+ </button>
@@ -0,0 +1,19 @@
1
+ <button href="http://example.com" class="noexpand">
2
+ A label
3
+ </button>
4
+
5
+ <button href="http://example.com" class="expand-niet">
6
+ A label
7
+ </button>
8
+
9
+ <button href="http://example.com" class="expand foo">
10
+ A label
11
+ </button>
12
+
13
+ <button href="http://example.com" class="foo expand">
14
+ A label
15
+ </button>
16
+
17
+ <button href="http://example.com" class="foo expand bar">
18
+ A label
19
+ </button>
@@ -0,0 +1 @@
1
+ <callout>Simple callout</callout>
@@ -0,0 +1,3 @@
1
+ <callout class="some klasses" foo="bar">
2
+ <p>I'm in a callout!</p>
3
+ </callout>
@@ -0,0 +1,2 @@
1
+ <callout>Hey</callout>
2
+ <callout>You</callout>
@@ -0,0 +1 @@
1
+ Very simple test...
@@ -0,0 +1,3 @@
1
+ Text before
2
+ <callout>Ho</callout>
3
+ Text after
@@ -0,0 +1,6 @@
1
+ <callout>
2
+ Hello
3
+ <br/>
4
+ Here's an image:
5
+ <img src="http://www.example.com" width="400" height="200"/>
6
+ </callout>
@@ -0,0 +1 @@
1
+ <columns class="some classes" foo="bar">First column</columns>
@@ -0,0 +1 @@
1
+ <container class="klass" foo="bar">some content</container>
@@ -0,0 +1 @@
1
+ <container align="left">some content</container>
@@ -0,0 +1 @@
1
+ <row class="some klasses" foo="bar">columns here</row>
@@ -0,0 +1,5 @@
1
+ <row class="collapse">
2
+ <columns>First column</columns>
3
+ <columns>Second column</columns>
4
+ <columns>Last column</columns>
5
+ </row>
@@ -0,0 +1 @@
1
+ <item class="some classes" foo="bar" href="http://example.com">An item</item>
@@ -0,0 +1 @@
1
+ <menu class="some classes" foo="bar"/>
@@ -0,0 +1 @@
1
+ <menu align="left"/>
@@ -0,0 +1,5 @@
1
+ <menu class="small-vertical">
2
+ <item href="http://example.com/1">An item</item>
3
+ <item href="http://example.com/2">Another Item</item>
4
+ <item href="http://example.com/3">Last Item</item>
5
+ </menu>
@@ -0,0 +1,5 @@
1
+ <div>
2
+ Stuff on top
3
+ <spacer/>
4
+ Stuff on bottom
5
+ </div>
@@ -0,0 +1,5 @@
1
+ <div>
2
+ Stuff on top
3
+ <spacer class="some classes" foo="bar" size="42"/>
4
+ Stuff on bottom
5
+ </div>
@@ -0,0 +1,4 @@
1
+ <div>
2
+ Stuff on top
3
+ <spacer class="some classes" foo="bar" size-lg="666"/>
4
+ <p>Stuff on bottom</p>
@@ -0,0 +1,5 @@
1
+ <div>
2
+ Stuff on top
3
+ <spacer class="some classes" foo="bar" size-sm="42"></spacer>
4
+ Stuff on bottom
5
+ </div>
@@ -0,0 +1,5 @@
1
+ <div>
2
+ Stuff on top
3
+ <spacer class="some classes" foo="bar" size-sm="42" size-lg="666"/>
4
+ Stuff on bottom
5
+ </div>
@@ -0,0 +1 @@
1
+ <wrapper>In the wrap</wrapper>
@@ -0,0 +1 @@
1
+ <wrapper align="left">In the wrap</wrapper>
@@ -0,0 +1 @@
1
+ <wrapper class="some classes" foo="bar">In the wrap</wrapper>
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ INKY_VERSION_REQUIRED = Inky::NODE_VERSION
5
+
6
+ def npm_packages
7
+ JSON.parse(`npm list -g --depth=1 --json=true`)
8
+ rescue
9
+ puts <<-Err
10
+ npm not detected, skipping comparison tests.
11
+ Err
12
+ nil
13
+ end
14
+
15
+ def inky_cli_ok?
16
+ return unless packages = npm_packages
17
+ version = packages['dependencies']['inky-cli']['dependencies']['inky']['version']
18
+ return true if version >= INKY_VERSION_REQUIRED
19
+ puts "Requires inky version #{INKY_VERSION_REQUIRED}+, currently installed #{version}"
20
+ false
21
+ rescue
22
+ puts <<-Err
23
+ inky-cli not globally installed, skipping comparison tests.
24
+ Install with:
25
+ npm install inky-cli -g
26
+ Err
27
+ false
28
+ end
29
+
30
+ RSpec.describe "Inky-rb" do
31
+ context "compared to inky-cli" do
32
+ Dir['./spec/cases/*'].each do |path|
33
+ folder = File.basename(path)
34
+ output_path = "./spec/_cases_output/#{File.basename(folder)}"
35
+ sources = "#{path}/*.inky"
36
+ source_paths = Dir[sources]
37
+
38
+ context "for #{folder} components" do
39
+ before(:all) do
40
+ shell = source_paths.map { |p| "inky #{p} #{output_path}" }
41
+ `#{shell.join(' && ')}`
42
+ end
43
+
44
+ source_paths.each do |filepath|
45
+ file = File.basename(filepath, '.inky')
46
+ content = File.read(filepath)
47
+ exec = content =~ /^<!--\s*(pending|skip)/ ? $1 : :it
48
+ send exec, "provides the same results for #{file}" do
49
+ compare(content, File.read("#{output_path}/#{file}.inky"))
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end if inky_cli_ok?
55
+ end
@@ -301,7 +301,6 @@ RSpec.describe "Spacer" do
301
301
  it 'creates a spacer element for small and large screens with correct sizes' do
302
302
  input = '<spacer size-sm="10" size-lg="20"></spacer>'
303
303
  expected = <<-HTML
304
- <span>
305
304
  <table class="spacer hide-for-large">
306
305
  <tbody>
307
306
  <tr>
@@ -316,7 +315,6 @@ RSpec.describe "Spacer" do
316
315
  </tr>
317
316
  </tbody>
318
317
  </table>
319
- </span>
320
318
  HTML
321
319
 
322
320
  compare(input, expected)
@@ -356,7 +354,7 @@ end
356
354
  RSpec.describe "raw" do
357
355
  it 'creates a wrapper that ignores anything inside' do
358
356
  input = "<body><raw><<LCG ProgramTG LCG Coupon Code Default='246996'>></raw></body>"
359
- expected = "<body><<LCG ProgramTG LCG Coupon Code Default='246996'>></body>\n"
357
+ expected = "<body><<LCG ProgramTG LCG Coupon Code Default='246996'>></body>"
360
358
 
361
359
  # Can't do vanilla compare because the second will fail to parse
362
360
  inky = Inky::Core.new
data/spec/grid_spec.rb CHANGED
@@ -4,7 +4,7 @@ RSpec.describe "Container" do
4
4
  it "creates a container table" do
5
5
  input = '<container></container>'
6
6
  expected = <<-HTML
7
- <table class="container">
7
+ <table class="container" align="center">
8
8
  <tbody>
9
9
  <tr>
10
10
  <td></td>
@@ -18,7 +18,7 @@ RSpec.describe "Container" do
18
18
  it 'works when parsing a full HTML document' do
19
19
  input = <<-INKY
20
20
  <!doctype html> <html>
21
- <head></head>
21
+ <head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"></head>
22
22
  <body>
23
23
  <container></container>
24
24
  </body>
@@ -27,9 +27,9 @@ RSpec.describe "Container" do
27
27
  expected = <<-HTML
28
28
  <!DOCTYPE html>
29
29
  <html>
30
- <head></head>
30
+ <head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"></head>
31
31
  <body>
32
- <table class="container">
32
+ <table class="container" align="center">
33
33
  <tbody>
34
34
  <tr>
35
35
  <td></td>
data/spec/spec_helper.rb CHANGED
@@ -2,11 +2,18 @@ require 'inky'
2
2
 
3
3
  def reformat_html(html)
4
4
  html
5
- .gsub(/\s+/, ' ') # Compact all whitespace to a single space
6
- .gsub(/> *</, ">\n<") # Use returns between tags
7
- .gsub(%r{<(\w+)([^>]*)>\n</\1>}, '<\1\2/>') # Auto close empty tags, e.g. <hr>\n</hr> => <hr/>
8
- .gsub(/ "/, '"').gsub(/\=" /, '="') # Remove leading/trailing spaces inside attributes
9
- .gsub(/ </, '<').gsub(/> /, '>') # Remove leading/trailing spaces inside tags
5
+ .gsub(/\s+/, ' ') # Compact all whitespace to a single space
6
+ .gsub(/> *</, ">\n<") # Use returns between tags
7
+ .gsub(%r{<(\w+)([^>]*)>\n</\1>}, '<\1\2/>') # Auto close empty tags, e.g. <hr>\n</hr> => <hr/>
8
+ .gsub(/ "/, '"').gsub(/\=" /, '="') # Remove leading/trailing spaces inside attributes
9
+ .gsub(/ </, '<').gsub(/> /, '>') # Remove leading/trailing spaces inside tags
10
+ .gsub(' data-parsed=""', '') # Don't consider this known inky-node artefact
11
+ .gsub('&#xA0', '&#160') # These are the same entity...
12
+ .gsub(/(align="[^"]+") (class="[^"]+")/, '\2 \1') # Tweak order to match inky-node on container
13
+ .gsub(/class\="([^"]+)"/) do # Sort class names
14
+ classes = $1.split(' ').sort.join(' ')
15
+ %{class="#{classes}"}
16
+ end
10
17
  end
11
18
 
12
19
  def compare(input, expected)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inky-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.6.3
4
+ version: 1.3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ZURB
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-08 00:00:00.000000000 Z
11
+ date: 2016-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foundation_emails
@@ -122,10 +122,39 @@ files:
122
122
  - lib/inky/rails/engine.rb
123
123
  - lib/inky/rails/template_handler.rb
124
124
  - lib/inky/rails/version.rb
125
+ - spec/cases/button/no_link.inky
126
+ - spec/cases/button/with_expand_class.inky
127
+ - spec/cases/button/with_image.inky
128
+ - spec/cases/button/with_link.inky
129
+ - spec/cases/button/with_tricky_class.inky
130
+ - spec/cases/callout/basic.inky
131
+ - spec/cases/callout/with_attributes.inky
132
+ - spec/cases/general/multiple_root.inky
133
+ - spec/cases/general/no_tag.inky
134
+ - spec/cases/general/root_within_text.inky
135
+ - spec/cases/general/void_html_elements.inky
136
+ - spec/cases/grid/columns.inky
137
+ - spec/cases/grid/container.inky
138
+ - spec/cases/grid/container_with_align.inky
139
+ - spec/cases/grid/row.inky
140
+ - spec/cases/grid/row_with_columns.inky
141
+ - spec/cases/menu/item.inky
142
+ - spec/cases/menu/menu.inky
143
+ - spec/cases/menu/menu_with_align.inky
144
+ - spec/cases/menu/menu_with_items.inky
145
+ - spec/cases/spacer/basic.inky
146
+ - spec/cases/spacer/with_size.inky
147
+ - spec/cases/spacer/with_size_lg.inky
148
+ - spec/cases/spacer/with_size_sm.inky
149
+ - spec/cases/spacer/with_size_sm_and_lg.inky
150
+ - spec/cases/wrapper/basic.inky
151
+ - spec/cases/wrapper/with_align.inky
152
+ - spec/cases/wrapper/with_attributes.inky
153
+ - spec/cases_spec.rb
125
154
  - spec/components_spec.rb
126
155
  - spec/grid_spec.rb
127
156
  - spec/spec_helper.rb
128
- homepage:
157
+ homepage: https://github.com/zurb/inky-rb
129
158
  licenses: []
130
159
  metadata: {}
131
160
  post_install_message:
@@ -151,6 +180,35 @@ summary: Inky is an HTML-based templating language that converts simple HTML int
151
180
  complex, responsive email-ready HTML. Designed for Foundation for Emails, a responsive
152
181
  email framework from ZURB.
153
182
  test_files:
183
+ - spec/cases/button/no_link.inky
184
+ - spec/cases/button/with_expand_class.inky
185
+ - spec/cases/button/with_image.inky
186
+ - spec/cases/button/with_link.inky
187
+ - spec/cases/button/with_tricky_class.inky
188
+ - spec/cases/callout/basic.inky
189
+ - spec/cases/callout/with_attributes.inky
190
+ - spec/cases/general/multiple_root.inky
191
+ - spec/cases/general/no_tag.inky
192
+ - spec/cases/general/root_within_text.inky
193
+ - spec/cases/general/void_html_elements.inky
194
+ - spec/cases/grid/columns.inky
195
+ - spec/cases/grid/container.inky
196
+ - spec/cases/grid/container_with_align.inky
197
+ - spec/cases/grid/row.inky
198
+ - spec/cases/grid/row_with_columns.inky
199
+ - spec/cases/menu/item.inky
200
+ - spec/cases/menu/menu.inky
201
+ - spec/cases/menu/menu_with_align.inky
202
+ - spec/cases/menu/menu_with_items.inky
203
+ - spec/cases/spacer/basic.inky
204
+ - spec/cases/spacer/with_size.inky
205
+ - spec/cases/spacer/with_size_lg.inky
206
+ - spec/cases/spacer/with_size_sm.inky
207
+ - spec/cases/spacer/with_size_sm_and_lg.inky
208
+ - spec/cases/wrapper/basic.inky
209
+ - spec/cases/wrapper/with_align.inky
210
+ - spec/cases/wrapper/with_attributes.inky
211
+ - spec/cases_spec.rb
154
212
  - spec/components_spec.rb
155
213
  - spec/grid_spec.rb
156
214
  - spec/spec_helper.rb