From a2c09fa2736279ed2eec00177f2b0215dd19cd22 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sun, 13 May 2018 16:38:24 +0200 Subject: \MkArbBreak{} now processes commands with up to one optional argument --- arabluatex.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'arabluatex.lua') diff --git a/arabluatex.lua b/arabluatex.lua index b2c651c..8105311 100644 --- a/arabluatex.lua +++ b/arabluatex.lua @@ -65,11 +65,19 @@ local function breakcmd(str) if next(brkcmds) == nil then -- nothing to do else + for i = 1,#brkcmds do + str = string.gsub(str, "\\"..brkcmds[i].."%s?(%b[])(%b{})", + function(opt, body) + opt = string.sub(opt, 2, -2) + body = string.sub(body, 2, -2) + return string.format("}\\"..brkcmds[i].."[%s]{%s}\\arb{", opt, body) + end) + end for i = 1,#brkcmds do str = string.gsub(str, "\\"..brkcmds[i].."%s?(%b{})", - function(body) - body = string.sub(body, 2, -2) - return string.format("}\\"..brkcmds[i].."{%s}\\arb{", body) + function(body) + body = string.sub(body, 2, -2) + return string.format("}\\"..brkcmds[i].."{%s}\\arb{", body) end) end end @@ -130,13 +138,6 @@ local function breakcmd(str) body = string.sub(body, 2, -2) return string.format("}\\%s{%s}\\arb{", tag, body) end) - -- any command that is not \arb{} and has an optional argument - str = string.gsub(str, "\\([^a][^r][^b].-)(%b[])(%b{})", - function(tag, opt, body) - opt = string.sub(opt, 2, -2) - body = string.sub(body, 2, -2) - return string.format("}\\%s[%s]{\\arb{%s}}\\arb{", tag, opt, body) - end) return str end -- cgit v1.2.3