aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2018-05-13 16:38:24 +0200
committerRobert Alessi <alessi@robertalessi.net>2018-05-13 16:38:24 +0200
commita2c09fa2736279ed2eec00177f2b0215dd19cd22 (patch)
treedbcb7c97d8b815cb07b5cd60ea5525b41e077b27
parent5243297448992d442c3ad388a16b6cb44d83a4fc (diff)
downloadarabluatex-a2c09fa2736279ed2eec00177f2b0215dd19cd22.tar.gz
\MkArbBreak{} now processes commands with up to one optional argument
-rw-r--r--arabluatex.lua21
1 files changed, 11 insertions, 10 deletions
diff --git a/arabluatex.lua b/arabluatex.lua
index b2c651c..8105311 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -66,10 +66,18 @@ local function breakcmd(str)
66 -- nothing to do 66 -- nothing to do
67 else 67 else
68 for i = 1,#brkcmds do 68 for i = 1,#brkcmds do
69 str = string.gsub(str, "\\"..brkcmds[i].."%s?(%b[])(%b{})",
70 function(opt, body)
71 opt = string.sub(opt, 2, -2)
72 body = string.sub(body, 2, -2)
73 return string.format("}\\"..brkcmds[i].."[%s]{%s}\\arb{", opt, body)
74 end)
75 end
76 for i = 1,#brkcmds do
69 str = string.gsub(str, "\\"..brkcmds[i].."%s?(%b{})", 77 str = string.gsub(str, "\\"..brkcmds[i].."%s?(%b{})",
70 function(body) 78 function(body)
71 body = string.sub(body, 2, -2) 79 body = string.sub(body, 2, -2)
72 return string.format("}\\"..brkcmds[i].."{%s}\\arb{", body) 80 return string.format("}\\"..brkcmds[i].."{%s}\\arb{", body)
73 end) 81 end)
74 end 82 end
75 end 83 end
@@ -130,13 +138,6 @@ local function breakcmd(str)
130 body = string.sub(body, 2, -2) 138 body = string.sub(body, 2, -2)
131 return string.format("}\\%s{%s}\\arb{", tag, body) 139 return string.format("}\\%s{%s}\\arb{", tag, body)
132 end) 140 end)
133 -- any command that is not \arb{} and has an optional argument
134 str = string.gsub(str, "\\([^a][^r][^b].-)(%b[])(%b{})",
135 function(tag, opt, body)
136 opt = string.sub(opt, 2, -2)
137 body = string.sub(body, 2, -2)
138 return string.format("}\\%s[%s]{\\arb{%s}}\\arb{", tag, opt, body)
139 end)
140 return str 141 return str
141end 142end
142 143