From 6adbeb0de2abb8d50efb0fbf579531a76ec37b45 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Mon, 23 Jul 2018 20:17:52 +0200 Subject: arabtex to utf8 texfile: first tests --- arabluatex.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arabluatex.lua b/arabluatex.lua index deb963b..197a40e 100644 --- a/arabluatex.lua +++ b/arabluatex.lua @@ -50,6 +50,8 @@ local bsqbracketsii = lpeg.Cs(bsqbrackets^-2) local bcbracesii = lpeg.Cs(bcbraces^-2) local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1) local cmdargs = lpeg.Cs(spce * bsqbracketsii * bcbracesii * bsqbrackets^-1) +local arbargs = lpeg.Cs(spce * bsqbrackets^-1 * bcbraces) +local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) local function protectarb(str) str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\@arb%2%3") @@ -639,6 +641,24 @@ local function processbuckw(str) return str end +function processexport(str) + str = "\\tooutfile{"..str.."}" + str = gsub(str, lpeg.Cs("\\arb") * arbargs, "}%1%2\\tooutfile{") + str = gsub(str, lpeg.Cs("\\bayt") * baytargs, "}\\tof{\\bayt}%1%2\\tooutfile{") + return str +end + +function tooutfile(str, nl) + local f = io.open(tex.jobname.."_out.tex", "a+") + if nl == "yes" then + f:write(str, "\n\n") + else + f:write(str) + end + f:close() + return true +end + function processvoc(str, rules, scheme) str = takeoutarb(str) str = processarbnull(str, scheme) @@ -655,6 +675,8 @@ function processvoc(str, rules, scheme) str = voc(str, rules) else end str = unprotectarb(str) + tofile = "{\\textdir TRT"..str.."}" + tooutfile(tofile) return str end @@ -717,6 +739,7 @@ function processtrans(str, mode, rules, scheme) str = transarabica(str) end str = unprotectarb(str) + tooutfile(str) return str end -- cgit v1.2.3