Check if "open" pattern is escaped
Previously this check was only done for "close" patterns.
This commit is contained in:
parent
99d328cfd7
commit
5b6b48320f
|
@ -192,15 +192,21 @@ function tokenizer.tokenize(incoming_syntax, text, state)
|
||||||
end
|
end
|
||||||
res[1] = next
|
res[1] = next
|
||||||
end
|
end
|
||||||
if res[1] and close and target[3] then
|
if res[1] and target[3] then
|
||||||
|
-- Check to see if the escaped character is there,
|
||||||
|
-- and if it is not itself escaped.
|
||||||
local count = 0
|
local count = 0
|
||||||
for i = res[1] - 1, 1, -1 do
|
for i = res[1] - 1, 1, -1 do
|
||||||
if text:byte(i) ~= target[3]:byte() then break end
|
if text:byte(i) ~= target[3]:byte() then break end
|
||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
-- Check to see if the escaped character is there,
|
if count % 2 == 0 then
|
||||||
-- and if it is not itself escaped.
|
-- The match is not escaped, so confirm it
|
||||||
if count % 2 == 0 then break end
|
break
|
||||||
|
elseif not close then
|
||||||
|
-- The *open* match is escaped, so avoid it
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
until not res[1] or not close or not target[3]
|
until not res[1] or not close or not target[3]
|
||||||
return table.unpack(res)
|
return table.unpack(res)
|
||||||
|
|
Loading…
Reference in New Issue