haml_lint 0.49.1 → 0.49.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd85ce9cb4a413016f9453199aed1366de9cd4fde3d1b0a61a9f56bf33d7b05a
|
4
|
+
data.tar.gz: cde16448577a5fda06012f39d523a7c02bbaf971a798ba0f76217245570d97cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53606b8698b377840f21a9dcaf4861e60958a80457a75a0503ecce33fb66170a39a25430a6cacfb34872765f3dd45299048a5a8b09bffe98117c9b7695f4f6b7
|
7
|
+
data.tar.gz: 90ff4f5eb6d627df9447d34dee4326f117316528a0ab08ca22ca3cfaf7560249b7d5bfce10dc88afb0870a62eea7931d60d22cceaa45ebd7a4399feac3895823
|
@@ -394,7 +394,7 @@ module HamlLint::RubyExtraction
|
|
394
394
|
|
395
395
|
# Adds chunks for the interpolation within the given code
|
396
396
|
def add_interpolation_chunks(node, code, haml_line_index, indent:, line_start_index: 0)
|
397
|
-
HamlLint::Utils.handle_interpolation_with_indexes(code) do |scanner, line_index,
|
397
|
+
HamlLint::Utils.handle_interpolation_with_indexes(code) do |scanner, line_index, line_char_index|
|
398
398
|
escapes = scanner[2].size
|
399
399
|
next if escapes.odd?
|
400
400
|
char = scanner[3] # '{', '@' or '$'
|
@@ -403,14 +403,16 @@ module HamlLint::RubyExtraction
|
|
403
403
|
next
|
404
404
|
end
|
405
405
|
|
406
|
-
|
407
|
-
|
406
|
+
line_start_char_index = line_char_index
|
407
|
+
line_start_char_index += line_start_index if line_index == 0
|
408
|
+
code_start_char_index = scanner.charpos
|
408
409
|
|
409
|
-
|
410
|
+
# This moves the scanner
|
411
|
+
Haml::Util.balance(scanner, '{', '}', 1)
|
410
412
|
|
411
413
|
# Need to manually get the code now that we have positions so that all whitespace is present,
|
412
414
|
# because Haml::Util.balance does a strip...
|
413
|
-
interpolated_code = code[
|
415
|
+
interpolated_code = code[code_start_char_index...scanner.charpos - 1]
|
414
416
|
|
415
417
|
if interpolated_code.include?("\n")
|
416
418
|
# We can't correct multiline interpolation.
|
@@ -430,7 +432,7 @@ module HamlLint::RubyExtraction
|
|
430
432
|
interpolated_code = "#{' ' * indent}#{script_output_prefix}#{interpolated_code}"
|
431
433
|
@ruby_chunks << InterpolationChunk.new(node, [interpolated_code],
|
432
434
|
haml_line_index: haml_line_index + line_index,
|
433
|
-
start_char_index:
|
435
|
+
start_char_index: line_start_char_index,
|
434
436
|
end_marker_indent: indent)
|
435
437
|
end
|
436
438
|
end
|
@@ -107,20 +107,22 @@ module HamlLint::RubyExtraction
|
|
107
107
|
statement_start_line_indexes = find_statement_start_line_indexes(to_ruby_lines)
|
108
108
|
|
109
109
|
continued_line_indent_delta = 2
|
110
|
+
continued_line_min_indent = 2
|
110
111
|
|
111
112
|
cur_line_start_index = nil
|
112
113
|
line_start_indexes_that_need_pipes = []
|
113
114
|
haml_output_prefix = first_output_haml_prefix
|
114
|
-
to_haml_lines = to_ruby_lines.map.with_index do |line, i|
|
115
|
+
to_haml_lines = to_ruby_lines.map.with_index do |line, i| # rubocop:disable Metrics/BlockLength
|
115
116
|
if line !~ /\S/
|
116
117
|
# whitespace or empty lines, we don't want any indentation
|
117
118
|
''
|
118
119
|
elsif statement_start_line_indexes.include?(i)
|
119
120
|
cur_line_start_index = i
|
120
121
|
code_start = line.index(/\S/)
|
122
|
+
continued_line_min_indent = code_start + 2
|
121
123
|
if line[code_start..].start_with?(script_output_ruby_prefix)
|
122
124
|
line = line.sub(script_output_ruby_prefix, '')
|
123
|
-
# The
|
125
|
+
# The next lines may have been too indented because of the "HL.out = " prefix
|
124
126
|
continued_line_indent_delta = 2 - script_output_ruby_prefix.size
|
125
127
|
new_line = "#{line[0...code_start]}#{haml_output_prefix} #{line[code_start..]}"
|
126
128
|
haml_output_prefix = '='
|
@@ -134,7 +136,12 @@ module HamlLint::RubyExtraction
|
|
134
136
|
line_start_indexes_that_need_pipes << cur_line_start_index
|
135
137
|
end
|
136
138
|
|
137
|
-
HamlLint::Utils.indent(line, continued_line_indent_delta)
|
139
|
+
line = HamlLint::Utils.indent(line, continued_line_indent_delta)
|
140
|
+
cur_indent = line[/^ */].size
|
141
|
+
if cur_indent < continued_line_min_indent
|
142
|
+
line = HamlLint::Utils.indent(line, continued_line_min_indent - cur_indent)
|
143
|
+
end
|
144
|
+
line
|
138
145
|
end
|
139
146
|
end
|
140
147
|
|
data/lib/haml_lint/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.49.
|
4
|
+
version: 0.49.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|