clean_k_tags: work correctly with tags in the same block

This commit is contained in:
odrling 2021-07-05 01:44:06 +02:00
parent 71eca4db49
commit 026734c423
No known key found for this signature in database
GPG key ID: A56620C3E2B7EB46

View file

@ -7,11 +7,19 @@ script_version = "1.0"
function special_k(subs, sel)
local double_k = "^(.-{\\k[^}]-)(\\k.+)$"
-- if the first tag is K/kf this would break the timing for the previous timing
local expr = "^(.-){\\(ko?)([0-9.]+)[^}]-}([^{]-){\\[kK][fo]?([0-9.]+)[^}]-}( -{(\\[kK][fo]?)[0-9.]+[^}]-}.*)$"
for _, i in ipairs(sel) do
line = subs[i]
before, after = line.text:match(double_k)
while after ~= nil do
line.text = before .. "}{" .. after
before, after = line.text:match(double_k)
end
before, tag, k1, between, k2, after = line.text:match(expr)
while after ~= nil do
line.text = before .. "{\\" .. tag .. tonumber(k1) + tonumber(k2) .. "}" .. between .. after