diff options
-rw-r--r-- | arabluatex.lua | 21 |
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 |
141 | end | 142 | end |
142 | 143 | ||