summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua')
-rw-r--r--Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua64
1 files changed, 33 insertions, 31 deletions
diff --git a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua
index 9d8343810f6..df031569c01 100644
--- a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua
+++ b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua
@@ -22,6 +22,8 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>.
--]]
+arabluatex = {}
+
require("arabluatex_voc")
require("arabluatex_fullvoc")
require("arabluatex_novoc")
@@ -95,7 +97,7 @@ local albrkcmds = {
}
local brkcmds = {}
-function mkarbbreak(str, opt)
+function arabluatex.mkarbbreak(str, opt)
str = str ..","
str = string.gsub(str, "%s+", "")
local fieldstart = 1
@@ -659,17 +661,17 @@ end
local utffilesuffix = "_out"
local export_utf = "no"
-function al_utffilesuffix(str)
+function arabluatex.utffilesuffix(str)
utffilesuffix = str
return true
end
-function al_doexport(str)
+function arabluatex.doexport(str)
export_utf = str
return true
end
-function al_openstream()
+function arabluatex.openstream()
local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "a+")
local preamble = io.open(tex.jobname..".tex", "r")
for line in preamble:lines() do
@@ -706,7 +708,7 @@ local function processarbtoutf(str)
body = string.gsub(body, "(\\abjad%s?)(%b{})", function(btag, bbody)
bbody = string.sub(bbody, 2, -2)
if tonumber(bbody) ~= nil then
- bbody = abjadify(bbody)
+ bbody = arabluatex.abjadify(bbody)
return string.format("\\oline*{\\arb[novoc]{%s}}", bbody)
else
return string.format("%s{%s}", btag, bbody)
@@ -793,7 +795,7 @@ local function processarbtoutf(str)
return str
end
-function arbtoutf(str)
+function arabluatex.arbtoutf(str)
str = processarbtoutf(str)
str = "\\ArbOutFile{"..str.."}"
str = string.gsub(str, "(\\ArbOutFile)%s?(%b{})", function(tag, body)
@@ -814,7 +816,7 @@ function arbtoutf(str)
return str
end
-function tooutfile(str, nl)
+function arabluatex.tooutfile(str, nl)
local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "a+")
if nl == "newline" then
f:write(str, "\n\n")
@@ -825,7 +827,7 @@ function tooutfile(str, nl)
return str
end
-function al_closestream()
+function arabluatex.closestream()
local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "r")
local o = io.open(tex.jobname..utffilesuffix..".tex", "w")
local t = f:read("*a")
@@ -883,7 +885,7 @@ function al_closestream()
end
-- Process standard arabluatex modes:
-function processvoc(str, rules, scheme)
+function arabluatex.processvoc(str, rules, scheme)
str = takeoutarb(str)
str = processarbnull(str, scheme)
str = takeoutcapetc(str)
@@ -901,17 +903,17 @@ function processvoc(str, rules, scheme)
str = unprotectarb(str)
if export_utf == "yes" then
tofile = "\\txarb{"..str.."}"
- tooutfile(tofile)
+ arabluatex.tooutfile(tofile)
elseif export_utf == "arabverse" then
tofile = "\\txarb{"..str.."}"
- tooutfile(tofile)
+ arabluatex.tooutfile(tofile)
else
return str
end
return ""
end
-function processfullvoc(str, rules, scheme)
+function arabluatex.processfullvoc(str, rules, scheme)
str = takeoutarb(str)
str = processarbnull(str, scheme)
str = takeoutcapetc(str)
@@ -931,17 +933,17 @@ function processfullvoc(str, rules, scheme)
str = unprotectarb(str)
if export_utf == "yes" then
tofile = "\\txarb{"..str.."}"
- tooutfile(tofile)
+ arabluatex.tooutfile(tofile)
elseif export_utf == "arabverse" then
tofile = "\\txarb{"..str.."}"
- tooutfile(tofile)
+ arabluatex.tooutfile(tofile)
else
return str
end
return ""
end
-function processnovoc(str, rules, scheme)
+function arabluatex.processnovoc(str, rules, scheme)
str = takeoutarb(str)
str = processarbnull(str, scheme)
str = takeoutcapetc(str)
@@ -959,17 +961,17 @@ function processnovoc(str, rules, scheme)
str = unprotectarb(str)
if export_utf == "yes" then
tofile = "\\txarb{"..str.."}"
- tooutfile(tofile)
+ arabluatex.tooutfile(tofile)
elseif export_utf == "arabverse" then
tofile = "\\txarb{"..str.."}"
- tooutfile(tofile)
+ arabluatex.tooutfile(tofile)
else
return str
end
return ""
end
-function processtrans(str, mode, rules, scheme)
+function arabluatex.processtrans(str, mode, rules, scheme)
str = takeoutarb(str)
str = processdiscretionary(str)
str = processarbnull(str, scheme)
@@ -990,17 +992,17 @@ function processtrans(str, mode, rules, scheme)
str = unprotectarb(str)
if export_utf == "yes" then
tofile = "\\txtrans{"..str.."}"
- tooutfile(tofile)
+ arabluatex.tooutfile(tofile)
elseif export_utf == "arabverse" then
tofile = "\\txtrans{"..str.."}"
- tooutfile(tofile)
+ arabluatex.tooutfile(tofile)
else
return str
end
return ""
end
-function newarbmark(abbr, rtlmk, ltrmk)
+function arabluatex.newarbmark(abbr, rtlmk, ltrmk)
abbr = "@"..abbr
rtlmk = "\\arabicfont{}"..rtlmk
table.insert(arbmarks, {a = abbr, b = rtlmk, c = ltrmk})
@@ -1017,7 +1019,7 @@ local function isintable(table, element)
return false
end
-function processarbmarks(str, dir)
+function arabluatex.processarbmarks(str, dir)
str = "@"..str
if not isintable(arbmarks, str) then
str = "\\LR{<??>}"..atletter.."\\al@wrong@mark{}"..atother
@@ -1042,17 +1044,17 @@ function processarbmarks(str, dir)
end
if export_utf == "yes" then
tofile = str
- tooutfile(tofile)
+ arabluatex.tooutfile(tofile)
elseif export_utf == "arabverse" then
tofile = str
- tooutfile(tofile)
+ arabluatex.tooutfile(tofile)
else
return str
end
return ""
end
-function uc(str)
+function arabluatex.uc(str)
str = string.gsub(str, "(\\txtrans.?)(%b{})", function(tag, body)
body = string.sub(body, 2, -2)
return string.format("%s", body)
@@ -1113,10 +1115,10 @@ function uc(str)
str = string.gsub(str, "\\@al@cb", "}")
if export_utf == "yes" then
tofile = str
- tooutfile(tofile)
+ arabluatex.tooutfile(tofile)
elseif export_utf == "arabverse" then
tofile = str
- tooutfile(tofile)
+ arabluatex.tooutfile(tofile)
else
return str
end
@@ -1126,7 +1128,7 @@ end
-- this function is adapted from an 'obsolete project' of Khaled
-- Hosny's that dates back to 2010. Thanks to him.
-- See https://github.com/khaledhosny/lualatex-arabic
-function abjadify(n)
+function arabluatex.abjadify(n)
local abjadnum = ""
n = tonumber(n)
if n >= 1000 then
@@ -1149,7 +1151,7 @@ function abjadify(n)
return "\\arb[novoc]{"..abjadnum.."}"
end
-function abraces(str)
+function arabluatex.abraces(str)
if tex.textdir == "TRT" then
str = "\\}"..str.."\\{"
elseif tex.textdir == "TLT" then
@@ -1158,7 +1160,7 @@ function abraces(str)
return str
end
-function aemph(str, opt)
+function arabluatex.aemph(str, opt)
if tex.textdir == "TRT" then
str = "\\oline{\\textdir TRT{}"..str.."}"
elseif tex.textdir == "TLT" then
@@ -1171,7 +1173,7 @@ function aemph(str, opt)
return str
end
-function ayah(str)
+function arabluatex.ayah(str)
if tonumber(str) ~= nil and str.len(str) < 4 then
if tex.textdir == "TRT" then
str = indnum(str).."^^^^06dd"