forked from PrismJS/prism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for etlua (PrismJS#2050)
This adds support for etlua (Embedded Lua templating).
- Loading branch information
1 parent
ffd1886
commit 87ff89a
Showing
10 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
(function (Prism) { | ||
|
||
Prism.languages.etlua = { | ||
'delimiter': { | ||
pattern: /^<%[-=]?|-?%>$/, | ||
alias: 'punctuation' | ||
}, | ||
'language-lua': { | ||
pattern: /[\s\S]+/, | ||
inside: Prism.languages.lua | ||
} | ||
}; | ||
|
||
Prism.hooks.add('before-tokenize', function (env) { | ||
var pattern = /<%[\s\S]+?%>/g; | ||
Prism.languages['markup-templating'].buildPlaceholders(env, 'etlua', pattern); | ||
}); | ||
|
||
Prism.hooks.add('after-tokenize', function (env) { | ||
Prism.languages['markup-templating'].tokenizePlaceholders(env, 'etlua'); | ||
}); | ||
|
||
}(Prism)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<h2>Full example</h2> | ||
<pre><code><div class="foo"> | ||
<% if true then %> | ||
Hello <%= name %>, | ||
Here are your items: | ||
<% for i, item in pairs(items) do %> | ||
* <%= item -%> | ||
<% --[[ comment block ]] %> | ||
<% end %> | ||
<%- "<b>this is not escaped</b>" %> | ||
<% end %> | ||
</div></code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<% lua_code %> | ||
<%= lua_expression %> | ||
<%- lua_expression %> | ||
<%= 'hello' -%> | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["etlua", [ | ||
["delimiter", "<%"], | ||
["language-lua", [ | ||
" lua_code " | ||
]], | ||
["delimiter", "%>"] | ||
]], | ||
["etlua", [ | ||
["delimiter", "<%="], | ||
["language-lua", [ | ||
" lua_expression " | ||
]], | ||
["delimiter", "%>"] | ||
]], | ||
["etlua", [ | ||
["delimiter", "<%-"], | ||
["language-lua", [ | ||
" lua_expression " | ||
]], | ||
["delimiter", "%>"] | ||
]], | ||
["etlua", [ | ||
["delimiter", "<%="], | ||
["language-lua", [ | ||
["string", "'hello'"] | ||
]], | ||
["delimiter", "-%>"] | ||
]] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for different delimiters. |