aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arabluatex.dtx8
-rw-r--r--arabluatex.lua33
2 files changed, 33 insertions, 8 deletions
diff --git a/arabluatex.dtx b/arabluatex.dtx
index 887acff..236e95f 100644
--- a/arabluatex.dtx
+++ b/arabluatex.dtx
@@ -3280,6 +3280,14 @@ wa-ya.sIru ta.hta 'l-jild-i
3280 {\NewDocumentCommand{\RL}{m}{\bgroup\textdir TRT#1\rmfamily\egroup}}} 3280 {\NewDocumentCommand{\RL}{m}{\bgroup\textdir TRT#1\rmfamily\egroup}}}
3281% \end{macrocode} 3281% \end{macrocode}
3282% \end{macro} 3282% \end{macro}
3283% \begin{macro}{\MkArbBreak}
3284% \changes{v1.9}{2017/07/02}{New \cs{MkArbBreak} command for inserting
3285% user-defined macros in Arabic environments}
3286% \begin{macrocode}
3287\DeclareDocumentCommand{\MkArbBreak}{m}{%
3288 \luadirect{mkarbbreak(\luastringN{#1})}}
3289% \end{macrocode}
3290% \end{macro}
3283% \begin{macro}{\aemph} Arabic emphasis. Needs to be redefined as well. 3291% \begin{macro}{\aemph} Arabic emphasis. Needs to be redefined as well.
3284% \begin{macrocode} 3292% \begin{macrocode}
3285\AtBeginDocument{\ifdef{\aemph}% 3293\AtBeginDocument{\ifdef{\aemph}%
diff --git a/arabluatex.lua b/arabluatex.lua
index 3a405a2..d35114d 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -27,13 +27,6 @@ require("arabluatex_fullvoc")
27require("arabluatex_novoc") 27require("arabluatex_novoc")
28require("arabluatex_trans") 28require("arabluatex_trans")
29 29
30function isintable(table, value)
31 for _, v in pairs(table) do
32 if v == value then return true end
33 end
34 return false
35end
36
37local function protectarb(str) 30local function protectarb(str)
38 str = string.gsub(str, "(\\arb.?)(%[.-%])(%b{})", "\\@arb%2%3") 31 str = string.gsub(str, "(\\arb.?)(%[.-%])(%b{})", "\\@arb%2%3")
39 str = string.gsub(str, "(\\begin.?)(%b{})(%b[])", "\\@begin%3%2") 32 str = string.gsub(str, "(\\begin.?)(%b{})(%b[])", "\\@begin%3%2")
@@ -53,9 +46,33 @@ local function unprotectarb(str)
53return str 46return str
54end 47end
55 48
56breakcmds = {} 49brkcmds = {}
50
51function mkarbbreak(str)
52 str = str ..","
53 str = string.gsub(str, "%s+", "")
54 local fieldstart = 1
55 repeat
56 local nexti = string.find(str, "%,", fieldstart)
57 table.insert(brkcmds, string.sub(str, fieldstart, nexti-1))
58 fieldstart = nexti +1
59 until fieldstart > string.len(str)
60 return brkcmds
61end
57 62
58local function breakcmd(str) 63local function breakcmd(str)
64 -- user commands
65 if next(brkcmds) == nil then
66 -- nothing to do
67 else
68 for i = 1,#brkcmds do
69 str = string.gsub(str, "\\"..brkcmds[i]..".?(%b{})",
70 function(body)
71 body = string.sub(body, 2, -2)
72 return string.format("}\\"..brkcmds[i].."{%s}\\arb{", body)
73 end)
74 end
75 end
59 -- process \item[], then \item[] 76 -- process \item[], then \item[]
60 str = string.gsub(str, "\\(item.?)(%b[])", 77 str = string.gsub(str, "\\(item.?)(%b[])",
61 function(tag, body) 78 function(tag, body)