Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dadbe84

Browse files
committed
fails with actual liquid, not sure why
1 parent 1a2c0b8 commit dadbe84

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/coderay/scanners/liquid.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ class Liquid < Scanner
1212

1313
LIQUID_BLOCK = /
1414
({[{|%])
15+
\s
1516
(.*?)
17+
\s
1618
([%|}]})
1719
/
1820

@@ -25,26 +27,26 @@ def setup
2527
@liquid_attribute_scanner = CodeRay.scanner :html, tokens: @tokens, keep_tokens: true, keep_stat: true
2628
end
2729

28-
def scan_tokens
30+
def scan_tokens(tokens, options)
2931
until eos?
30-
if (match = scan_until(/(?=#{START_OF_LIQUID})/o) || scan_reset) and not match.empty?
31-
@html_scanner.tokenize match, tokens: encoder
32+
if (match = scan_until(/(?=#{START_OF_LIQUID})/o) || scan_rest) and not match.empty?
33+
@html_scanner.tokenize match, tokens: tokens
3234
elsif match = scan(/#{LIQUID_BLOCK}/o)
3335
start_tag = self[1]
3436
code = self[2]
3537
end_tag = self[3]
3638

37-
encoder.begin_group :inline
38-
encoder.text_token start_tag, :inline_delimiter
39+
tokens.begin_group :inline
40+
tokens.text_token start_tag, :inline_delimiter
3941

4042
unless code.empty?
41-
@liquid_attribute_scanner.tokenize code, tokens: encoder, state: :attribute
43+
@liquid_attribute_scanner.tokenize code, tokens: tokens, state: :attribute
4244
end
4345

44-
encoder.text_token end_tag, :inline_delimiter unless end_tag.empty?
45-
encoder.end_group :inline
46+
tokens.text_token end_tag, :inline_delimiter unless end_tag.empty?
47+
tokens.end_group :inline
4648
else
47-
raise_inspect 'else-case reached!', encoder
49+
raise_inspect 'else-case reached!', tokens
4850
end
4951
end
5052
end

0 commit comments

Comments
 (0)