Skip to content
Permalink
Browse files
Haml: Improved filter and interpolation tokenization (#3191)
  • Loading branch information
RunDevelopment committed Nov 10, 2021
1 parent 4433d7f commit 005ba46924638b6709ed42f7bfe9c9bb9a01ca8d
@@ -95,7 +95,10 @@
pattern: /^#\{|\}$/,
alias: 'punctuation'
},
rest: Prism.languages.ruby
'ruby': {
pattern: /[\s\S]+/,
inside: Prism.languages.ruby
}
}
},
'punctuation': {
@@ -131,7 +134,11 @@
pattern: /^:[\w-]+/,
alias: 'variable'
},
rest: Prism.languages[filter.language]
'text': {
pattern: /[\s\S]+/,
alias: [filter.language, 'language-' + filter.language],
inside: Prism.languages[filter.language]
}
}
};
}

Some generated files are not rendered by default. Learn more.

@@ -10,15 +10,19 @@
[
["filter-coffee", [
["filter-name", ":coffee"],
["string", "'This is coffee script'"]
["text", [
["string", "'This is coffee script'"]
]]
]],
["punctuation", "~"],
["filter-coffee", [
["filter-name", ":coffee"],
["string", "'This is coffee script'"]
]]
["filter-name", ":coffee"],
["text", [
["string", "'This is coffee script'"]
]]
]]
]

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

Checks for CoffeeScript filter in Haml. The tilde serves only as a separator.
Checks for CoffeeScript filter in Haml. The tilde serves only as a separator.
@@ -10,19 +10,23 @@
[
["filter-css", [
["filter-name", ":css"],
["selector", ".test"],
["punctuation", "{"],
["punctuation", "}"]
["text", [
["selector", ".test"],
["punctuation", "{"],
["punctuation", "}"]
]]
]],
["punctuation", "~"],
["filter-css", [
["filter-name", ":css"],
["selector", ".test"],
["punctuation", "{"],
["punctuation", "}"]
]]
["filter-name", ":css"],
["text", [
["selector", ".test"],
["punctuation", "{"],
["punctuation", "}"]
]]
]]
]

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

Checks for CSS filter in Haml. The tilde serves only as a separator.
Checks for CSS filter in Haml. The tilde serves only as a separator.
@@ -10,30 +10,30 @@
[
["filter-erb", [
["filter-name", ":erb"],
["operator", "<"],
["operator", "%"],
["operator", "="],
" render ",
["variable", "@products"],
["operator", "||"],
["string", [
"\"empty_list\""
]],
["operator", "%"],
["operator", ">"]
["text", [
["operator", "<"],
["operator", "%"],
["operator", "="],
" render ",
["variable", "@products"],
["operator", "||"],
["string", ["\"empty_list\""]],
["operator", "%"],
["operator", ">"]
]]
]],
["punctuation", "~"],
["filter-erb", [
["filter-name", ":erb"],
["operator", "<"],
["operator", "%"],
["operator", "="],
" render ",
["variable", "@products"],
["operator", "||"],
["string", [
"\"empty_list\""
]],
["delimiter", "%>"]
["text", [
["operator", "<"],
["operator", "%"],
["operator", "="],
" render ",
["variable", "@products"],
["operator", "||"],
["string", ["\"empty_list\""]],
["delimiter", "%>"]
]]
]]
]
@@ -6,16 +6,20 @@
[
["interpolation", [
["delimiter", "#{"],
["number", "42"],
["ruby", [
["number", "42"]
]],
["delimiter", "}"]
]],
["interpolation", [
["delimiter", "#{"],
["string", ["\"foobar\""]],
["ruby", [
["string", ["\"foobar\""]]
]],
["delimiter", "}"]
]]
]

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

Checks for interpolation in plain text.
Checks for interpolation in plain text.
@@ -42,11 +42,14 @@
["attributes", [
["punctuation", "{"],
["symbol", ":type"],
["operator", "="], ["operator", ">"],
["operator", "="],
["operator", ">"],
["string", ["\"text/javascript\""]],
["punctuation", ","],

["symbol", ":src"],
["operator", "="], ["operator", ">"],
["operator", "="],
["operator", ">"],
["string", [
"\"javascripts/script_",
["interpolation", [
@@ -65,7 +68,8 @@
["attributes", [
["punctuation", "{"],
["symbol", ":id"],
["operator", "="], ["operator", ">"],
["operator", "="],
["operator", ">"],
["punctuation", "["],
["variable", "@item"],
["punctuation", "."],
@@ -88,8 +92,8 @@
["attr-value", "@title"],
["attr-name", "href"],
["punctuation", "="],
["attr-value", "href"],
["punctuation", ")"]
["attr-value", "href"],
["punctuation", ")"]
]]
]],
["tag", [
@@ -138,7 +142,8 @@
["attributes", [
["punctuation", "{"],
["symbol", ":id"],
["operator", "="], ["operator", ">"],
["operator", "="],
["operator", ">"],
["variable", "@article"],
["punctuation", "."],
"number",
@@ -150,8 +155,14 @@
["tag", [".item"]],

["tag", ["%br/"]],
["tag", ["%blockquote", ["punctuation", "<"]]],
["tag", ["%img", ["punctuation", ">"]]]
["tag", [
"%blockquote",
["punctuation", "<"]
]],
["tag", [
"%img",
["punctuation", ">"]
]]
]

----------------------------------------------------
@@ -10,15 +10,19 @@
[
["filter-javascript", [
["filter-name", ":javascript"],
["number", "0xBadFace"]
["text", [
["number", "0xBadFace"]
]]
]],
["punctuation", "~"],
["filter-javascript", [
["filter-name", ":javascript"],
["number", "0xBadFace"]
["text", [
["number", "0xBadFace"]
]]
]]
]

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

Checks for JavaScript filter in Haml. The tilde serves only as a separator.
Checks for JavaScript filter in Haml. The tilde serves only as a separator.
@@ -10,23 +10,27 @@
[
["filter-less", [
["filter-name", ":less"],
["selector", [".foo"]],
["punctuation", "{"],
["mixin-usage", ".bar"],
["punctuation", ";"],
["punctuation", "}"]
["text", [
["selector", [".foo"]],
["punctuation", "{"],
["mixin-usage", ".bar"],
["punctuation", ";"],
["punctuation", "}"]
]]
]],
["punctuation", "~"],
["filter-less", [
["filter-name", ":less"],
["selector", [".foo"]],
["punctuation", "{"],
["mixin-usage", ".bar"],
["punctuation", ";"],
["punctuation", "}"]
["text", [
["selector", [".foo"]],
["punctuation", "{"],
["mixin-usage", ".bar"],
["punctuation", ";"],
["punctuation", "}"]
]]
]]
]

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

Checks for Less filter in Haml. The tilde serves only as a separator.
Checks for Less filter in Haml. The tilde serves only as a separator.
@@ -10,23 +10,27 @@
[
["filter-markdown", [
["filter-name", ":markdown"],
["title", [
["punctuation", "#"],
" Title 1"
["text", [
["title", [
["punctuation", "#"],
" Title 1"
]]
]]
]],
["punctuation", "~"],
["filter-markdown", [
["filter-name", ":markdown"],
["title", [
["punctuation", "#"],
" Title 1"
]]
["text", [
["title", [
["punctuation", "#"],
" Title 1"
]]
]]
]]
]

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

Checks for Markdown filter in Haml. The tilde serves only as a separator.
Indentation is intentionally less than 1 tab, otherwise markdown is
interpreted as code.
interpreted as code.

0 comments on commit 005ba46

Please sign in to comment.