diff options
author | Karl Berry <karl@freefriends.org> | 2020-03-03 23:05:43 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-03-03 23:05:43 +0000 |
commit | bb0d98952d1aee8d64d8f04a6352b4b761955ed4 (patch) | |
tree | 6c7a3214e97496ef8045fa8700a5d42805b303a6 /Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua | |
parent | 92e56c9b825469ff667ccc85663f7b7d22dc9494 (diff) |
arabluatex (1mar20)
git-svn-id: svn://tug.org/texlive/trunk@54052 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua')
-rw-r--r-- | Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua index df031569c01..868e11692d3 100644 --- a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua +++ b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua @@ -2,7 +2,7 @@ This file is part of the `arabluatex' package ArabLuaTeX -- Processing ArabTeX notation under LuaLaTeX -Copyright (C) 2016--2019 Robert Alessi +Copyright (C) 2016--2020 Robert Alessi Please send error reports and suggestions for improvements to Robert Alessi <alessi@robertalessi.net> @@ -56,6 +56,7 @@ local aftercmd = lpeg.Cs(lpeg.S("*[{,.?;:'`\"") + dblbkslash) local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1) local arbargs = lpeg.Cs(spce^-1 * bsqbrackets^-1 * bcbraces) local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) +local arind = lpeg.Cs(dblbkslash * lpeg.P("arind") * spce^-1 * bsqbracketsii) local function protectarb(str) str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\al@brk{\\arb%2%3}") @@ -268,7 +269,7 @@ local function takeoutarb(str) end str = string.gsub(str, "(\\arb%s?)(%b{})", function(tag, body) body = string.sub(body, 2, -2) - return string.format("%s", body) + return string.format("\\al@brk{%s{%s}}", tag, body) end) str = string.gsub(str, "\\@rb", "\\arb") str = "\\arb{"..str.."}" @@ -655,6 +656,20 @@ local function processbuckw(str) return str end +local function processarind(str, mode) + str = gsub(str, arind * bcbraces, function(tag, arg) + arg = string.sub(arg, 2, -2) + if mode == "trans" then + return string.format("%s{\\txtrans{%s}}", tag, arg) + else + arg = novoc(arg) + arg = string.gsub(arg, "\\arabicfont%s?{}", "") + return string.format("%s{\\txarb{%s}}", tag, arg) + end + end) + return str +end + -- The following functions produce a copy of the original .tex source -- file in which all arabtex strings are replaced with Unicode -- equivalents @@ -743,15 +758,9 @@ local function processarbtoutf(str) return string.format("%s{\\arb[trans]{\\uc{%s}}}", tag, body) end end) - str = string.gsub(str, "(\\begin%s?{arab})(%b[])", function(tag, body) - if string.find(body, "trans") then - return string.format("\\par\\bgroup\\setLR\\arb%s{", body) - else - return string.format("\\par\\bgroup\\setRL\\arb%s{", body) - end - end) - str = string.gsub(str, "(\\begin%s?{arab})", "\\par\\bgroup\\arbpardir\\arb{") - str = string.gsub(str, "\\end%s?{arab}", "}\\egroup\\par") + str = string.gsub(str, "(\\begin%s?{arab})(%b[])", "\\bgroup\\arb%2{") + str = string.gsub(str, "(\\begin%s?{arab})", "\\bgroup\\arb{") + str = string.gsub(str, "\\end%s?{arab}", "}\\egroup") -- This does not work, while the following two do. Look into this later. -- str = gsub(str, lpeg.Cs("\\arb") * spcenc * bsqbrackets^-1 * bcbraces, function(tag, opt, body) -- body = string.sub(body, 2, -2) @@ -836,6 +845,14 @@ function arabluatex.closestream() t = string.gsub(t, "(\\@al@ob)", "{") t = string.gsub(t, "(\\@al@cb@sp)", "} ") t = string.gsub(t, "(\\@al@cb)(%s?)", "}") + t = string.gsub(t, "(\\bgroup%s?)(\\txarb%s?)(%b{})(\\egroup%s?)", function(tagio, tag, body, tagic) + body = string.sub(body, 2, -2) + return string.format("\\begin{txarab}%s\\end{txarab}", body) + end) + t = string.gsub(t, "(\\bgroup%s?)(\\txtrans%s?)(%b{})(\\egroup%s?)", function(tagio, tag, body, tagic) + body = string.sub(body, 2, -2) + return string.format("\\begin{txarabtr}%s\\end{txarabtr}", body) + end) t = gsub(t, lpeg.Cs("\\begin") * spcenc^-1 * bcbraces * cmdargs, "\n%1%2%3\n") t = string.gsub(t, "(\\\\)(%s?)", "%1\n") @@ -892,6 +909,7 @@ function arabluatex.processvoc(str, rules, scheme) str = protectarb(str) str = breakcmd(str) str = holdcmd(str) + str = processarind(str) if scheme == "buckwalter" then str = processbuckw(str) else end @@ -920,6 +938,7 @@ function arabluatex.processfullvoc(str, rules, scheme) str = protectarb(str) str = breakcmd(str) str = holdcmd(str) + str = processarind(str) if scheme == "buckwalter" then str = processbuckw(str) else end @@ -950,6 +969,7 @@ function arabluatex.processnovoc(str, rules, scheme) str = protectarb(str) str = breakcmd(str) str = holdcmd(str) + str = processarind(str) if scheme == "buckwalter" then str = processbuckw(str) else end @@ -979,6 +999,7 @@ function arabluatex.processtrans(str, mode, rules, scheme) str = protectarb(str) str = breakcmd(str) str = holdcmd(str) + str = processarind(str, "trans") if scheme == "buckwalter" then str = processbuckw(str) end |