syntax_tree-haml 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/Gemfile.lock +3 -3
- data/lib/syntax_tree/haml/format.rb +21 -25
- data/lib/syntax_tree/haml/version.rb +1 -1
- 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: 0dfb86a00b3723b124c178e28e4a6af8a604aba895a495324ea151732449bde3
|
4
|
+
data.tar.gz: d597c33107dc7d04b1b52dbe645b2b8b0bf0830e0dc328f83971e95305dab32f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6c225f3fcbd9af942f4a6cc00ca8a018a9ebec362b18e987f3b38895164da276ceec928fc02303fcb5055b4a4d787e0224d37cea9402de94f3310171e290c87
|
7
|
+
data.tar.gz: 40ae9ef5f96374fed98f1e00302bfda455e3b279f4f653c733cd806bdc52af37ee4f56bd6464b3a16442dd522a56afc23a8773d07692213d978bad16d68b87ac
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.3.1] - 2022-08-01
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
- Use Syntax Tree to handle properly quoting strings.
|
14
|
+
|
9
15
|
## [1.3.0] - 2022-07-22
|
10
16
|
|
11
17
|
### Added
|
@@ -48,7 +54,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
48
54
|
|
49
55
|
- 🎉 Initial release! 🎉
|
50
56
|
|
51
|
-
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.
|
57
|
+
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.3.1...HEAD
|
58
|
+
[1.3.1]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.3.0...v1.3.1
|
59
|
+
[1.3.0]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.2.1...v1.3.0
|
52
60
|
[1.2.1]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.2.0...v1.2.1
|
53
61
|
[1.2.0]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.1.0...v1.2.0
|
54
62
|
[1.1.0]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.0.1...v1.1.0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
syntax_tree-haml (1.3.
|
4
|
+
syntax_tree-haml (1.3.1)
|
5
5
|
haml (>= 5.2)
|
6
6
|
prettier_print
|
7
7
|
syntax_tree (>= 2.0.1)
|
@@ -22,10 +22,10 @@ GEM
|
|
22
22
|
simplecov_json_formatter (~> 0.1)
|
23
23
|
simplecov-html (0.12.3)
|
24
24
|
simplecov_json_formatter (0.1.4)
|
25
|
-
syntax_tree (3.2.
|
25
|
+
syntax_tree (3.2.1)
|
26
26
|
prettier_print
|
27
27
|
temple (0.8.2)
|
28
|
-
tilt (2.0.
|
28
|
+
tilt (2.0.11)
|
29
29
|
|
30
30
|
PLATFORMS
|
31
31
|
ruby
|
@@ -123,6 +123,8 @@ module SyntaxTree
|
|
123
123
|
|
124
124
|
LiteralHashValue = Struct.new(:value)
|
125
125
|
|
126
|
+
StringHashValue = Struct.new(:value, :quote)
|
127
|
+
|
126
128
|
# When formatting a tag, there are a lot of different kinds of things that
|
127
129
|
# can be printed out. There's the tag name, the attributes, the content,
|
128
130
|
# etc. This object is responsible for housing all of those parts.
|
@@ -220,19 +222,34 @@ module SyntaxTree
|
|
220
222
|
private
|
221
223
|
|
222
224
|
def format_value(q, hash, level = 0)
|
225
|
+
quote = SyntaxTree::Formatter::OPTIONS[:quote]
|
226
|
+
|
223
227
|
q.group do
|
224
228
|
q.text("{")
|
225
229
|
q.indent do
|
226
230
|
q.group do
|
227
231
|
q.breakable(level == 0 ? "" : " ")
|
228
232
|
q.seplist(hash, nil, :each_pair) do |key, value|
|
229
|
-
|
233
|
+
if key.match?(/^@|[-:]/)
|
234
|
+
q.text("#{quote}#{Quotes.normalize(key, quote)}#{quote}:")
|
235
|
+
else
|
236
|
+
q.text("#{key}:")
|
237
|
+
end
|
238
|
+
|
230
239
|
q.text(" ")
|
231
240
|
|
232
|
-
|
241
|
+
case value
|
242
|
+
when Hash
|
233
243
|
format_value(q, value, level + 1)
|
244
|
+
when LiteralHashValue
|
245
|
+
q.text(value.value)
|
246
|
+
when StringLiteral
|
247
|
+
qq = Formatter.new("")
|
248
|
+
qq.with_target(q.target) { value.format(qq) }
|
249
|
+
when String
|
250
|
+
q.text("#{quote}#{Quotes.normalize(value, quote)}#{quote}")
|
234
251
|
else
|
235
|
-
q.text(
|
252
|
+
q.text(value.to_s)
|
236
253
|
end
|
237
254
|
end
|
238
255
|
end
|
@@ -244,27 +261,6 @@ module SyntaxTree
|
|
244
261
|
end
|
245
262
|
end
|
246
263
|
|
247
|
-
def self.hash_key(key)
|
248
|
-
if key.match?(/^@|[-:]/)
|
249
|
-
quote = SyntaxTree::Formatter::OPTIONS[:quote]
|
250
|
-
"#{quote}#{Quotes.normalize(key, quote)}#{quote}:"
|
251
|
-
else
|
252
|
-
"#{key}:"
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
def self.hash_value(value)
|
257
|
-
case value
|
258
|
-
when LiteralHashValue
|
259
|
-
value.value
|
260
|
-
when String
|
261
|
-
quote = SyntaxTree::Formatter::OPTIONS[:quote]
|
262
|
-
"#{quote}#{Quotes.normalize(value, quote)}#{quote}"
|
263
|
-
else
|
264
|
-
value.to_s
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
264
|
# Visit a tag node.
|
269
265
|
def visit_tag(node)
|
270
266
|
parts = PartList.new(node)
|
@@ -405,7 +401,7 @@ module SyntaxTree
|
|
405
401
|
::Haml::AttributeParser.parse(source)
|
406
402
|
parsed.to_h { |key, value| [key, parse_attributes(value)] }
|
407
403
|
in [:program, [[:string_literal, *], *]]
|
408
|
-
source[
|
404
|
+
SyntaxTree.parse(source).statements.body[0]
|
409
405
|
else
|
410
406
|
LiteralHashValue.new(source)
|
411
407
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syntax_tree-haml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Newton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|