syntax_tree-haml 3.0.0 → 4.0.0
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 +7 -0
- data/Gemfile.lock +12 -16
- data/lib/syntax_tree/haml/format.rb +44 -21
- data/lib/syntax_tree/haml/version.rb +1 -1
- data/syntax_tree-haml.gemspec +2 -3
- metadata +5 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '090ea651f3d163420a8d52ec028c152238f2184770d1a1de3771391e37804550'
|
|
4
|
+
data.tar.gz: b9b1241849203a2b0ded757e135319d3f05c200cc6add2ca42991de03de28f7c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9ce10d5f934ab991630d7893a4439a829db161a796f54fa560407e07ab513046dd495cf8b84cd91c3aa59acb68543e0a5b6f622c18c48aa9c9aa2c54ce30378a
|
|
7
|
+
data.tar.gz: 6c706e13ce097c7dbf3484701cb88cb6007683dc825f0a4a0b9666fd0fc0bf0dee5fa1b92ba4e63528d118480a0e66df5aa363a9bb0607c5e08ec8b638e0694b
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [4.0.0] - 2023-03-07
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Required syntax_tree version 6.0.0 or higher.
|
|
14
|
+
- Fixed up hash attribute parser to handle multiline hashes using Syntax Tree itself.
|
|
15
|
+
|
|
9
16
|
## [3.0.0] - 2022-12-23
|
|
10
17
|
|
|
11
18
|
### Changed
|
data/Gemfile.lock
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
syntax_tree-haml (
|
|
5
|
-
haml (>= 5.2
|
|
4
|
+
syntax_tree-haml (4.0.0)
|
|
5
|
+
haml (>= 5.2)
|
|
6
6
|
prettier_print (>= 1.0.0)
|
|
7
|
-
syntax_tree (>=
|
|
7
|
+
syntax_tree (>= 6.0.0)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
@@ -14,27 +14,23 @@ GEM
|
|
|
14
14
|
temple (>= 0.8.2)
|
|
15
15
|
thor
|
|
16
16
|
tilt
|
|
17
|
-
minitest (5.
|
|
18
|
-
prettier_print (1.
|
|
17
|
+
minitest (5.18.0)
|
|
18
|
+
prettier_print (1.2.0)
|
|
19
19
|
rake (13.0.6)
|
|
20
|
-
simplecov (0.
|
|
20
|
+
simplecov (0.22.0)
|
|
21
21
|
docile (~> 1.1)
|
|
22
22
|
simplecov-html (~> 0.11)
|
|
23
23
|
simplecov_json_formatter (~> 0.1)
|
|
24
24
|
simplecov-html (0.12.3)
|
|
25
25
|
simplecov_json_formatter (0.1.4)
|
|
26
|
-
syntax_tree (
|
|
27
|
-
prettier_print (>= 1.
|
|
28
|
-
temple (0.
|
|
26
|
+
syntax_tree (6.0.2)
|
|
27
|
+
prettier_print (>= 1.2.0)
|
|
28
|
+
temple (0.10.0)
|
|
29
29
|
thor (1.2.1)
|
|
30
|
-
tilt (2.0
|
|
30
|
+
tilt (2.1.0)
|
|
31
31
|
|
|
32
32
|
PLATFORMS
|
|
33
|
-
|
|
34
|
-
x86_64-darwin-19
|
|
35
|
-
x86_64-darwin-20
|
|
36
|
-
x86_64-darwin-21
|
|
37
|
-
x86_64-linux
|
|
33
|
+
arm64-darwin-22
|
|
38
34
|
|
|
39
35
|
DEPENDENCIES
|
|
40
36
|
bundler
|
|
@@ -44,4 +40,4 @@ DEPENDENCIES
|
|
|
44
40
|
syntax_tree-haml!
|
|
45
41
|
|
|
46
42
|
BUNDLED WITH
|
|
47
|
-
2.
|
|
43
|
+
2.4.1
|
|
@@ -161,7 +161,6 @@ module SyntaxTree
|
|
|
161
161
|
end
|
|
162
162
|
|
|
163
163
|
LiteralHashValue = Struct.new(:value)
|
|
164
|
-
StringHashValue = Struct.new(:value, :quote)
|
|
165
164
|
|
|
166
165
|
# When formatting a tag, there are a lot of different kinds of things that
|
|
167
166
|
# can be printed out. There's the tag name, the attributes, the content,
|
|
@@ -274,7 +273,7 @@ module SyntaxTree
|
|
|
274
273
|
q.group do
|
|
275
274
|
level == 0 ? q.breakable_empty : q.breakable_space
|
|
276
275
|
q.seplist(hash, nil, :each_pair) do |key, value|
|
|
277
|
-
if key.match?(/^@|[-:]/)
|
|
276
|
+
if key.match?(/^@|[-:]/) && !key.match?(/^["']/)
|
|
278
277
|
q.text("#{quote}#{Quotes.normalize(key, quote)}#{quote}:")
|
|
279
278
|
else
|
|
280
279
|
q.text("#{key}:")
|
|
@@ -352,17 +351,7 @@ module SyntaxTree
|
|
|
352
351
|
# we're going to print them out here.
|
|
353
352
|
if node.value[:dynamic_attributes].old
|
|
354
353
|
parts << PlainPart.new("%div") if parts.empty?
|
|
355
|
-
|
|
356
|
-
if ::Haml::AttributeParser.available?
|
|
357
|
-
dynamic = parse_attributes(node.value[:dynamic_attributes].old)
|
|
358
|
-
parts << if dynamic.is_a?(LiteralHashValue)
|
|
359
|
-
PlainPart.new(dynamic.value)
|
|
360
|
-
else
|
|
361
|
-
HashAttributesPart.new(dynamic)
|
|
362
|
-
end
|
|
363
|
-
else
|
|
364
|
-
parts << PlainPart.new(node.value[:dynamic_attributes].old)
|
|
365
|
-
end
|
|
354
|
+
parts << parse_attributes(node.value[:dynamic_attributes].old)
|
|
366
355
|
end
|
|
367
356
|
|
|
368
357
|
# https://haml.info/docs/yardoc/file.REFERENCE.html#object-reference-
|
|
@@ -438,18 +427,52 @@ module SyntaxTree
|
|
|
438
427
|
# Take a source string and attempt to parse it into a set of attributes
|
|
439
428
|
# that can be used to format the source.
|
|
440
429
|
def parse_attributes(source)
|
|
441
|
-
|
|
442
|
-
|
|
430
|
+
source = source.strip
|
|
431
|
+
source = source.start_with?("{") ? source : "{#{source}}"
|
|
443
432
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
433
|
+
program = SyntaxTree.parse(source)
|
|
434
|
+
return PlainPart.new(source) if program.nil?
|
|
435
|
+
|
|
436
|
+
node = program.statements.body.first
|
|
437
|
+
return PlainPart.new(source) unless node.is_a?(HashLiteral)
|
|
438
|
+
|
|
439
|
+
HashAttributesPart.new(parse_attributes_hash(source, node))
|
|
440
|
+
rescue Parser::ParseError
|
|
441
|
+
PlainPart.new(source)
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
def parse_attributes_hash(source, node, level = 1)
|
|
445
|
+
node.assocs.to_h do |assoc|
|
|
446
|
+
key =
|
|
447
|
+
case assoc.key
|
|
448
|
+
when StringLiteral
|
|
449
|
+
format(assoc.key)
|
|
450
|
+
when Label
|
|
451
|
+
assoc.key.value.delete_suffix(":")
|
|
452
|
+
when DynaSymbol
|
|
453
|
+
format(assoc.key).delete_prefix(":")
|
|
454
|
+
else
|
|
455
|
+
format(assoc.key)
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
value =
|
|
459
|
+
case assoc.value
|
|
460
|
+
when HashLiteral
|
|
461
|
+
parse_attributes_hash(source, assoc.value, level + 1)
|
|
462
|
+
when StringLiteral
|
|
463
|
+
assoc.value
|
|
464
|
+
else
|
|
465
|
+
LiteralHashValue.new(format(assoc.value, level * 2).lstrip)
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
[key, value]
|
|
450
469
|
end
|
|
451
470
|
end
|
|
452
471
|
|
|
472
|
+
def format(node, column = 0)
|
|
473
|
+
SyntaxTree::Formatter.format(+"", node, column)
|
|
474
|
+
end
|
|
475
|
+
|
|
453
476
|
def with_children(node)
|
|
454
477
|
if node.children.empty?
|
|
455
478
|
q.group { yield }
|
data/syntax_tree-haml.gemspec
CHANGED
|
@@ -24,10 +24,9 @@ Gem::Specification.new do |spec|
|
|
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
25
25
|
spec.require_paths = %w[lib]
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
spec.add_dependency "haml", ">= 5.2", "!= 6.0.0"
|
|
27
|
+
spec.add_dependency "haml", ">= 5.2"
|
|
29
28
|
spec.add_dependency "prettier_print", ">= 1.0.0"
|
|
30
|
-
spec.add_dependency "syntax_tree", ">=
|
|
29
|
+
spec.add_dependency "syntax_tree", ">= 6.0.0"
|
|
31
30
|
|
|
32
31
|
spec.add_development_dependency "bundler"
|
|
33
32
|
spec.add_development_dependency "minitest"
|
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:
|
|
4
|
+
version: 4.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kevin Newton
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-03-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: haml
|
|
@@ -17,9 +17,6 @@ dependencies:
|
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '5.2'
|
|
20
|
-
- - "!="
|
|
21
|
-
- !ruby/object:Gem::Version
|
|
22
|
-
version: 6.0.0
|
|
23
20
|
type: :runtime
|
|
24
21
|
prerelease: false
|
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -27,9 +24,6 @@ dependencies:
|
|
|
27
24
|
- - ">="
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
26
|
version: '5.2'
|
|
30
|
-
- - "!="
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: 6.0.0
|
|
33
27
|
- !ruby/object:Gem::Dependency
|
|
34
28
|
name: prettier_print
|
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -50,14 +44,14 @@ dependencies:
|
|
|
50
44
|
requirements:
|
|
51
45
|
- - ">="
|
|
52
46
|
- !ruby/object:Gem::Version
|
|
53
|
-
version:
|
|
47
|
+
version: 6.0.0
|
|
54
48
|
type: :runtime
|
|
55
49
|
prerelease: false
|
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
51
|
requirements:
|
|
58
52
|
- - ">="
|
|
59
53
|
- !ruby/object:Gem::Version
|
|
60
|
-
version:
|
|
54
|
+
version: 6.0.0
|
|
61
55
|
- !ruby/object:Gem::Dependency
|
|
62
56
|
name: bundler
|
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -159,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
159
153
|
- !ruby/object:Gem::Version
|
|
160
154
|
version: '0'
|
|
161
155
|
requirements: []
|
|
162
|
-
rubygems_version: 3.
|
|
156
|
+
rubygems_version: 3.4.1
|
|
163
157
|
signing_key:
|
|
164
158
|
specification_version: 4
|
|
165
159
|
summary: Syntax Tree support for Haml
|