From 67d484712e6f6f2d26894c8858a220dc8de5c3c8 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Tue, 18 Jun 2019 08:30:52 +0200 Subject: new function processarind() for indexing Arabic words --- arabluatex.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/arabluatex.lua b/arabluatex.lua index df03156..67e4fc3 100644 --- a/arabluatex.lua +++ b/arabluatex.lua @@ -56,6 +56,7 @@ local aftercmd = lpeg.Cs(lpeg.S("*[{,.?;:'`\"") + dblbkslash) local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1) local arbargs = lpeg.Cs(spce^-1 * bsqbrackets^-1 * bcbraces) local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) +local arind = lpeg.Cs(dblbkslash * lpeg.P("arind") * spce^-1 * bsqbracketsii) local function protectarb(str) str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\al@brk{\\arb%2%3}") @@ -655,6 +656,20 @@ local function processbuckw(str) return str end +local function processarind(str, mode) + str = gsub(str, arind * bcbraces, function(tag, arg) + arg = string.sub(arg, 2, -2) + if mode == "trans" then + return string.format("%s{\\txtrans{%s}}", tag, arg) + else + arg = novoc(arg) + arg = string.gsub(arg, "\\arabicfont%s?{}", "") + return string.format("%s{\\txarb{%s}}", tag, arg) + end + end) + return str +end + -- The following functions produce a copy of the original .tex source -- file in which all arabtex strings are replaced with Unicode -- equivalents @@ -892,6 +907,7 @@ function arabluatex.processvoc(str, rules, scheme) str = protectarb(str) str = breakcmd(str) str = holdcmd(str) + str = processarind(str) if scheme == "buckwalter" then str = processbuckw(str) else end @@ -920,6 +936,7 @@ function arabluatex.processfullvoc(str, rules, scheme) str = protectarb(str) str = breakcmd(str) str = holdcmd(str) + str = processarind(str) if scheme == "buckwalter" then str = processbuckw(str) else end @@ -950,6 +967,7 @@ function arabluatex.processnovoc(str, rules, scheme) str = protectarb(str) str = breakcmd(str) str = holdcmd(str) + str = processarind(str) if scheme == "buckwalter" then str = processbuckw(str) else end @@ -979,6 +997,7 @@ function arabluatex.processtrans(str, mode, rules, scheme) str = protectarb(str) str = breakcmd(str) str = holdcmd(str) + str = processarind(str, "trans") if scheme == "buckwalter" then str = processbuckw(str) end -- cgit v1.2.3