From f0195ef546e9c35f539edd3bf01ef8b1b0cb7344 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Tue, 21 Aug 2018 17:52:35 +0200 Subject: arabtex2utf: arabverse needed much more work --- arabluatex.lua | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'arabluatex.lua') diff --git a/arabluatex.lua b/arabluatex.lua index 13db492..9b46d01 100644 --- a/arabluatex.lua +++ b/arabluatex.lua @@ -672,7 +672,20 @@ function al_openstream() end local function processarbtoutf(str) - str = "\\begin{arabexport}"..str + if export_utf ~= "arabverse" then + str = "\\begin{arabexport}"..str + else end + str = string.gsub(str, "(\\bayt)%s?(%b{})(%b[])(%b{})", function(tag, argi, argii, argiii) + argi = string.sub(argi, 2, -2) + argii = string.sub(argii, 2, -2) + argiii = string.sub(argiii, 2, -2) + return string.format("%s*{\\arb{%s}}[\\arb{%s}]{\\arb{%s}}", tag, argi, argii, argiii) + end) + str = string.gsub(str, "(\\bayt)%s?(%b{})(%b{})", function(tag, argi, argii) + argi = string.sub(argi, 2, -2) + argii = string.sub(argii, 2, -2) + return string.format("%s*{\\arb{%s}}{\\arb{%s}}", tag, argi, argii) + end) str = string.gsub(str, "(\\prname)%s?(%b{})", function(tag, body) body = string.sub(body, 2, -2) if string.find(body, "\\uc%s?%b{}") then @@ -727,7 +740,9 @@ local function processarbtoutf(str) body = string.gsub(body, "(\\@al@cb)(%s?)", "}%2") return string.format("{%s}", body) end) - str = str.."\\end{arabexport}" + if export_utf ~= "arabverse" then + str = str.."\\end{arabexport}" + else end return str end @@ -785,7 +800,9 @@ function al_closestream() t = string.gsub(t, "(\\end%s?)(%b{})", "%1%2\n") t = string.gsub(t, "([^\n]%s-)(\\end)%s?(%b{})", "%1\n%2%3") t = string.gsub(t, "\n\n\n", "\n\n") - if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") then + if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") or + string.find(t, "\\begin%s?{document}.-\\[Uu]c%s?%b{}") + then tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{There are still 'arabtex' strings to be converted. Open ]]..tex.jobname..utffilesuffix..".tex"..[[ and compile it one more time}}]]) else end t = t.."\n\\end{document}" @@ -820,7 +837,7 @@ function processvoc(str, rules, scheme) elseif export_utf == "arabverse" then tofile = str tooutfile(tofile) - return str +-- return str else return str end @@ -851,7 +868,7 @@ function processfullvoc(str, rules, scheme) elseif export_utf == "arabverse" then tofile = str tooutfile(tofile) - return str +-- return str else return str end @@ -880,7 +897,7 @@ function processnovoc(str, rules, scheme) elseif export_utf == "arabverse" then tofile = str tooutfile(tofile) - return str +-- return str else return str end @@ -912,7 +929,7 @@ function processtrans(str, mode, rules, scheme) elseif export_utf == "arabverse" then tofile = str tooutfile(tofile) - return str +-- return str else return str end @@ -956,7 +973,7 @@ function processarbmarks(str) elseif export_utf == "arabverse" then tofile = str tooutfile(tofile) - return str +-- return str else return str end @@ -1022,7 +1039,7 @@ function uc(str) elseif export_utf == "arabverse" then tofile = "\\txtrans{"..str.."}" tooutfile(tofile) - return "\\txtrans{"..str.."}" +-- return "\\txtrans{"..str.."}" else return "\\txtrans{"..str.."}" end -- cgit v1.2.3