Nested Syntax Highlighting (#160)

This commit is contained in:
adamharrison
2021-05-01 11:45:30 +02:00
committed by GitHub
parent a72431ace7
commit 3fe6665b9a
3 changed files with 136 additions and 17 deletions
+36
View File
@@ -0,0 +1,36 @@
-- lite-xl 1.16
local syntax = require "core.syntax"
syntax.add {
files = { "%.html?$" },
patterns = {
{
pattern = { "<script type=['\"]%a+/javascript['\"]>", "</script>" },
syntax = ".js",
type = "function"
},
{
pattern = { "<script>", "</script>" },
syntax = ".js",
type = "function"
},
{
pattern = { "<style[^>]*>", "</style>" },
syntax = ".css",
type = "function"
},
{ pattern = { "<!%-%-", "%-%->" }, type = "comment" },
{ pattern = { '%f[^>][^<]', '%f[<]' }, type = "normal" },
{ pattern = { '"', '"', '\\' }, type = "string" },
{ pattern = { "'", "'", '\\' }, type = "string" },
{ pattern = "0x[%da-fA-F]+", type = "number" },
{ pattern = "-?%d+[%d%.]*f?", type = "number" },
{ pattern = "-?%.?%d+f?", type = "number" },
{ pattern = "%f[^<]![%a_][%w_]*", type = "keyword2" },
{ pattern = "%f[^<][%a_][%w_]*", type = "function" },
{ pattern = "%f[^<]/[%a_][%w_]*", type = "function" },
{ pattern = "[%a_][%w_]*", type = "keyword" },
{ pattern = "[/<>=]", type = "operator" },
},
symbols = {},
}
+1 -1
View File
@@ -2,7 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
files = { "%.xml$", "%.html?$" },
files = { "%.xml$" },
headers = "<%?xml",
patterns = {
{ pattern = { "<!%-%-", "%-%->" }, type = "comment" },