From 4bc1b33217166c2dbbe5767b4f9d53a9cab6e8d5 Mon Sep 17 00:00:00 2001 From: Eric Knibbe Date: Fri, 29 Nov 2019 04:01:31 -0500 Subject: [PATCH] Add pattern for matching filenames to the Liquid lexer (#1351) 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. --- lib/rouge/lexers/liquid.rb | 2 +- spec/visual/samples/liquid | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rouge/lexers/liquid.rb b/lib/rouge/lexers/liquid.rb index caab00d028..75ca9b3225 100644 --- a/lib/rouge/lexers/liquid.rb +++ b/lib/rouge/lexers/liquid.rb @@ -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 diff --git a/spec/visual/samples/liquid b/spec/visual/samples/liquid index 3c888f45ce..bf33219f68 100644 --- a/spec/visual/samples/liquid +++ b/spec/visual/samples/liquid @@ -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 %}