From 7b51f6927c7b900d6512eb67e4dceb17393216b0 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Mon, 20 Aug 2018 10:19:24 +0200 Subject: use \prname in processarbout() and process \prname and \uc. some minor corrections. --- arabluatex.lua | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/arabluatex.lua b/arabluatex.lua index b87f2dc..13db492 100644 --- a/arabluatex.lua +++ b/arabluatex.lua @@ -676,7 +676,7 @@ local function processarbtoutf(str) str = string.gsub(str, "(\\prname)%s?(%b{})", function(tag, body) body = string.sub(body, 2, -2) if string.find(body, "\\uc%s?%b{}") then - return string.format("%s{%s}", tag, body) + return string.format("%s*{%s}", tag, body) else return string.format("%s{\\arb[trans]{\\uc{%s}}}", tag, body) end @@ -711,6 +711,10 @@ local function processarbtoutf(str) body = string.sub(body, 2, -2) return string.format("%s\\@al@pr@ob%s\\@al@pr@cb", tag, body) end) + str = string.gsub(str, "(\\[Uu]c)%s?(%b{})", function(tag, body) + body = string.sub(body, 2, -2) + return string.format("%s\\@al@pr@ob%s\\@al@pr@cb", tag, body) + end) str = string.gsub(str, "{", "\\@al@ob") str = string.gsub(str, "} ", "\\@al@cb@sp") str = string.gsub(str, "}", "\\@al@cb") @@ -740,6 +744,11 @@ function arbtoutf(str) body = string.gsub(body, "(\\abjad)%s?(%b{})", "}%1%2\\ArbOutFile{") return string.format("%s{%s}", tag, body) end) + str = string.gsub(str, "(\\ArbOutFile)%s?(%b{})", function(tag, body) + body = string.sub(body, 2, -2) + body = string.gsub(body, "(\\[Uu]c)%s?(%b{})", "}%1%2\\ArbOutFile{") + return string.format("%s{%s}", tag, body) + end) str = string.gsub(str, "(\\ArbOutFile)%s?(%b{})", function(tag, body) body = string.sub(body, 2, -2) body = string.gsub(body, "(\\arbmark)%s?(%b{})", "}%1%2\\ArbOutFile{") @@ -899,7 +908,7 @@ function processtrans(str, mode, rules, scheme) str = unprotectarb(str) if export_utf == "yes" then tofile = str - tooutfile(str) + tooutfile(tofile) elseif export_utf == "arabverse" then tofile = str tooutfile(tofile) @@ -943,7 +952,11 @@ function processarbmarks(str) -- return str if export_utf == "yes" then tofile = str - tooutfile(str) + tooutfile(tofile) + elseif export_utf == "arabverse" then + tofile = str + tooutfile(tofile) + return str else return str end @@ -1001,7 +1014,19 @@ function uc(str) for i = 1,#lcuc do str = string.gsub(str, "(%s[%(%<%[]?)"..lcuc[i].a, "%1"..lcuc[i].b) end - return "\\txtrans{"..str.."}" +-- return "\\txtrans{"..str.."}" +-- + if export_utf == "yes" then + tofile = "\\txtrans{"..str.."}" + tooutfile(tofile) + elseif export_utf == "arabverse" then + tofile = "\\txtrans{"..str.."}" + tooutfile(tofile) + return "\\txtrans{"..str.."}" + else + return "\\txtrans{"..str.."}" + end + return "" end -- this function is adapted from an 'obsolete project' of Khaled -- cgit v1.2.3