From 374a2ade09506f08e0e903f15f8c08b0ec751120 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sat, 23 Mar 2019 10:34:02 +0100 Subject: stored all global functions in the 'arabluatex' table --- arabluatex.lua | 62 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'arabluatex.lua') diff --git a/arabluatex.lua b/arabluatex.lua index 39b4f56..df03156 100644 --- a/arabluatex.lua +++ b/arabluatex.lua @@ -97,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 @@ -661,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 @@ -708,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) @@ -795,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) @@ -816,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") @@ -827,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") @@ -885,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) @@ -903,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) @@ -933,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) @@ -961,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) @@ -992,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}) @@ -1019,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 @@ -1044,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) @@ -1115,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 @@ -1128,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 @@ -1151,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 @@ -1160,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 @@ -1173,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" -- cgit v1.2.3