syntax_tree-haml 4.0.1 → 4.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +3 -2
- data/CHANGELOG.md +16 -1
- data/Gemfile.lock +3 -3
- data/lib/syntax_tree/haml/format.rb +19 -10
- data/lib/syntax_tree/haml/version.rb +1 -1
- data/lib/syntax_tree/haml.rb +20 -0
- data/syntax_tree-haml.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c410fddce7b0b3de3dca5f4f0ff6f1f495f70897d1a07f956ceb3cedb8a3bc42
|
4
|
+
data.tar.gz: 6f4866aefe38f780411b65fa2671a9f9491aba0249884dc6c6f627d1a76f5520
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b79312706a5519a3d6933040c99f353ca344290d9c026d27ee2b6aa5b092ef8f03e735ae5e0de4b832bf7acbdceeceb844bdb9ca46ddd1b6aa9ea3f8c1d37cbc
|
7
|
+
data.tar.gz: e0993ba8112bb8149cbcaf972ba588e2b347431254bf0d3d0a63482657d18d5f70af4aa58f185b9d696d5c028bae55621cb483ad9800474242c2236be3043e98
|
data/.github/workflows/main.yml
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
name: Main
|
2
|
+
|
2
3
|
on:
|
3
4
|
push:
|
4
5
|
branches:
|
5
6
|
- main
|
6
7
|
pull_request: {}
|
8
|
+
|
7
9
|
jobs:
|
8
10
|
ci:
|
9
11
|
strategy:
|
@@ -14,10 +16,9 @@ jobs:
|
|
14
16
|
- '2.7.5'
|
15
17
|
- '3.0'
|
16
18
|
- '3.1'
|
19
|
+
- '3.2'
|
17
20
|
name: CI
|
18
21
|
runs-on: ubuntu-latest
|
19
|
-
env:
|
20
|
-
CI: true
|
21
22
|
steps:
|
22
23
|
- uses: actions/checkout@v3
|
23
24
|
- uses: ruby/setup-ruby@v1
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,19 @@ 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.3] - 2023-03-12
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
- Fixed a bug where blank lines were being inserted into filter nodes accidentally.
|
14
|
+
|
15
|
+
## [4.0.2] - 2023-03-09
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
|
19
|
+
- Require `prettier_print` `1.2.1` or higher to fix the infinite loop bug.
|
20
|
+
- Maintain blank lines in nested nodes.
|
21
|
+
|
9
22
|
## [4.0.1] - 2023-03-07
|
10
23
|
|
11
24
|
### Changed
|
@@ -93,7 +106,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
93
106
|
|
94
107
|
- 🎉 Initial release! 🎉
|
95
108
|
|
96
|
-
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v4.0.
|
109
|
+
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v4.0.3...HEAD
|
110
|
+
[4.0.3]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v4.0.2...v4.0.3
|
111
|
+
[4.0.2]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v4.0.1...v4.0.2
|
97
112
|
[4.0.1]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v4.0.0...v4.0.1
|
98
113
|
[4.0.0]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v3.0.0...v4.0.0
|
99
114
|
[3.0.0]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v2.0.0...v3.0.0
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
syntax_tree-haml (4.0.
|
4
|
+
syntax_tree-haml (4.0.3)
|
5
5
|
haml (>= 5.2)
|
6
|
-
prettier_print (>= 1.
|
6
|
+
prettier_print (>= 1.2.1)
|
7
7
|
syntax_tree (>= 6.0.0)
|
8
8
|
|
9
9
|
GEM
|
@@ -15,7 +15,7 @@ GEM
|
|
15
15
|
thor
|
16
16
|
tilt
|
17
17
|
minitest (5.18.0)
|
18
|
-
prettier_print (1.2.
|
18
|
+
prettier_print (1.2.1)
|
19
19
|
rake (13.0.6)
|
20
20
|
simplecov (0.22.0)
|
21
21
|
docile (~> 1.1)
|
@@ -69,15 +69,17 @@ module SyntaxTree
|
|
69
69
|
q.breakable_force
|
70
70
|
first = true
|
71
71
|
|
72
|
-
node.value[:text]
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
node.value[:text]
|
73
|
+
.rstrip
|
74
|
+
.each_line(chomp: true) do |line|
|
75
|
+
if first
|
76
|
+
first = false
|
77
|
+
else
|
78
|
+
q.breakable_force
|
79
|
+
end
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
+
q.text(line)
|
82
|
+
end
|
81
83
|
end
|
82
84
|
end
|
83
85
|
end
|
@@ -124,8 +126,7 @@ module SyntaxTree
|
|
124
126
|
|
125
127
|
node.children.each do |child|
|
126
128
|
q.breakable_force if previous_line && (child.line - previous_line) > 1
|
127
|
-
previous_line =
|
128
|
-
child.children.any? ? child.children.last.line : child.line
|
129
|
+
previous_line = child.last_line
|
129
130
|
|
130
131
|
visit(child)
|
131
132
|
q.breakable_force
|
@@ -504,9 +505,17 @@ module SyntaxTree
|
|
504
505
|
q.group do
|
505
506
|
q.group { yield }
|
506
507
|
q.indent do
|
508
|
+
previous_line = nil
|
509
|
+
|
507
510
|
node.children.each do |child|
|
508
511
|
q.breakable_force
|
512
|
+
|
513
|
+
if previous_line && (child.line - previous_line) > 1
|
514
|
+
q.breakable_force
|
515
|
+
end
|
516
|
+
|
509
517
|
visit(child)
|
518
|
+
previous_line = child.last_line
|
510
519
|
end
|
511
520
|
end
|
512
521
|
end
|
data/lib/syntax_tree/haml.rb
CHANGED
@@ -82,10 +82,30 @@ class Haml::Parser::ParseNode
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
# This is our entrypoint for the formatter. We effectively delegate this to
|
86
|
+
# accepting the Format visitor.
|
85
87
|
def format(q)
|
86
88
|
accept(SyntaxTree::Haml::Format.new(q))
|
87
89
|
end
|
88
90
|
|
91
|
+
# When we're formatting a list of children, we need to know the last line a
|
92
|
+
# node is on. This is because the next node in the list of children should be
|
93
|
+
# at most 1 blank line below the last line of the previous node. We cache this
|
94
|
+
# because at worst it requires walking the entire tree because filter nodes
|
95
|
+
# can take up multiple lines.
|
96
|
+
def last_line
|
97
|
+
@last_line ||=
|
98
|
+
if children.any?
|
99
|
+
children.last.last_line
|
100
|
+
elsif type == :filter
|
101
|
+
line + value[:text].rstrip.count("\n") + 1
|
102
|
+
else
|
103
|
+
line
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# This is our entrypoint for the pretty printer. We effectively delegate this
|
108
|
+
# to accepting the PrettyPrint visitor.
|
89
109
|
def pretty_print(q)
|
90
110
|
accept(SyntaxTree::Haml::PrettyPrint.new(q))
|
91
111
|
end
|
data/syntax_tree-haml.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.require_paths = %w[lib]
|
26
26
|
|
27
27
|
spec.add_dependency "haml", ">= 5.2"
|
28
|
-
spec.add_dependency "prettier_print", ">= 1.
|
28
|
+
spec.add_dependency "prettier_print", ">= 1.2.1"
|
29
29
|
spec.add_dependency "syntax_tree", ">= 6.0.0"
|
30
30
|
|
31
31
|
spec.add_development_dependency "bundler"
|
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.0.
|
4
|
+
version: 4.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Newton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.2.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.2.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: syntax_tree
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|