Skip to content

Commit 253fca4

Browse files
committed
change regexes constants to strings, still broken
1 parent 799227a commit 253fca4

File tree

1 file changed

+8
-80
lines changed

1 file changed

+8
-80
lines changed

lib/coderay/scanners/liquid.rb

Lines changed: 8 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -5,81 +5,13 @@ class Liquid < Scanner
55

66
register_for :liquid
77

8-
DIRECTIVE_KEYWORDS = /
9-
list|
10-
endlist|
11-
for|
12-
endfor|
13-
wrap|
14-
endwrap|
15-
if|
16-
endif|
17-
unless|
18-
endunless|
19-
elsif|
20-
assign|
21-
cycle|
22-
capture|
23-
end|
24-
capture|
25-
fill|
26-
iflist|
27-
endiflist|
28-
else|
29-
/x
8+
DIRECTIVE_KEYWORDS = "list|endlist|for|endfor|wrap|endwrap|if|endif|unless|endunless|elsif|assign|cycle|capture|end|capture|fill|iflist|endiflist|else"
309

31-
DIRECTIVE_OPERATORS = /
32-
=|
33-
==|
34-
!=|
35-
>|
36-
<|
37-
<=|
38-
>=|
39-
contains|
40-
/x
10+
DIRECTIVE_OPERATORS = "=|==|!=|>|<|<=|>=|contains|"
4111

42-
MATH = /
43-
=|
44-
==|
45-
!=|
46-
>|
47-
<|
48-
<=|
49-
>|
50-
/x
12+
MATH = "=|==|!=|>|<|<=|>|"
5113

52-
FILTER_KEYWORDS = /
53-
date|
54-
capitalize|
55-
downcase|
56-
upcase|
57-
first|
58-
last|
59-
join|
60-
sort|
61-
map|
62-
size|
63-
escape|
64-
escape_once|
65-
strip_html|
66-
strip_newlines|
67-
newline_to_br|
68-
replace|
69-
replace_first|
70-
remove|
71-
remove_first|
72-
truncate|
73-
truncatewords|
74-
prepend|
75-
append|
76-
minus|
77-
plus|
78-
times|
79-
divided_by|
80-
split|
81-
modulo
82-
/x
14+
FILTER_KEYWORDS = "date|capitalize|downcase|upcase|first|last|join|sort|map|size|escape|escape_once|strip_html|strip_newlines|newline_to_br|replace|replace_first|remove|remove_first|truncate|truncatewords|prepend|append|minus|plus|times|divided_by|split|modulo"
8315

8416
LIQUID_DIRECTIVE_BLOCK = /
8517
{%
@@ -119,17 +51,16 @@ def scan_directive(encoder, options, match)
11951
encoder.text_token match, :key
12052
state = :liquid
12153
scan_spaces(encoder)
122-
#Replace with DIRECTIVES_KEYWORDS regex
123-
if match = scan(/wrap|if|endif|endwrap/)
54+
#This regex doesn't work and I don't know why
55+
if match = scan(/#{DIRECTIVES_KEYWORDS}/)
12456
encoder.text_token match, :directive
12557
scan_spaces(encoder)
12658
if match =~ /if/
12759
if match = scan(/\w+\.?\w*/)
12860
encoder.text_token match, :variable
12961
end
13062
scan_spaces(encoder)
131-
#Replace with MATH regex
132-
if match = scan(/!=/)
63+
if match = scan(/#{MATH}/)
13364
encoder.text_token match, :char
13465
scan_spaces(encoder)
13566
end
@@ -150,10 +81,7 @@ def scan_directive(encoder, options, match)
15081
def scan_output_filters(encoder, options, match)
15182
encoder.text_token match, :delimiter
15283
scan_spaces(encoder)
153-
#Replace with FILTER_KEYWORDS regex
154-
testx = /replace_first|prepend/
155-
if directive = scan(/#{testx}/)
156-
#if directive = scan(/#{FILTER_KEYWORDS}/)
84+
if directive = scan(/#{FILTER_KEYWORDS}/)
15785
encoder.text_token directive, :directive
15886
end
15987
if delimiter = scan(/:/)

0 commit comments

Comments
 (0)