aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2022-11-11 14:03:32 -0400
committerjgmdev <jgmdev@gmail.com>2022-11-11 14:03:32 -0400
commitdaadc666291c3c51bfe836d7079e4a284dd18cbd (patch)
tree36c4d2b547263a3a2715190d1400ad493ad493af
parent33ddb0686459e28643a77dad62e5a01c71b25e94 (diff)
downloadlite-xl-plugins-daadc666291c3c51bfe836d7079e4a284dd18cbd.tar.gz
lite-xl-plugins-daadc666291c3c51bfe836d7079e4a284dd18cbd.zip
language_php: fix highlighting outside of markdown code tags
-rw-r--r--plugins/language_php.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/plugins/language_php.lua b/plugins/language_php.lua
index bb54723..be24eb6 100644
--- a/plugins/language_php.lua
+++ b/plugins/language_php.lua
@@ -86,8 +86,7 @@ local inline_variables = {
type = { "keyword2", "keyword", "symbol" }
},
{ pattern = "%$[%a_][%w_]*", type = "keyword2" },
- { pattern = "%w+", type = "string" },
- { pattern = "[^\"]", type = "string" },
+ { pattern = "%w+", type = "string" }
}
local function combine_patterns(t1, t2)
@@ -180,6 +179,7 @@ syntax.add {
syntax = {
patterns = combine_patterns(inline_variables, {
-- prevent matching outside of the parent string
+ { pattern = "[^\"]", type = "string" },
{ pattern = "%p+%f[\"]", type = "string" },
{ pattern = "%p", type = "string" },
}),
@@ -327,9 +327,9 @@ syntax.add {
block_comment = {"/*", "*/"},
patterns = {
{
- pattern = {
- "<%?php%s+",
- "%?>"
+ regex = {
+ "<\\?php\\s+",
+ "(\\?>|(?=`{3}))" -- end if inside markdown code tags
},
syntax = ".phps",
type = "keyword2"
@@ -370,6 +370,9 @@ syntax.add {
{ pattern = "%f[^<]/[%a_][%w_]*", type = "function" },
{ pattern = "[%a_][%w_]*", type = "keyword" },
{ pattern = "[/<>=]", type = "operator" },
+ -- match markdown code tags to be able to end php highlighting
+ -- when inside the subsyntax .phps
+ { regex = "(?=`{3})", type = "string" }
},
symbols = {},
}