Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inline comment syntax to liquid #3821

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions components/prism-liquid.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
Prism.languages.liquid = {
'comment': {
pattern: /(^\{%\s*comment\s*%\})[\s\S]+(?=\{%\s*endcomment\s*%\}$)/,
lookbehind: true
},
'comment': [
{
pattern: /(^\{%\s*comment\s*%\})[\s\S]+(?=\{%\s*endcomment\s*%\}$)/,
lookbehind: true
},
{
pattern: /#.*?(?=\n|%\})/,
},
],
'delimiter': {
pattern: /^\{(?:\{\{|[%\{])-?|-?(?:\}\}|[%\}])\}$/,
alias: 'punctuation'
Expand Down
2 changes: 1 addition & 1 deletion components/prism-liquid.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 25 additions & 1 deletion tests/languages/liquid/comment_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ My name is Wilson Abercrombie{% comment %}, esquire{% endcomment %}.
{% endcomment %}
Anything you put between {% comment %} and {% endcomment %} tags
is {{ verb }} into a comment.
# hash fun #
{% # inline comments %}
{% liquid
# even here, too
%}
{% liquid
# and here %}

----------------------------------------------------

Expand Down Expand Up @@ -57,5 +64,22 @@ is {{ verb }} into a comment.
" verb ",
["delimiter", "}}"]
]],
" into a comment."
" into a comment.\r\n# hash fun #\r\n",

["liquid", [
["delimiter", "{%"],
["comment", "# inline comments "],
["delimiter", "%}"]
]],

["liquid", [
["delimiter", "{%"], ["keyword", "liquid"],
"\r\n\t# even here", ["punctuation", ","], " too\r\n",
["delimiter", "%}"]
]],

["liquid", [
["delimiter", "{%"], ["keyword", "liquid"],
["comment", "# and here "], ["delimiter", "%}"]
]]
]
Loading