diff options
author | Karl Berry <karl@freefriends.org> | 2018-10-09 20:26:52 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-10-09 20:26:52 +0000 |
commit | 815ff6f1c227df5cd720c1db1b0a4b9e6c6398d0 (patch) | |
tree | 2dd799a7b09fba1f5f36a99f7e9166c535534901 /Master/texmf-dist/tex/lualatex | |
parent | 48ea6378daabbb2e379b09ea33972c665b3b12ec (diff) |
arabluatex (9oct18)
git-svn-id: svn://tug.org/texlive/trunk@48868 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/lualatex')
3 files changed, 71 insertions, 26 deletions
diff --git a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua index 4db23a295ed..862b8aeab37 100644 --- a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua +++ b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua @@ -88,7 +88,8 @@ local albrkcmds = { "par", "LRmarginpar", "arbmark", - "abjad" + "abjad", + "ayah" } local brkcmds = {} @@ -201,11 +202,19 @@ local function processarbnull(str, scheme) return str end -local function takeoutabjad(str) +local function takeout_abjad_ayah(str) str = string.gsub(str, "(\\abjad.?)(%b{})", function(tag, body) body = string.sub(body, 2, -2) return string.format("%s", body) end) + str = string.gsub(str, "(\\ayah.?)(%b{})", function(tag, body) + body = string.sub(body, 2, -2) + if tonumber(body) ~= nil and str.len(body) < 4 then + return string.format("(%s)", body) + else + return "<??>" + end + end) return str end @@ -675,15 +684,20 @@ local function processarbtoutf(str) if export_utf ~= "arabverse" then str = "\\begin{arabexport}"..str else end + --[[ -- of no use, see above takeout_abjad_ayah() str = string.gsub(str, "(\\txtrans%s?)(%b{})", function(tag, body) body = string.sub(body, 2, -2) body = string.gsub(body, "(\\abjad%s?)(%b{})", function(btag, bbody) bbody = string.sub(bbody, 2, -2) return string.format("%s", bbody) end) + body = string.gsub(body, "(\\ayah%s?)(%b{})", function(btag, bbody) + bbody = string.sub(bbody, 2, -2) + return string.format("(%s)", bbody) + end) return string.format("%s{%s}", tag, body) end) - + --]] str = string.gsub(str, "(\\txarb%s?)(%b{})", function(tag, body) body = string.sub(body, 2, -2) body = string.gsub(body, "(\\abjad%s?)(%b{})", function(btag, bbody) @@ -699,6 +713,10 @@ local function processarbtoutf(str) bbody = string.sub(bbody, 2, -2) return string.format("%s[rl]{%s}", btag, bbody) end) + body = string.gsub(body, "(\\ayah%s?)(%b{})", function(btag, bbody) + bbody = string.sub(bbody, 2, -2) + return string.format("\\arb[novoc]{%s^^^^06dd}", bbody) + end) return string.format("%s{%s}", tag, body) end) str = string.gsub(str, "(\\bayt)%s?(%b{})(%b[])(%b{})", function(tag, argi, argii, argiii) @@ -813,7 +831,8 @@ function al_closestream() t = string.gsub(t, "(\\@al@ob)", "{") t = string.gsub(t, "(\\@al@cb@sp)", "} ") t = string.gsub(t, "(\\@al@cb)(%s?)", "}") - t = gsub(t, lpeg.Cs("\\begin") * spcenc^-1 * bcbraces * cmdargs, "\n%1%2%3\n") + t = gsub(t, lpeg.Cs("\\begin") * spcenc^-1 * bcbraces * cmdargs, + "\n%1%2%3\n") t = string.gsub(t, "(\\\\)(%s?)", "%1\n") t = string.gsub(t, "(\\\\)(\n)(\\end%s?)(%b{})", "%1%3%4") t = string.gsub(t, "%s-\n(\\begin%s?)(%b{})", "\n%1%2") @@ -822,18 +841,33 @@ 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") - t = string.gsub(t, "(\\txarb%s?%{)(\\txarb%s?)(%b{})(%})", function(tagio, tagii, body, tagic) + t = string.gsub(t, "(\\txarb%s?%{)(\\txarb%s?)(%b{})(%})", + function(tagio, tagii, body, tagic) body = string.sub(body, 2, -2) - return string.format("%s%s%s", tagio, body, tagic) + return + string.format("%s%s%s", tagio, body, tagic) end) - t = string.gsub(t, "(\\prname%s?%*%{)(\\txtrans%s?)(%b{})(%})", function(tagio, tagii, body, tagic) + t = string.gsub(t, "(\\prname%s?%*%{)(\\txtrans%s?)(%b{})(%})", + function(tagio, tagii, body, tagic) body = string.sub(body, 2, -2) return string.format("%s%s%s", tagio, body, tagic) end) - if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") or + 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. Please open ]]..tex.jobname..utffilesuffix..".tex"..[[ and compile it one more time}}]]) + or + string.find(t, "\\begin%s?{document}.-\\abjad%s?%b{}") + or + string.find(t, "\\begin%s?{document}.-\\ayah%s?%b{}") + then + -- issue a warning: + tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{]] + .. + [[There are still 'arabtex' strings to be converted. ]] + .. + [[Please open ]] .. tex.jobname .. utffilesuffix .. ".tex" .. + [[ and compile it one more time}}]]) + -- else end t = t.."\n\\end{document}" io.write(t) @@ -935,7 +969,7 @@ function processtrans(str, mode, rules, scheme) str = takeoutarb(str) str = processdiscretionary(str) str = processarbnull(str, scheme) - str = takeoutabjad(str) + str = takeout_abjad_ayah(str) str = protectarb(str) str = breakcmd(str) str = holdcmd(str) @@ -963,6 +997,7 @@ function processtrans(str, mode, rules, scheme) end function newarbmark(abbr, rtlmk, ltrmk) + abbr = "@"..abbr rtlmk = "\\arabicfont{}"..rtlmk table.insert(arbmarks, {a = abbr, b = rtlmk, c = ltrmk}) table.sort(arbmarks, function(a ,b) return(#a.a > #b.a) end) @@ -979,6 +1014,7 @@ local function isintable(table, element) end function processarbmarks(str, dir) + str = "@"..str if not isintable(arbmarks, str) then str = "\\LR{<??>}"..atletter.."\\al@wrong@mark{}"..atother else @@ -1122,3 +1158,16 @@ function aemph(str, opt) end return str end + +function ayah(str) + if tonumber(str) ~= nil and str.len(str) < 4 then + if tex.textdir == "TRT" then + str = "\\arb[novoc]{"..str.."^^^^06dd}" + elseif tex.textdir == "TLT" then + str = "\\arb[trans]{("..str..")}" + end + return str + else + return "\\LR{<??>}" + end +end diff --git a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.sty b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.sty index 4a46cfe5665..23ab051531b 100644 --- a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.sty +++ b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.sty @@ -41,7 +41,7 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{arabluatex}% -[2018/08/29 v1.14 An ArabTeX-like interface for LuaLaTeX] +[2018/10/09 v1.15 An ArabTeX-like interface for LuaLaTeX] \RequirePackage{ifluatex} \ifluatex\else \PackageError{arabluatex}{lualatex needed}{% @@ -148,25 +148,19 @@ \NewDocumentCommand{\arb}{O{\al@mode} +m}% {\edef\@tempa{#1}% \ifx\@tempa\al@mode@voc% - \booltrue{al@rlmode}% - \bgroup\textdir TRT\arabicfont% + \bgroup\booltrue{al@rlmode}\textdir TRT\arabicfont% \luadirect{tex.sprint(processvoc(\luastringN{#2}, \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup% - \boolfalse{al@rlmode}% \else% \ifx\@tempa\al@mode@fullvoc% - \booltrue{al@rlmode}% - \bgroup\textdir TRT\arabicfont% + \bgroup\booltrue{al@rlmode}\textdir TRT\arabicfont% \luadirect{tex.sprint(processfullvoc(\luastringN{#2}, \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup% - \boolfalse{al@rlmode}% \else% \ifx\@tempa\al@mode@novoc% - \booltrue{al@rlmode}% - \bgroup\textdir TRT\arabicfont% + \bgroup\booltrue{al@rlmode}\textdir TRT\arabicfont% \luadirect{tex.sprint(processnovoc(\luastringN{#2}, \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup% - \boolfalse{al@rlmode}% \else% \ifx\@tempa\al@mode@trans% \bgroup\textdir TLT\al@trans@style% @@ -300,6 +294,8 @@ {\aemph{\luadirect{tex.sprint(abjadify(\luastring{#1}))}}} {\luadirect{tex.sprint(abjadify(\luastring{#1}))}}} \fi} +\NewDocumentCommand{\ayah}{m}{% + \luadirect{tex.sprint(ayah(\luastringN{#1}))}} \NewDocumentCommand{\arbnull}{m}{\relax} \NewDocumentCommand{\abraces}{+m}{% \luadirect{tex.sprint(abraces(\luastringN{#1}))}} @@ -345,7 +341,7 @@ \else\par\BODY\fi\else\par\BODY\fi }[\par] \NewDocumentCommand{\arbpardir}{}{% - \ifx\al@mode\al@mode@trans\setLR\else\booltrue{al@rlmode}\setRL\fi} + \ifx\al@mode\al@mode@trans\setLR\else\setRL\fi} \newcommand{\al@warning}[1]{\PackageWarning{arabluatex}{#1}} \newcommand{\al@error}[2]{\PackageError{arabluatex}{#1}{#2}} \newcommand{\al@wrong@nesting}{\al@error{% diff --git a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex_voc.lua b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex_voc.lua index 842f42b78ee..c70e0557a0d 100644 --- a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex_voc.lua +++ b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex_voc.lua @@ -23,10 +23,10 @@ along with this program. If not, see --]] arbmarks = { - {a="bismillah", b="\\arabicfont{}^^^^fdfd", c="\\arb[trans]{bi-ismi \\uc{'l-l_ahi} 'l-ra.hm_ani 'l-ra.hImi}"}, - {a="salam", b="\\arabicfont{}^^^^fdf5", c="\\arb[trans]{.sall_A\\arbnull{'l-l_ahu} \\uc{'l-l_ahu} `alay-hi wa-sallama}"}, - {a="jalla", b="\\arabicfont{}^^^^fdfb", c="\\arb[trans]{^galla ^galAla-hu}"}, - {a="slm", b="\\arabicfont{}^^^^fdfa", c="\\arb[trans]{.sall_A\\arbnull{'l-l_ahu} \\uc{'l-l_ahu} `alay-hi wa-sallama}"} + {a="@bismillah", b="\\arabicfont{}^^^^fdfd", c="\\arb[trans]{bi-ismi \\uc{'l-l_ahi} 'l-ra.hm_ani 'l-ra.hImi}"}, + {a="@salam", b="\\arabicfont{}^^^^fdf5", c="\\arb[trans]{.sall_A\\arbnull{'l-l_ahu} \\uc{'l-l_ahu} `alay-hi wa-sallama}"}, + {a="@jalla", b="\\arabicfont{}^^^^fdfb", c="\\arb[trans]{^galla ^galAla-hu}"}, + {a="@slm", b="\\arabicfont{}^^^^fdfa", c="\\arb[trans]{.sall_A\\arbnull{'l-l_ahu} \\uc{'l-l_ahu} `alay-hi wa-sallama}"} } abjad = { |