syntax_tree-haml 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/Gemfile.lock +3 -3
- data/README.md +1 -1
- data/lib/syntax_tree/haml/format.rb +37 -17
- data/lib/syntax_tree/haml/version.rb +1 -1
- data/lib/syntax_tree/haml.rb +5 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bddc6888f36d28a1f0829960a0be5a71edb719342895c68a1635f474fe977634
|
4
|
+
data.tar.gz: b56774e91f16a8521ca888824f84a4d9dbd3242837d74107add7255f3bc571d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9b36d29e67e7ea5424825a8344580c3560e7a49672fceb121eec6959a4e0becbb0a8481e935450c3566e6c5647062f90ad6b9411d2d8ce202d2c98b4695eece
|
7
|
+
data.tar.gz: 35dcaa252fdfe1b53bf8904feb2d312cd7c6f353bc48343f0944a030c315a9289bce62a6578f5c6d5813d992c35681cb9770abd66e2cc5ea53fab3389b8b4f7f
|
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.2] - 2022-09-19
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Properly support unescaping plain and script.
|
14
|
+
|
9
15
|
## [1.3.1] - 2022-08-01
|
10
16
|
|
11
17
|
### Changed
|
@@ -54,7 +60,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
54
60
|
|
55
61
|
- 🎉 Initial release! 🎉
|
56
62
|
|
57
|
-
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.3.
|
63
|
+
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.3.2...HEAD
|
64
|
+
[1.3.2]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.3.1...v1.3.2
|
58
65
|
[1.3.1]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.3.0...v1.3.1
|
59
66
|
[1.3.0]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.2.1...v1.3.0
|
60
67
|
[1.2.1]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.2.0...v1.2.1
|
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.2)
|
5
5
|
haml (>= 5.2)
|
6
6
|
prettier_print
|
7
7
|
syntax_tree (>= 2.0.1)
|
@@ -13,7 +13,7 @@ GEM
|
|
13
13
|
haml (5.2.2)
|
14
14
|
temple (>= 0.8.0)
|
15
15
|
tilt
|
16
|
-
minitest (5.16.
|
16
|
+
minitest (5.16.3)
|
17
17
|
prettier_print (0.1.0)
|
18
18
|
rake (13.0.6)
|
19
19
|
simplecov (0.21.2)
|
@@ -22,7 +22,7 @@ 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.
|
25
|
+
syntax_tree (3.6.0)
|
26
26
|
prettier_print
|
27
27
|
temple (0.8.2)
|
28
28
|
tilt (2.0.11)
|
data/README.md
CHANGED
@@ -55,7 +55,7 @@ template.haml 1ms
|
|
55
55
|
|
56
56
|
## Development
|
57
57
|
|
58
|
-
After checking out the repo, run `
|
58
|
+
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake test` to run the tests. You can also run `bundle console` for an interactive prompt that will allow you to experiment.
|
59
59
|
|
60
60
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
61
61
|
|
@@ -3,6 +3,22 @@
|
|
3
3
|
module SyntaxTree
|
4
4
|
module Haml
|
5
5
|
class Format < Visitor
|
6
|
+
class Formatter < ::SyntaxTree::Formatter
|
7
|
+
attr_reader :literal_lines, :quote
|
8
|
+
|
9
|
+
def initialize(source, ...)
|
10
|
+
@literal_lines = {}
|
11
|
+
source
|
12
|
+
.lines
|
13
|
+
.each
|
14
|
+
.with_index(1) do |line, index|
|
15
|
+
@literal_lines[index] = line.rstrip if line.start_with?("!")
|
16
|
+
end
|
17
|
+
|
18
|
+
super(source, ...)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
attr_reader :q
|
7
23
|
|
8
24
|
def initialize(q)
|
@@ -62,12 +78,11 @@ module SyntaxTree
|
|
62
78
|
text = node.value[:text].strip
|
63
79
|
|
64
80
|
if text.include?("\n")
|
81
|
+
separator = -> { q.breakable(force: true) }
|
82
|
+
|
65
83
|
q.indent do
|
66
|
-
|
67
|
-
q.seplist(
|
68
|
-
text.split("\n"),
|
69
|
-
-> { q.breakable(force: true) }
|
70
|
-
) { |segment| q.text(segment) }
|
84
|
+
separator.call
|
85
|
+
q.seplist(text.split("\n"), separator) { |segment| q.text(segment) }
|
71
86
|
end
|
72
87
|
else
|
73
88
|
q.text(" #{text}")
|
@@ -76,9 +91,13 @@ module SyntaxTree
|
|
76
91
|
|
77
92
|
# https://haml.info/docs/yardoc/file.REFERENCE.html#plain-text
|
78
93
|
def visit_plain(node)
|
79
|
-
|
80
|
-
|
81
|
-
|
94
|
+
if line = q.literal_lines[node.line]
|
95
|
+
q.text(line)
|
96
|
+
else
|
97
|
+
text = node.value[:text]
|
98
|
+
q.text("\\") if escaped?(text)
|
99
|
+
q.text(text)
|
100
|
+
end
|
82
101
|
end
|
83
102
|
|
84
103
|
# Visit the root node of the AST.
|
@@ -92,12 +111,14 @@ module SyntaxTree
|
|
92
111
|
# https://haml.info/docs/yardoc/file.REFERENCE.html#inserting_ruby
|
93
112
|
def visit_script(node)
|
94
113
|
with_children(node) do
|
95
|
-
q.
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
114
|
+
if line = q.literal_lines[node.line]
|
115
|
+
q.text(line)
|
116
|
+
else
|
117
|
+
q.text("&") if node.value[:escape_html]
|
118
|
+
q.text(node.value[:preserve] ? "~" : "=")
|
119
|
+
q.text(" ")
|
120
|
+
q.text(node.value[:text].strip)
|
121
|
+
end
|
101
122
|
end
|
102
123
|
end
|
103
124
|
|
@@ -222,7 +243,7 @@ module SyntaxTree
|
|
222
243
|
private
|
223
244
|
|
224
245
|
def format_value(q, hash, level = 0)
|
225
|
-
quote =
|
246
|
+
quote = q.quote
|
226
247
|
|
227
248
|
q.group do
|
228
249
|
q.text("{")
|
@@ -244,8 +265,7 @@ module SyntaxTree
|
|
244
265
|
when LiteralHashValue
|
245
266
|
q.text(value.value)
|
246
267
|
when StringLiteral
|
247
|
-
|
248
|
-
qq.with_target(q.target) { value.format(qq) }
|
268
|
+
value.format(q)
|
249
269
|
when String
|
250
270
|
q.text("#{quote}#{Quotes.normalize(value, quote)}#{quote}")
|
251
271
|
else
|
data/lib/syntax_tree/haml.rb
CHANGED
@@ -34,7 +34,11 @@ module SyntaxTree
|
|
34
34
|
# This is the main entrypoint for the formatter. It parses the source,
|
35
35
|
# builds a formatter, then pretty prints the result.
|
36
36
|
def self.format(source, maxwidth = 80)
|
37
|
-
|
37
|
+
formatter = Format::Formatter.new(source, +"", maxwidth)
|
38
|
+
parse(source).format(formatter)
|
39
|
+
|
40
|
+
formatter.flush
|
41
|
+
formatter.output
|
38
42
|
end
|
39
43
|
|
40
44
|
# This is a required API for syntax tree which just delegates to File.read.
|
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.2
|
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-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '0'
|
154
154
|
requirements: []
|
155
|
-
rubygems_version: 3.3.
|
155
|
+
rubygems_version: 3.3.21
|
156
156
|
signing_key:
|
157
157
|
specification_version: 4
|
158
158
|
summary: Syntax Tree support for Haml
|