Skip to content

Commit

Permalink
liquid: support inline comments proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
EricFromCanada committed Oct 22, 2021
1 parent 9fdae00 commit f6a92fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/rouge/lexers/liquid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class Liquid < RegexLexer
pop! until state? :liquid
end
end

mixin :whitespace
end

state :end_output do
Expand Down Expand Up @@ -106,6 +108,8 @@ class Liquid < RegexLexer

# custom tags or blocks
rule %r/(\w+)\b/, Name::Tag, :block_args

mixin :end_logic
end

state :output do
Expand Down Expand Up @@ -231,6 +235,8 @@ class Liquid < RegexLexer

state :filter do
rule %r/[a-zA-Z_](?:\w|-(?![%}]))*/, Name::Function, :pop!

mixin :whitespace
end

state :args do
Expand All @@ -255,6 +261,7 @@ class Liquid < RegexLexer

state :whitespace do
rule %r/\s+/, Text::Whitespace
rule %r/(#-?\s(?:[^-%}\n]|-(?!%})|[%}](?!}))*\s*)+/, Comment
end

state :number do
Expand Down
6 changes: 4 additions & 2 deletions spec/visual/samples/liquid
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,17 @@ Some other {{ output }}!
{% endfor %}

{% for char in 'The Quick Brown Fox' %}
{{ char | upcase }}
{{ char | upcase # inline comment }}
{% endfor %}

{% for char in "Hello World" reversed %}
{% echo char | url_encode %}
{% endfor %}
{% endfor
# inline comment %}

{% liquid %}
{% liquid
# inline comment
assign size = "one two" | split: " "
for value in size
echo value
Expand Down

0 comments on commit f6a92fe

Please sign in to comment.