synvert-core 1.26.2 → 1.26.3
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/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/synvert/core/engine/elegant.rb +6 -0
- data/lib/synvert/core/engine/haml.rb +1 -1
- data/lib/synvert/core/engine/slim.rb +1 -1
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/engine/haml_spec.rb +19 -0
- data/spec/synvert/core/engine/slim_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33af6c56062d411c6a6b22460889e1416975ce685fe1d8e8e86c73583ea8c3c3
|
4
|
+
data.tar.gz: fc14712ad5a4a95f4c97cfd7cf41dbd51973b43c9a24be9086baf321a626a92e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee2aee51d031543fade41cf86d36d8f3704fac0d1bebaf8d146400a73d277352318216b40c4b2bd819e6cd3dbb865ed8dbac05c6e53800a6e7e993460e0d1b73
|
7
|
+
data.tar.gz: 2ea5ae0070defc84ed1e2a157af58c3beab37c04cdc4b18b3528a5339a69aa8a4a02f53515a0fc14381e996bf7374497dc376c408dc305de1552f0db35cf503f
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -69,6 +69,9 @@ module Synvert::Core
|
|
69
69
|
|
70
70
|
while rest.rstrip.end_with?(',')
|
71
71
|
rest = scanner.scan(/.*?(\z|\n)/)
|
72
|
+
if IF_KEYWORDS.include?(keyword) || rest =~ DO_BLOCK_REGEX
|
73
|
+
leading_spaces_counts << leading_spaces_count
|
74
|
+
end
|
72
75
|
new_code << rest
|
73
76
|
end
|
74
77
|
end
|
@@ -85,6 +88,9 @@ module Synvert::Core
|
|
85
88
|
|
86
89
|
while rest.rstrip.end_with?(',')
|
87
90
|
rest = scanner.scan(/.*?(\z|\n)/)
|
91
|
+
if rest =~ DO_BLOCK_REGEX
|
92
|
+
leading_spaces_counts << leading_spaces_count
|
93
|
+
end
|
88
94
|
new_code << rest
|
89
95
|
end
|
90
96
|
end
|
@@ -28,7 +28,7 @@ module Synvert::Core
|
|
28
28
|
new_code << (WHITESPACE * scanner.matched.size)
|
29
29
|
scan_matching_wrapper(scanner, new_code, '{', '}')
|
30
30
|
if scanner.scan('=')
|
31
|
-
new_code <<
|
31
|
+
new_code << ';'
|
32
32
|
scan_ruby_expression(scanner, new_code, leading_spaces_counts, leading_spaces_count)
|
33
33
|
else
|
34
34
|
scan_ruby_interpolation_and_plain_text(scanner, new_code, leading_spaces_counts, leading_spaces_count)
|
@@ -33,7 +33,7 @@ module Synvert::Core
|
|
33
33
|
end
|
34
34
|
scan_attributes_between_whitespace(scanner, new_code)
|
35
35
|
if scanner.scan(/ ?==?/) # it matches ruby expression " span= current_user.login"
|
36
|
-
new_code << (WHITESPACE * scanner.matched.size)
|
36
|
+
new_code << (WHITESPACE * (scanner.matched.size - 1)) + ';'
|
37
37
|
scan_ruby_expression(scanner, new_code, leading_spaces_counts, leading_spaces_count)
|
38
38
|
else
|
39
39
|
scan_ruby_interpolation_and_plain_text(scanner, new_code, leading_spaces_counts, leading_spaces_count)
|
data/lib/synvert/core/version.rb
CHANGED
@@ -98,6 +98,14 @@ module Synvert::Core
|
|
98
98
|
expect(encoded_source).to be_include '{:href=>"/posts", :data => {:author_id => 123, :category => 7}}'
|
99
99
|
end
|
100
100
|
|
101
|
+
it 'encodes attributes with ruby evaluation' do
|
102
|
+
source = <<~EOS
|
103
|
+
%a{:href=>"/posts", :data => {:author_id => 123, :category => 7}}= current_user.name
|
104
|
+
EOS
|
105
|
+
encoded_source = Engine::Haml.encode(source)
|
106
|
+
expect(encoded_source).to be_include '{:href=>"/posts", :data => {:author_id => 123, :category => 7}}; current_user.name'
|
107
|
+
end
|
108
|
+
|
101
109
|
it 'encodes class and ID' do
|
102
110
|
source = <<~EOS
|
103
111
|
%div#things
|
@@ -194,6 +202,17 @@ module Synvert::Core
|
|
194
202
|
expect(encoded_source).not_to be_include 'See, I can count!'
|
195
203
|
end
|
196
204
|
|
205
|
+
it 'encodes ruby block in multi lines' do
|
206
|
+
source = <<~EOS
|
207
|
+
= form_for(:document, builder: BootstrapForm,
|
208
|
+
html: {id: 'new_document_form', class: 'form-vertical'}) do |f|
|
209
|
+
EOS
|
210
|
+
encoded_source = Engine::Haml.encode(source)
|
211
|
+
expect(encoded_source).to be_include 'form_for'
|
212
|
+
expect(encoded_source).to be_include 'do |f|'
|
213
|
+
expect(encoded_source).to be_include 'end'
|
214
|
+
end
|
215
|
+
|
197
216
|
it 'encodes ruby interpolation' do
|
198
217
|
source = 'Look at #{h word} lack of backslash: \#{foo}'
|
199
218
|
encoded_source = Engine::Haml.encode(source)
|
@@ -131,8 +131,8 @@ module Synvert::Core
|
|
131
131
|
h2[id="tagline" class="small tagline"] = page_tagline
|
132
132
|
EOS
|
133
133
|
encoded_source = Engine::Slim.encode(source)
|
134
|
-
expect(encoded_source).to be_include 'page_logo'
|
135
|
-
expect(encoded_source).to be_include 'page_tagline'
|
134
|
+
expect(encoded_source).to be_include '; page_logo'
|
135
|
+
expect(encoded_source).to be_include '; page_tagline'
|
136
136
|
expect(encoded_source).not_to be_include 'h1'
|
137
137
|
expect(encoded_source).not_to be_include 'h2'
|
138
138
|
expect(encoded_source).not_to be_include 'id'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synvert-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.26.
|
4
|
+
version: 1.26.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|