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 Mar 3, 2021
1 parent 68ea48b commit 84e6cff
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 84e6cff

Please sign in to comment.