hamli 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfe5c703b08f1580b7b3bf603b45984d68c1ccaff5675b0243a838a190597366
4
- data.tar.gz: b5af88cc968267fdbc9ae35806a0d6fef3fb749b1939ce42a19d635b00f0c767
3
+ metadata.gz: 9f1faa1d3b9fa40c999ab475131a1cdf13a0cf97ad348b57a4d3fcbd2028e915
4
+ data.tar.gz: 33b020dd8ee73741bc3e262e48c0cab0e7d7be24eb1df90deecd322c6ae4237f
5
5
  SHA512:
6
- metadata.gz: a29fe320a9c23065a6d897eab4acaf1e97b2303c11e0ec28854eb37bd50507a95247edee7a315dfa8b1e91af0be39ec79a1e4ec996220905084e9efa051fc285
7
- data.tar.gz: cfcee2c4310365319915007a790d2962a88913180f21baae95857db5493c911fb09da9d152ac0993e01de4f684e141c73646466d1b31181fde85a8dbcde5196e
6
+ metadata.gz: 6ad5489d23376861eecd2b6de81ef2c9e9fd97cd57a81cc0679a59ae7e7500a4c4ddeba8831281f02c2e110657aaccf7751c89f5497f2dfc8c153daf86e17082
7
+ data.tar.gz: eceab6eadc445020e237eaa39f8b34a4b9007cc261327dc011ec97e00420532d51fd237c1614bc830874aad87cad520a3642dda41cb518dc1f1cc7f8303d9d9a
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.4.0 - 2022-01-26
6
+
7
+ ### Added
8
+
9
+ - Add :file option for better error report.
10
+
11
+ ### Fixed
12
+
13
+ - Fix error from parse_text_block on some case.
14
+ - Fix filter bug on :text node.
15
+ - Fix parse_interpolate_line bug.
16
+ - Fix haml comment parser bug.
17
+ - Fix pipe multi-line handling.
18
+
5
19
  ## 0.3.0 - 2022-01-26
6
20
 
7
21
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hamli (0.3.0)
4
+ hamli (0.4.0)
5
5
  temple
6
6
 
7
7
  GEM
@@ -14,11 +14,10 @@ module Hamli
14
14
  [:hamli, :position, begin_, end_, compile(expression)]
15
15
  end
16
16
 
17
- # @param [String] type
18
17
  # @param [Array] expression
19
18
  # @return [Array]
20
- def on_hamli_text(type, expression)
21
- [:hamli, :text, type, compile(expression)]
19
+ def on_hamli_text(expression)
20
+ [:hamli, :text, compile(expression)]
22
21
  end
23
22
  end
24
23
  end
data/lib/hamli/parser.rb CHANGED
@@ -4,6 +4,15 @@ require 'temple'
4
4
 
5
5
  module Hamli
6
6
  class Parser < ::Temple::Parser
7
+ define_options(
8
+ :file
9
+ )
10
+
11
+ def initialize(_options = {})
12
+ super
13
+ @file_path = options[:file] || '(__TEMPLATE__)'
14
+ end
15
+
7
16
  # @param [String] source Haml template source.
8
17
  # @return [Array]
9
18
  def call(source)
@@ -351,8 +360,9 @@ module Hamli
351
360
  # ^^^^^^
352
361
  def parse_haml_comment_line
353
362
  @scanner.pos += 2
363
+ @scanner.scan(/[^\r\n]*/)
354
364
  while !@scanner.eos? && (@scanner.match?(/[ \t]*(?=\r|$)/) || peek_indent > @indents.last)
355
- @scanner.skip(/[^\r\n]*/)
365
+ @scanner.scan(/[^\r\n]*/)
356
366
  parse_line_ending
357
367
  end
358
368
  end
@@ -387,7 +397,7 @@ module Hamli
387
397
 
388
398
  # @return [Array, nil]
389
399
  def parse_interpolate_line
390
- return unless @scanner.match?(/[^\r\n]/)
400
+ return unless @scanner.match?(/[^\r\n]+/)
391
401
 
392
402
  begin_ = @scanner.charpos
393
403
  value = @scanner.matched
@@ -425,11 +435,14 @@ module Hamli
425
435
  while result.end_with?(',') || result.end_with?('|')
426
436
  syntax_error!(Errors::UnexpectedEosError) unless @scanner.scan(/\r?\n/)
427
437
 
428
- result.delete_suffix('|')
429
438
  result << "\n"
430
439
  result << @scanner.scan(/[^\r\n]*/)
431
440
  end
432
- result
441
+ lines = result.lines
442
+ if lines.length >= 2 && lines.all? { |line| line.end_with?("|\n") }
443
+ result.gsub!(/\|$/, '')
444
+ end
445
+ result.delete_suffix("\n")
433
446
  end
434
447
 
435
448
  # @param [Class] syntax_error_class A child class of Hamli::Errors::HamlSyntaxError.
@@ -446,7 +459,7 @@ module Hamli
446
459
 
447
460
  # @return [Integer]
448
461
  def indent_from_last_match
449
- @scanner.matched.chars.map do |char|
462
+ (@scanner.matched || '').chars.map do |char|
450
463
  case char
451
464
  when "\t"
452
465
  4
data/lib/hamli/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hamli
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura