Skip to content

Commit

Permalink
Add pattern for matching filenames to the Liquid lexer (#1351)
Browse files Browse the repository at this point in the history
The Shopify Liquid parser and the Jekyll Liquid parser treat the
argument to the `include` tag differently. Specifically, the Jekyll
lexer expects a filepath.

The existing Liquid lexer does not properly handle code written for the
Jekyll implementation. This commit fixes that by introducing a rule thet
matches against slashes, periods and alphanumeric characters.
  • Loading branch information
EricFromCanada authored and pyrmont committed Nov 29, 2019
1 parent eda009b commit 4bc1b33
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rouge/lexers/liquid.rb
Expand Up @@ -266,7 +266,7 @@ class Liquid < RegexLexer
end

rule %r/(with|for)\b/, Name::Tag
rule %r/[^\s\.]+(\.[^\s\.]+)+\b/, Name::Other
rule %r/[\/\w-]+(\.[\w-]+)+\b/, Text

mixin :variable_tag_markup
end
Expand Down
4 changes: 2 additions & 2 deletions spec/visual/samples/liquid
Expand Up @@ -57,8 +57,8 @@ Some other {{ output }}!
{% else %}
{% endcase %}

{% include file.html param = 'value' param2 = object %}
{% include 'snippet', param: 'value', param2: object %}
{% include dir/file.html param = 'example.com' param2 = object %}
{% include 'snippet', param: 'example.com', param2: object %}
{% include product_page with products[0] %}
{% include {{product_page | split: "." | first}} for products %}

Expand Down

0 comments on commit 4bc1b33

Please sign in to comment.