Skip to content

Commit cf25d44

Browse files
committed
fix deferred tags
1 parent 7eca2c9 commit cf25d44

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/coderay/scanners/liquid.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ class Liquid < Scanner
99

1010
DIRECTIVE_OPERATORS = "=|==|!=|>|<|<=|>=|contains"
1111

12-
MATH = "=|==|!=|>|<|<=|>"
12+
MATH = "==|=|!=|>|<=|<|>"
1313

1414
FILTER_KEYWORDS = "date|capitalize|downcase|upcase|first|last|join|sort|map|size|escape_once|escape|strip_html|strip_newlines|newline_to_br|replace_first|replace|remove_first|remove|truncate|truncatewords|prepend|append|minus|plus|times|divided_by|split|modulo"
1515

1616
LIQUID_DIRECTIVE_BLOCK = /
17-
{%
17+
{{1,2}%
1818
(.*?)
19-
%}
19+
%}{1,2}
2020
/x
2121

2222
def setup
@@ -75,7 +75,7 @@ def scan_directive(encoder, options, match)
7575
end
7676
scan_selector(encoder, options, match)
7777
scan_spaces(encoder)
78-
if match = scan(/%}/)
78+
if match = scan(/%}{1,2}/)
7979
encoder.text_token match, :tag
8080
state = :initial
8181
end
@@ -111,7 +111,7 @@ def scan_output(encoder, options, match)
111111
scan_output_filters(encoder, options, match)
112112
end
113113
scan_spaces(encoder)
114-
if match = scan(/}}/)
114+
if match = scan(/}{2,3}/)
115115
encoder.text_token match, :tag
116116
end
117117
state = :initial
@@ -122,7 +122,7 @@ def scan_tokens(encoder, options)
122122
state = :initial
123123

124124
until eos?
125-
if (match = scan_until(/(?=({{|{%))/) || scan_rest) and not match.empty? and state != :liquid
125+
if (match = scan_until(/(?=({{2,3}|{{1,2}%))/) || scan_rest) and not match.empty? and state != :liquid
126126
Rails.logger.debug "DEBUG: HTML scanning: #{match}"
127127
if match =~ /^"|^'/
128128
#match = match.sub /^"|^'/, ''
@@ -132,9 +132,9 @@ def scan_tokens(encoder, options)
132132
end
133133
state = :initial
134134
scan_spaces(encoder)
135-
elsif match = scan(/{%/)
135+
elsif match = scan(/{{1,2}%/)
136136
scan_directive(encoder, options, match)
137-
elsif match = scan(/{{/)
137+
elsif match = scan(/{{2,3}/)
138138
scan_output(encoder, options, match)
139139
else
140140
raise "Else-case reached. State: #{state.to_s}."

0 commit comments

Comments
 (0)