summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorgi Kirilov <>2020-11-22 15:10:50 +0200
committerGeorgi Kirilov <>2023-10-04 18:24:59 +0800
commitc3a27083e9d3d15652bb68291ebe4e3b2ccad65e (patch)
tree837a458e6dcba4be946896fb83bedee1b0f3dff7
parentdf348ce7ce97d5ad82e06e73ab1665d6e7accae9 (diff)
downloadvis-pairs-c3a27083e9d3d15652bb68291ebe4e3b2ccad65e.tar.gz
Check for void elements *before* capturing
-rw-r--r--pairs.lua6
1 files changed, 3 insertions, 3 deletions
diff --git a/pairs.lua b/pairs.lua
index 5e243c0..604b41e 100644
--- a/pairs.lua
+++ b/pairs.lua
@@ -303,10 +303,10 @@ vis.events.subscribe(vis.events.INIT, function()
local function casecmp(_, _, c1, c2) return c1:lower() == c2:lower() end
local function closing(s1, s2, cmpfunc) return l.Cmt(s1 * l.Cb("t") * l.C((1 - l.P(s2))^1) * s2, cmpfunc) end
local tex_environment = {"\\begin{" * l.Cg(l.R("az", "AZ")^1, "t") * "}", closing("\\end{", "}", cmp), {"\\begin{\xef\xbf\xbd}", "\\end{\xef\xbf\xbd}"}, "environment name"}
- local function is(_, _, v) return v ~= 1 end
local tag_name = (l.S"_:" + l.R("az", "AZ")) * (l.R("az", "AZ", "09") + l.S"_:.-")^0
- local noslash = l.Cmt(l.Cb("t") / string.lower / {--[[implicit:]] p=1, dt=1, dd=1, li=1, --[[void:]] img=1, input=1, hr=1, br=1, link=1, meta=1}, is)
- local html_tag = {"<" * l.Cg(tag_name, "t") * noslash * (1 - l.S"><")^0 * (">" - l.B"/"), closing("</", ">", casecmp), {"<\xef\xbf\xbd>", "</\xef\xbf\xbd>"}, "tag name"}
+ local noslash = {--[[implicit:]] p=1, dt=1, dd=1, li=1, --[[void:]] img=1, input=1, hr=1, br=1, link=1, meta=1}
+ local function is_not(_, _, v) return v ~= 1 end
+ local html_tag = {"<" * l.Cg(l.Cmt(tag_name / string.lower / noslash, is_not), "t") * (1 - l.S"><")^0 * (">" - l.B"/"), closing("</", ">", casecmp), {"<\xef\xbf\xbd>", "</\xef\xbf\xbd>"}, "tag name"}
local xml_tag = {"<" * l.Cg(tag_name, "t") * (1 - l.S"><")^0 * (">" - l.B"/"), closing("</", ">", cmp), {"<\xef\xbf\xbd>", "</\xef\xbf\xbd>"}, "tag name"}
local function any_pair(set, default) return {l.Cg(l.S(set), "s"), l.Cmt(l.Cb("s") * l.C(1), function(_, _, c1, c2) return builtin_textobjects[c1][2] == c2 end), builtin_textobjects[default]} end
local any_bracket = any_pair("({[", "(")