aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2019-03-23 10:34:02 +0100
committerRobert Alessi <alessi@robertalessi.net>2019-03-23 10:34:02 +0100
commit374a2ade09506f08e0e903f15f8c08b0ec751120 (patch)
treeb837909c58d9a96ca14cddf9a44890c70d35171d
parent4e2cb2c325214545485ca6c38d0380b402038266 (diff)
downloadarabluatex-374a2ade09506f08e0e903f15f8c08b0ec751120.tar.gz
stored all global functions in the 'arabluatex' table
-rw-r--r--arabluatex.dtx75
-rw-r--r--arabluatex.lua62
2 files changed, 69 insertions, 68 deletions
diff --git a/arabluatex.dtx b/arabluatex.dtx
index 8f13acd..4f185ce 100644
--- a/arabluatex.dtx
+++ b/arabluatex.dtx
@@ -4327,9 +4327,9 @@ wa-ya.sIru ta.hta 'l-jild-i
4327\DeclareOptionX{trans}{\def\al@mode{trans}} 4327\DeclareOptionX{trans}{\def\al@mode{trans}}
4328\define@boolkey{arabluatex.sty}[@pkg@]{export}[true]{% 4328\define@boolkey{arabluatex.sty}[@pkg@]{export}[true]{%
4329 \if@pkg@export% 4329 \if@pkg@export%
4330 \AtBeginDocument{\luadirect{al_openstream()}% 4330 \AtBeginDocument{\luadirect{arabluatex.openstream()}%
4331 \MkArbBreak{@al@ob,@al@cb,@al@cb@sp}} 4331 \MkArbBreak{@al@ob,@al@cb,@al@cb@sp}}
4332 \AtEndDocument{\luadirect{al_closestream()}} 4332 \AtEndDocument{\luadirect{arabluatex.closestream()}}
4333 \else\fi} 4333 \else\fi}
4334\ExecuteOptionsX{voc} 4334\ExecuteOptionsX{voc}
4335\ProcessOptionsX\relax 4335\ProcessOptionsX\relax
@@ -4415,8 +4415,8 @@ wa-ya.sIru ta.hta 'l-jild-i
4415% \begin{macrocode} 4415% \begin{macrocode}
4416\NewDocumentCommand{\MkArbBreak}{s m}{% 4416\NewDocumentCommand{\MkArbBreak}{s m}{%
4417 \IfBooleanTF{#1} 4417 \IfBooleanTF{#1}
4418 {\luadirect{mkarbbreak(\luastringN{#2}, "out")}} 4418 {\luadirect{arabluatex.mkarbbreak(\luastringN{#2}, "out")}}
4419 {\luadirect{mkarbbreak(\luastringN{#2}, "dflt")}} 4419 {\luadirect{arabluatex.mkarbbreak(\luastringN{#2}, "dflt")}}
4420} 4420}
4421% \end{macrocode} 4421% \end{macrocode}
4422% \end{macro} 4422% \end{macro}
@@ -4437,12 +4437,12 @@ wa-ya.sIru ta.hta 'l-jild-i
4437\AtBeginDocument{\ifdef{\aemph}% 4437\AtBeginDocument{\ifdef{\aemph}%
4438 {\RenewDocumentCommand{\aemph}{s m}{% 4438 {\RenewDocumentCommand{\aemph}{s m}{%
4439 \IfBooleanTF{#1}{% 4439 \IfBooleanTF{#1}{%
4440 \luadirect{tex.sprint(aemph(\luastringN{#2}, "over"))}} 4440 \luadirect{tex.sprint(arabluatex.aemph(\luastringN{#2}, "over"))}}
4441 {\luadirect{tex.sprint(aemph(\luastringN{#2}, "dflt"))}}}} 4441 {\luadirect{tex.sprint(arabluatex.aemph(\luastringN{#2}, "dflt"))}}}}
4442 {\NewDocumentCommand{\aemph}{s m}{% 4442 {\NewDocumentCommand{\aemph}{s m}{%
4443 \IfBooleanTF{#1}{% 4443 \IfBooleanTF{#1}{%
4444 \luadirect{tex.sprint(aemph(\luastringN{#2}, "over"))}} 4444 \luadirect{tex.sprint(arabluatex.aemph(\luastringN{#2}, "over"))}}
4445 {\luadirect{tex.sprint(aemph(\luastringN{#2}, "dflt"))}}}}} 4445 {\luadirect{tex.sprint(arabluatex.aemph(\luastringN{#2}, "dflt"))}}}}}
4446% \end{macrocode} 4446% \end{macrocode}
4447% \end{macro} 4447% \end{macro}
4448% \end{macro} 4448% \end{macro}
@@ -4567,7 +4567,7 @@ wa-ya.sIru ta.hta 'l-jild-i
4567% uppercased. \cs{uc} is actually coded in Lua. 4567% uppercased. \cs{uc} is actually coded in Lua.
4568% \begin{macrocode} 4568% \begin{macrocode}
4569\NewDocumentCommand{\uc}{m}% 4569\NewDocumentCommand{\uc}{m}%
4570 {\luadirect{tex.sprint(uc(\luastringN{#1}))}} 4570 {\luadirect{tex.sprint(arabluatex.uc(\luastringN{#1}))}}
4571% \end{macrocode} 4571% \end{macrocode}
4572% \end{macro} 4572% \end{macro}
4573% \begin{macro}{\Uc} \cs{uc} can be used safely in all of the modes 4573% \begin{macro}{\Uc} \cs{uc} can be used safely in all of the modes
@@ -4638,22 +4638,22 @@ wa-ya.sIru ta.hta 'l-jild-i
4638{\edef\@tempa{#1}% 4638{\edef\@tempa{#1}%
4639 \ifx\@tempa\al@mode@voc% 4639 \ifx\@tempa\al@mode@voc%
4640 \bgroup\booltrue{al@rlmode}\textdir TRT\arabicfont% 4640 \bgroup\booltrue{al@rlmode}\textdir TRT\arabicfont%
4641 \luadirect{tex.sprint(processvoc(\luastringN{#2}, 4641 \luadirect{tex.sprint(arabluatex.processvoc(\luastringN{#2},
4642 \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup% 4642 \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup%
4643 \else% 4643 \else%
4644 \ifx\@tempa\al@mode@fullvoc% 4644 \ifx\@tempa\al@mode@fullvoc%
4645 \bgroup\booltrue{al@rlmode}\textdir TRT\arabicfont% 4645 \bgroup\booltrue{al@rlmode}\textdir TRT\arabicfont%
4646 \luadirect{tex.sprint(processfullvoc(\luastringN{#2}, 4646 \luadirect{tex.sprint(arabluatex.processfullvoc(\luastringN{#2},
4647 \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup% 4647 \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup%
4648 \else% 4648 \else%
4649 \ifx\@tempa\al@mode@novoc% 4649 \ifx\@tempa\al@mode@novoc%
4650 \bgroup\booltrue{al@rlmode}\textdir TRT\arabicfont% 4650 \bgroup\booltrue{al@rlmode}\textdir TRT\arabicfont%
4651 \luadirect{tex.sprint(processnovoc(\luastringN{#2}, 4651 \luadirect{tex.sprint(arabluatex.processnovoc(\luastringN{#2},
4652 \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup% 4652 \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup%
4653 \else% 4653 \else%
4654 \ifx\@tempa\al@mode@trans% 4654 \ifx\@tempa\al@mode@trans%
4655 \bgroup\textdir TLT\al@trans@font\al@trans@style% 4655 \bgroup\textdir TLT\al@trans@font\al@trans@style%
4656 \luadirect{tex.sprint(processtrans(\luastringN{#2}, 4656 \luadirect{tex.sprint(arabluatex.processtrans(\luastringN{#2},
4657 \luastringO{\al@trans@convention}, 4657 \luastringO{\al@trans@convention},
4658 \luastringO{\al@arb@rules}, 4658 \luastringO{\al@arb@rules},
4659 \luastringO{\al@input@scheme}))}\egroup% 4659 \luastringO{\al@input@scheme}))}\egroup%
@@ -4674,7 +4674,7 @@ wa-ya.sIru ta.hta 'l-jild-i
4674\NewDocumentCommand{\arbmark}{O{} m}{% 4674\NewDocumentCommand{\arbmark}{O{} m}{%
4675 \bgroup% 4675 \bgroup%
4676 \SetInputScheme{arabtex}% 4676 \SetInputScheme{arabtex}%
4677 \luadirect{tex.sprint(processarbmarks(\luastringN{#2}, 4677 \luadirect{tex.sprint(arabluatex.processarbmarks(\luastringN{#2},
4678 \luastringN{#1}))}% 4678 \luastringN{#1}))}%
4679 \egroup} 4679 \egroup}
4680% \end{macrocode} 4680% \end{macrocode}
@@ -4688,7 +4688,8 @@ wa-ya.sIru ta.hta 'l-jild-i
4688% romanized Arabic. 4688% romanized Arabic.
4689% \begin{macrocode} 4689% \begin{macrocode}
4690\NewDocumentCommand{\newarbmark}{m m m}{% 4690\NewDocumentCommand{\newarbmark}{m m m}{%
4691 \luadirect{newarbmark(\luastringN{#1}, \luastringN{#2}, \luastringN{#3})}} 4691 \luadirect{arabluatex.newarbmark(\luastringN{#1}, \luastringN{#2},
4692 \luastringN{#3})}}
4692% \end{macrocode} 4693% \end{macrocode}
4693% \end{macro} 4694% \end{macro}
4694% \begin{environment}{arab} 4695% \begin{environment}{arab}
@@ -4700,24 +4701,24 @@ wa-ya.sIru ta.hta 'l-jild-i
4700 \ifx\@tempa\al@mode@voc% 4701 \ifx\@tempa\al@mode@voc%
4701 \booltrue{al@rlmode}% 4702 \booltrue{al@rlmode}%
4702 \bgroup\pardir TRT\textdir TRT\arabicfont% 4703 \bgroup\pardir TRT\textdir TRT\arabicfont%
4703 \luadirect{tex.sprint(processvoc(\luastringO{\BODY}, 4704 \luadirect{tex.sprint(arabluatex.processvoc(\luastringO{\BODY},
4704 \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup% 4705 \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup%
4705 \else% 4706 \else%
4706 \ifx\@tempa\al@mode@fullvoc% 4707 \ifx\@tempa\al@mode@fullvoc%
4707 \booltrue{al@rlmode}% 4708 \booltrue{al@rlmode}%
4708 \bgroup\pardir TRT\textdir TRT\arabicfont% 4709 \bgroup\pardir TRT\textdir TRT\arabicfont%
4709 \luadirect{tex.sprint(processfullvoc(\luastringO{\BODY}, 4710 \luadirect{tex.sprint(arabluatex.processfullvoc(\luastringO{\BODY},
4710 \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup% 4711 \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup%
4711 \else% 4712 \else%
4712 \ifx\@tempa\al@mode@novoc% 4713 \ifx\@tempa\al@mode@novoc%
4713 \booltrue{al@rlmode}% 4714 \booltrue{al@rlmode}%
4714 \bgroup\pardir TRT\textdir TRT\arabicfont% 4715 \bgroup\pardir TRT\textdir TRT\arabicfont%
4715 \luadirect{tex.sprint(processnovoc(\luastringO{\BODY}, 4716 \luadirect{tex.sprint(arabluatex.processnovoc(\luastringO{\BODY},
4716 \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup% 4717 \luastringO{\al@arb@rules}, \luastringO{\al@input@scheme}))}\egroup%
4717 \else% 4718 \else%
4718 \ifx\@tempa\al@mode@trans% 4719 \ifx\@tempa\al@mode@trans%
4719 \bgroup\pardir TLT\textdir TLT\al@trans@font\al@trans@style% 4720 \bgroup\pardir TLT\textdir TLT\al@trans@font\al@trans@style%
4720 \luadirect{tex.sprint(processtrans(\luastringO{\BODY}, 4721 \luadirect{tex.sprint(arabluatex.processtrans(\luastringO{\BODY},
4721 \luastringO{\al@trans@convention}, 4722 \luastringO{\al@trans@convention},
4722 \luastringO{\al@arb@rules}, 4723 \luastringO{\al@arb@rules},
4723 \luastringO{\al@input@scheme}))}\egroup% 4724 \luastringO{\al@input@scheme}))}\egroup%
@@ -4758,11 +4759,11 @@ wa-ya.sIru ta.hta 'l-jild-i
4758 \if@pkg@export\ifal@verse@export% 4759 \if@pkg@export\ifal@verse@export%
4759 \ArbOutFile{\begin{arabverse}}% 4760 \ArbOutFile{\begin{arabverse}}%
4760 % \ifx\al@mode\al@mode@trans% 4761 % \ifx\al@mode\al@mode@trans%
4761 % \luadirect{tooutfile(\luastringN{[#1]})}% 4762 % \luadirect{arabluatex.tooutfile(\luastringN{[#1]})}%
4762 % \else% 4763 % \else%
4763 \IfSubStr[1]{#1}{utf}% 4764 \IfSubStr[1]{#1}{utf}%
4764 {\luadirect{tooutfile(\luastringN{[#1]})}}% 4765 {\luadirect{arabluatex.tooutfile(\luastringN{[#1]})}}%
4765 {\luadirect{tooutfile(\luastringN{[#1, utf]})}}% 4766 {\luadirect{arabluatex.tooutfile(\luastringN{[#1, utf]})}}%
4766 % \fi 4767 % \fi
4767 \else\fi\else\fi\egroup% 4768 \else\fi\else\fi\egroup%
4768 \par\centering\noindent\bgroup\setkeys[al]{verse}[metre]{#1}% 4769 \par\centering\noindent\bgroup\setkeys[al]{verse}[metre]{#1}%
@@ -4852,13 +4853,13 @@ wa-ya.sIru ta.hta 'l-jild-i
4852 \ifdefined\abjad% 4853 \ifdefined\abjad%
4853 \RenewDocumentCommand{\abjad}{m}% 4854 \RenewDocumentCommand{\abjad}{m}%
4854 {\ifbool{al@rlmode}% 4855 {\ifbool{al@rlmode}%
4855 {\oline*{\luadirect{tex.sprint(abjadify(\luastring{#1}))}}} 4856 {\oline*{\luadirect{tex.sprint(arabluatex.abjadify(\luastring{#1}))}}}
4856 {\luadirect{tex.sprint(abjadify(\luastring{#1}))}}} 4857 {\luadirect{tex.sprint(arabluatex.abjadify(\luastring{#1}))}}}
4857 \else% 4858 \else%
4858 \NewDocumentCommand{\abjad}{m}% 4859 \NewDocumentCommand{\abjad}{m}%
4859 {\ifbool{al@rlmode}% 4860 {\ifbool{al@rlmode}%
4860 {\oline*{\luadirect{tex.sprint(abjadify(\luastring{#1}))}}} 4861 {\oline*{\luadirect{tex.sprint(arabluatex.abjadify(\luastring{#1}))}}}
4861 {\luadirect{tex.sprint(abjadify(\luastring{#1}))}}} 4862 {\luadirect{tex.sprint(arabluatex.abjadify(\luastring{#1}))}}}
4862 \fi} 4863 \fi}
4863% \end{macrocode} 4864% \end{macrocode}
4864% \end{macro} 4865% \end{macro}
@@ -4868,7 +4869,7 @@ wa-ya.sIru ta.hta 'l-jild-i
4868% depending on the mode which is selected. 4869% depending on the mode which is selected.
4869% \begin{macrocode} 4870% \begin{macrocode}
4870\NewDocumentCommand{\ayah}{m}{% 4871\NewDocumentCommand{\ayah}{m}{%
4871 \luadirect{tex.sprint(ayah(\luastringN{#1}))}} 4872 \luadirect{tex.sprint(arabluatex.ayah(\luastringN{#1}))}}
4872% \end{macrocode} 4873% \end{macrocode}
4873% \end{macro} 4874% \end{macro}
4874% 4875%
@@ -4890,7 +4891,7 @@ wa-ya.sIru ta.hta 'l-jild-i
4890% expresses its argument between braces.} 4891% expresses its argument between braces.}
4891% \begin{macrocode} 4892% \begin{macrocode}
4892\NewDocumentCommand{\abraces}{+m}{% 4893\NewDocumentCommand{\abraces}{+m}{%
4893 \luadirect{tex.sprint(abraces(\luastringN{#1}))}} 4894 \luadirect{tex.sprint(arabluatex.abraces(\luastringN{#1}))}}
4894% \end{macrocode} 4895% \end{macrocode}
4895% \end{macro} 4896% \end{macro}
4896% \begin{macro}{\LRmarginpar} \cs{LRmarginpar} is supposed to be 4897% \begin{macro}{\LRmarginpar} \cs{LRmarginpar} is supposed to be
@@ -4940,7 +4941,7 @@ wa-ya.sIru ta.hta 'l-jild-i
4940% set with \cs{SetArbOutSuffix}\marg{suffix}. 4941% set with \cs{SetArbOutSuffix}\marg{suffix}.
4941% \begin{macrocode} 4942% \begin{macrocode}
4942\NewDocumentCommand{\SetArbOutSuffix}{m}{ 4943\NewDocumentCommand{\SetArbOutSuffix}{m}{
4943 \luadirect{al_utffilesuffix(\luastringN{#1})}} 4944 \luadirect{arabluatex.utffilesuffix(\luastringN{#1})}}
4944% \end{macrocode} 4945% \end{macrocode}
4945% \end{macro} 4946% \end{macro}
4946% \begin{macro}{\ArbOutFile} 4947% \begin{macro}{\ArbOutFile}
@@ -4958,8 +4959,8 @@ wa-ya.sIru ta.hta 'l-jild-i
4958\NewDocumentCommand{\ArbOutFile}{s O{no} +m}{% 4959\NewDocumentCommand{\ArbOutFile}{s O{no} +m}{%
4959 \if@pkg@export% 4960 \if@pkg@export%
4960 \IfBooleanTF{#1}{% 4961 \IfBooleanTF{#1}{%
4961 #3\luadirect{tooutfile(\luastringN{#3}, "#2")}}{% 4962 #3\luadirect{arabluatex.tooutfile(\luastringN{#3}, "#2")}}{%
4962 \luadirect{tooutfile(\luastringN{#3}, "#2")}}% 4963 \luadirect{arabluatex.tooutfile(\luastringN{#3}, "#2")}}%
4963 \else\IfBooleanTF{#1}{#3}{}\fi} 4964 \else\IfBooleanTF{#1}{#3}{}\fi}
4964% \end{macrocode} 4965% \end{macrocode}
4965% \end{macro} 4966% \end{macro}
@@ -4978,9 +4979,9 @@ wa-ya.sIru ta.hta 'l-jild-i
4978 \if@pkg@export% 4979 \if@pkg@export%
4979 \par 4980 \par
4980 \BODY 4981 \BODY
4981 \luadirect{al_doexport("yes")} 4982 \luadirect{arabluatex.doexport("yes")}
4982 \luadirect{tex.sprint(arbtoutf(\luastringO{\BODY}))} 4983 \luadirect{tex.sprint(arabluatex.arbtoutf(\luastringO{\BODY}))}
4983 \luadirect{al_doexport("no")} 4984 \luadirect{arabluatex.doexport("no")}
4984 \else\par\BODY\fi 4985 \else\par\BODY\fi
4985 }[\par] 4986 }[\par]
4986% \end{macrocode} 4987% \end{macrocode}
@@ -4995,9 +4996,9 @@ wa-ya.sIru ta.hta 'l-jild-i
4995 \if@pkg@export\ifal@verse@export% 4996 \if@pkg@export\ifal@verse@export%
4996 \par 4997 \par
4997 \BODY 4998 \BODY
4998 \luadirect{al_doexport("arabverse")} 4999 \luadirect{arabluatex.doexport("arabverse")}
4999 \luadirect{tex.sprint(arbtoutf(\luastringO{\BODY}))} 5000 \luadirect{tex.sprint(arabluatex.arbtoutf(\luastringO{\BODY}))}
5000 \luadirect{al_doexport("no")} 5001 \luadirect{arabluatex.doexport("no")}
5001 \else\par\BODY\fi\else\par\BODY\fi 5002 \else\par\BODY\fi\else\par\BODY\fi
5002}[\par] 5003}[\par]
5003% \end{macrocode} 5004% \end{macrocode}
diff --git a/arabluatex.lua b/arabluatex.lua
index 39b4f56..df03156 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -97,7 +97,7 @@ local albrkcmds = {
97} 97}
98local brkcmds = {} 98local brkcmds = {}
99 99
100function mkarbbreak(str, opt) 100function arabluatex.mkarbbreak(str, opt)
101 str = str .."," 101 str = str ..","
102 str = string.gsub(str, "%s+", "") 102 str = string.gsub(str, "%s+", "")
103 local fieldstart = 1 103 local fieldstart = 1
@@ -661,17 +661,17 @@ end
661local utffilesuffix = "_out" 661local utffilesuffix = "_out"
662local export_utf = "no" 662local export_utf = "no"
663 663
664function al_utffilesuffix(str) 664function arabluatex.utffilesuffix(str)
665 utffilesuffix = str 665 utffilesuffix = str
666 return true 666 return true
667end 667end
668 668
669function al_doexport(str) 669function arabluatex.doexport(str)
670 export_utf = str 670 export_utf = str
671 return true 671 return true
672end 672end
673 673
674function al_openstream() 674function arabluatex.openstream()
675 local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "a+") 675 local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "a+")
676 local preamble = io.open(tex.jobname..".tex", "r") 676 local preamble = io.open(tex.jobname..".tex", "r")
677 for line in preamble:lines() do 677 for line in preamble:lines() do
@@ -708,7 +708,7 @@ local function processarbtoutf(str)
708 body = string.gsub(body, "(\\abjad%s?)(%b{})", function(btag, bbody) 708 body = string.gsub(body, "(\\abjad%s?)(%b{})", function(btag, bbody)
709 bbody = string.sub(bbody, 2, -2) 709 bbody = string.sub(bbody, 2, -2)
710 if tonumber(bbody) ~= nil then 710 if tonumber(bbody) ~= nil then
711 bbody = abjadify(bbody) 711 bbody = arabluatex.abjadify(bbody)
712 return string.format("\\oline*{\\arb[novoc]{%s}}", bbody) 712 return string.format("\\oline*{\\arb[novoc]{%s}}", bbody)
713 else 713 else
714 return string.format("%s{%s}", btag, bbody) 714 return string.format("%s{%s}", btag, bbody)
@@ -795,7 +795,7 @@ local function processarbtoutf(str)
795 return str 795 return str
796end 796end
797 797
798function arbtoutf(str) 798function arabluatex.arbtoutf(str)
799 str = processarbtoutf(str) 799 str = processarbtoutf(str)
800 str = "\\ArbOutFile{"..str.."}" 800 str = "\\ArbOutFile{"..str.."}"
801 str = string.gsub(str, "(\\ArbOutFile)%s?(%b{})", function(tag, body) 801 str = string.gsub(str, "(\\ArbOutFile)%s?(%b{})", function(tag, body)
@@ -816,7 +816,7 @@ function arbtoutf(str)
816 return str 816 return str
817end 817end
818 818
819function tooutfile(str, nl) 819function arabluatex.tooutfile(str, nl)
820 local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "a+") 820 local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "a+")
821 if nl == "newline" then 821 if nl == "newline" then
822 f:write(str, "\n\n") 822 f:write(str, "\n\n")
@@ -827,7 +827,7 @@ function tooutfile(str, nl)
827 return str 827 return str
828end 828end
829 829
830function al_closestream() 830function arabluatex.closestream()
831 local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "r") 831 local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "r")
832 local o = io.open(tex.jobname..utffilesuffix..".tex", "w") 832 local o = io.open(tex.jobname..utffilesuffix..".tex", "w")
833 local t = f:read("*a") 833 local t = f:read("*a")
@@ -885,7 +885,7 @@ function al_closestream()
885end 885end
886 886
887-- Process standard arabluatex modes: 887-- Process standard arabluatex modes:
888function processvoc(str, rules, scheme) 888function arabluatex.processvoc(str, rules, scheme)
889 str = takeoutarb(str) 889 str = takeoutarb(str)
890 str = processarbnull(str, scheme) 890 str = processarbnull(str, scheme)
891 str = takeoutcapetc(str) 891 str = takeoutcapetc(str)
@@ -903,17 +903,17 @@ function processvoc(str, rules, scheme)
903 str = unprotectarb(str) 903 str = unprotectarb(str)
904 if export_utf == "yes" then 904 if export_utf == "yes" then
905 tofile = "\\txarb{"..str.."}" 905 tofile = "\\txarb{"..str.."}"
906 tooutfile(tofile) 906 arabluatex.tooutfile(tofile)
907 elseif export_utf == "arabverse" then 907 elseif export_utf == "arabverse" then
908 tofile = "\\txarb{"..str.."}" 908 tofile = "\\txarb{"..str.."}"
909 tooutfile(tofile) 909 arabluatex.tooutfile(tofile)
910 else 910 else
911 return str 911 return str
912 end 912 end
913 return "" 913 return ""
914end 914end
915 915
916function processfullvoc(str, rules, scheme) 916function arabluatex.processfullvoc(str, rules, scheme)
917 str = takeoutarb(str) 917 str = takeoutarb(str)
918 str = processarbnull(str, scheme) 918 str = processarbnull(str, scheme)
919 str = takeoutcapetc(str) 919 str = takeoutcapetc(str)
@@ -933,17 +933,17 @@ function processfullvoc(str, rules, scheme)
933 str = unprotectarb(str) 933 str = unprotectarb(str)
934 if export_utf == "yes" then 934 if export_utf == "yes" then
935 tofile = "\\txarb{"..str.."}" 935 tofile = "\\txarb{"..str.."}"
936 tooutfile(tofile) 936 arabluatex.tooutfile(tofile)
937 elseif export_utf == "arabverse" then 937 elseif export_utf == "arabverse" then
938 tofile = "\\txarb{"..str.."}" 938 tofile = "\\txarb{"..str.."}"
939 tooutfile(tofile) 939 arabluatex.tooutfile(tofile)
940 else 940 else
941 return str 941 return str
942 end 942 end
943 return "" 943 return ""
944end 944end
945 945
946function processnovoc(str, rules, scheme) 946function arabluatex.processnovoc(str, rules, scheme)
947 str = takeoutarb(str) 947 str = takeoutarb(str)
948 str = processarbnull(str, scheme) 948 str = processarbnull(str, scheme)
949 str = takeoutcapetc(str) 949 str = takeoutcapetc(str)
@@ -961,17 +961,17 @@ function processnovoc(str, rules, scheme)
961 str = unprotectarb(str) 961 str = unprotectarb(str)
962 if export_utf == "yes" then 962 if export_utf == "yes" then
963 tofile = "\\txarb{"..str.."}" 963 tofile = "\\txarb{"..str.."}"
964 tooutfile(tofile) 964 arabluatex.tooutfile(tofile)
965 elseif export_utf == "arabverse" then 965 elseif export_utf == "arabverse" then
966 tofile = "\\txarb{"..str.."}" 966 tofile = "\\txarb{"..str.."}"
967 tooutfile(tofile) 967 arabluatex.tooutfile(tofile)
968 else 968 else
969 return str 969 return str
970 end 970 end
971 return "" 971 return ""
972end 972end
973 973
974function processtrans(str, mode, rules, scheme) 974function arabluatex.processtrans(str, mode, rules, scheme)
975 str = takeoutarb(str) 975 str = takeoutarb(str)
976 str = processdiscretionary(str) 976 str = processdiscretionary(str)
977 str = processarbnull(str, scheme) 977 str = processarbnull(str, scheme)
@@ -992,17 +992,17 @@ function processtrans(str, mode, rules, scheme)
992 str = unprotectarb(str) 992 str = unprotectarb(str)
993 if export_utf == "yes" then 993 if export_utf == "yes" then
994 tofile = "\\txtrans{"..str.."}" 994 tofile = "\\txtrans{"..str.."}"
995 tooutfile(tofile) 995 arabluatex.tooutfile(tofile)
996 elseif export_utf == "arabverse" then 996 elseif export_utf == "arabverse" then
997 tofile = "\\txtrans{"..str.."}" 997 tofile = "\\txtrans{"..str.."}"
998 tooutfile(tofile) 998 arabluatex.tooutfile(tofile)
999 else 999 else
1000 return str 1000 return str
1001 end 1001 end
1002 return "" 1002 return ""
1003end 1003end
1004 1004
1005function newarbmark(abbr, rtlmk, ltrmk) 1005function arabluatex.newarbmark(abbr, rtlmk, ltrmk)
1006 abbr = "@"..abbr 1006 abbr = "@"..abbr
1007 rtlmk = "\\arabicfont{}"..rtlmk 1007 rtlmk = "\\arabicfont{}"..rtlmk
1008 table.insert(arbmarks, {a = abbr, b = rtlmk, c = ltrmk}) 1008 table.insert(arbmarks, {a = abbr, b = rtlmk, c = ltrmk})
@@ -1019,7 +1019,7 @@ local function isintable(table, element)
1019 return false 1019 return false
1020end 1020end
1021 1021
1022function processarbmarks(str, dir) 1022function arabluatex.processarbmarks(str, dir)
1023 str = "@"..str 1023 str = "@"..str
1024 if not isintable(arbmarks, str) then 1024 if not isintable(arbmarks, str) then
1025 str = "\\LR{<??>}"..atletter.."\\al@wrong@mark{}"..atother 1025 str = "\\LR{<??>}"..atletter.."\\al@wrong@mark{}"..atother
@@ -1044,17 +1044,17 @@ function processarbmarks(str, dir)
1044 end 1044 end
1045 if export_utf == "yes" then 1045 if export_utf == "yes" then
1046 tofile = str 1046 tofile = str
1047 tooutfile(tofile) 1047 arabluatex.tooutfile(tofile)
1048 elseif export_utf == "arabverse" then 1048 elseif export_utf == "arabverse" then
1049 tofile = str 1049 tofile = str
1050 tooutfile(tofile) 1050 arabluatex.tooutfile(tofile)
1051 else 1051 else
1052 return str 1052 return str
1053 end 1053 end
1054 return "" 1054 return ""
1055end 1055end
1056 1056
1057function uc(str) 1057function arabluatex.uc(str)
1058 str = string.gsub(str, "(\\txtrans.?)(%b{})", function(tag, body) 1058 str = string.gsub(str, "(\\txtrans.?)(%b{})", function(tag, body)
1059 body = string.sub(body, 2, -2) 1059 body = string.sub(body, 2, -2)
1060 return string.format("%s", body) 1060 return string.format("%s", body)
@@ -1115,10 +1115,10 @@ function uc(str)
1115 str = string.gsub(str, "\\@al@cb", "}") 1115 str = string.gsub(str, "\\@al@cb", "}")
1116 if export_utf == "yes" then 1116 if export_utf == "yes" then
1117 tofile = str 1117 tofile = str
1118 tooutfile(tofile) 1118 arabluatex.tooutfile(tofile)
1119 elseif export_utf == "arabverse" then 1119 elseif export_utf == "arabverse" then
1120 tofile = str 1120 tofile = str
1121 tooutfile(tofile) 1121 arabluatex.tooutfile(tofile)
1122 else 1122 else
1123 return str 1123 return str
1124 end 1124 end
@@ -1128,7 +1128,7 @@ end
1128-- this function is adapted from an 'obsolete project' of Khaled 1128-- this function is adapted from an 'obsolete project' of Khaled
1129-- Hosny's that dates back to 2010. Thanks to him. 1129-- Hosny's that dates back to 2010. Thanks to him.
1130-- See https://github.com/khaledhosny/lualatex-arabic 1130-- See https://github.com/khaledhosny/lualatex-arabic
1131function abjadify(n) 1131function arabluatex.abjadify(n)
1132 local abjadnum = "" 1132 local abjadnum = ""
1133 n = tonumber(n) 1133 n = tonumber(n)
1134 if n >= 1000 then 1134 if n >= 1000 then
@@ -1151,7 +1151,7 @@ function abjadify(n)
1151 return "\\arb[novoc]{"..abjadnum.."}" 1151 return "\\arb[novoc]{"..abjadnum.."}"
1152end 1152end
1153 1153
1154function abraces(str) 1154function arabluatex.abraces(str)
1155 if tex.textdir == "TRT" then 1155 if tex.textdir == "TRT" then
1156 str = "\\}"..str.."\\{" 1156 str = "\\}"..str.."\\{"
1157 elseif tex.textdir == "TLT" then 1157 elseif tex.textdir == "TLT" then
@@ -1160,7 +1160,7 @@ function abraces(str)
1160 return str 1160 return str
1161end 1161end
1162 1162
1163function aemph(str, opt) 1163function arabluatex.aemph(str, opt)
1164 if tex.textdir == "TRT" then 1164 if tex.textdir == "TRT" then
1165 str = "\\oline{\\textdir TRT{}"..str.."}" 1165 str = "\\oline{\\textdir TRT{}"..str.."}"
1166 elseif tex.textdir == "TLT" then 1166 elseif tex.textdir == "TLT" then
@@ -1173,7 +1173,7 @@ function aemph(str, opt)
1173 return str 1173 return str
1174end 1174end
1175 1175
1176function ayah(str) 1176function arabluatex.ayah(str)
1177 if tonumber(str) ~= nil and str.len(str) < 4 then 1177 if tonumber(str) ~= nil and str.len(str) < 4 then
1178 if tex.textdir == "TRT" then 1178 if tex.textdir == "TRT" then
1179 str = indnum(str).."^^^^06dd" 1179 str = indnum(str).."^^^^06dd"