@@ -362,25 +362,26 @@ def parse(text, filename, line_no, type, &include_callback)
362
362
363
363
private def normalize_comment_lines ( lines )
364
364
blank_line_regexp = /\A \s *\z /
365
+ lines = lines . dup
366
+ lines . shift while lines . first &.match? ( blank_line_regexp )
367
+ lines . pop while lines . last &.match? ( blank_line_regexp )
368
+
365
369
min_spaces = lines . map do |l |
366
- l [ /\A */ ] . size unless l . match? ( blank_line_regexp )
370
+ l . match ( /\A *(?= \S )/ ) &. end ( 0 )
367
371
end . compact . min
368
372
if min_spaces && min_spaces > 0
369
- lines = lines . map { |l | l [ min_spaces ..] || '' }
373
+ lines . map { |l | l [ min_spaces ..] || '' }
370
374
else
371
- lines = lines . dup
375
+ lines
372
376
end
373
- lines . shift while lines . first &.match? ( blank_line_regexp )
374
- lines . pop while lines . last &.match? ( blank_line_regexp )
375
- lines
376
377
end
377
378
378
379
# Take value lines of multiline directive
379
380
380
381
private def take_multiline_directive_value_lines ( directive , filename , line_no , lines , base_indent_size , indent_regexp , has_param )
381
382
return [ ] if lines . empty?
382
383
383
- first_indent_size = lines . first [ indent_regexp ] . size
384
+ first_indent_size = lines . first . match ( indent_regexp ) . end ( 0 )
384
385
385
386
# Blank line or unindented line is not part of multiline-directive value
386
387
return [ ] if first_indent_size <= base_indent_size
@@ -391,9 +392,9 @@ def parse(text, filename, line_no, type, &include_callback)
391
392
# line3
392
393
#
393
394
value_lines = lines . take_while do |l |
394
- l . rstrip [ indent_regexp ] . size > base_indent_size
395
+ l . rstrip . match ( indent_regexp ) . end ( 0 ) > base_indent_size
395
396
end
396
- min_indent = value_lines . map { |l | l [ indent_regexp ] . size } . min
397
+ min_indent = value_lines . map { |l | l . match ( indent_regexp ) . end ( 0 ) } . min
397
398
value_lines . map { |l | l [ min_indent ..] }
398
399
else
399
400
# Take indented lines accepting blank lines between them
0 commit comments