From b7b8ca1722448ffcd363bcbac38ccede672c5644 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Wed, 15 Aug 2018 12:01:04 +0200 Subject: tidy up --- arabluatex.dtx | 18 ++++++++++-------- arabluatex.lua | 35 ----------------------------------- 2 files changed, 10 insertions(+), 43 deletions(-) diff --git a/arabluatex.dtx b/arabluatex.dtx index d54290a..091ceb7 100644 --- a/arabluatex.dtx +++ b/arabluatex.dtx @@ -4059,7 +4059,7 @@ wa-ya.sIru ta.hta 'l-jild-i \DeclareOptionX{trans}{\def\al@mode{trans}} \define@boolkey{arabluatex.sty}[@pkg@]{export}[true]{% \AtBeginDocument{\luadirect{al_openstream()}% - \MkArbBreak{@al@ob, @al@cb}} + \MkArbBreak{@al@ob,@al@cb}} \AtEndDocument{\luadirect{al_closestream()}} } \ExecuteOptionsX{voc} @@ -4094,8 +4094,8 @@ wa-ya.sIru ta.hta 'l-jild-i % and attempt to load the Amiri font which is included in \TeX{}live: % \begin{macrocode} \AtBeginDocument{\ifdefined\arabicfont\relax\else -\PackageWarning{arabluatex}{\string\arabicfont\ is not defined.^^JI - will try to load Amiri}% +\PackageWarning{arabluatex}{\string\arabicfont\ is not defined.^^J + I will try to load Amiri}% \newfontfamily\arabicfont[Script=Arabic]{Amiri}\fi}% % \end{macrocode} % \begin{macro}{\setRL} @@ -4471,7 +4471,8 @@ wa-ya.sIru ta.hta 'l-jild-i % Then follows the environment itself: % \begin{macrocode} \NewDocumentEnvironment{arabverse}{O{}}% -{\bgroup\setkeys[al]{verse}[width,gutter,color,utf,delim,mode,metre]{#1}% +{\bgroup\setkeys[al]{verse}[width, gutter, color, utf, delim, mode, + metre]{#1}% \if@pkg@export\ifal@verse@export% \ArbOutFile{\begin{arabverse}}% \luadirect{tooutfile(\luastringN{[#1]})}% @@ -4480,10 +4481,11 @@ wa-ya.sIru ta.hta 'l-jild-i \ifx\al@mode\al@mode@trans% \ifal@verse@utf\setRL\else\setLR\fi% \else\setRL\fi}% -%{\hfill\setkeys[al]{verse}[width,gutter,utf,mode]{#1}\egroup\par} -{\hfill\setkeys[al]{verse}[width,gutter,color,utf,delim,mode,export]{#1}% +{\hfill\setkeys[al]{verse}[width, gutter, color, utf, delim, mode, + export]{#1}% \egroup\par% - \bgroup\setkeys[al]{verse}[width,gutter,color,utf,delim,mode,metre]{#1}% + \bgroup\setkeys[al]{verse}[width, gutter, color, utf, delim, mode, + metre]{#1}% \if@pkg@export\ifal@verse@export% \ArbOutFile{\end{arabverse}}\else\fi\else\fi\egroup} % \end{macrocode} @@ -4695,7 +4697,7 @@ wa-ya.sIru ta.hta 'l-jild-i % right direction. % \begin{macrocode} \NewDocumentCommand{\arbpardir}{}{% - \ifx\al@mode\al@mode@trans\setLR\else\setRL\fi} + \ifx\al@mode\al@mode@trans\setLR\else\booltrue{al@rlmode}\setRL\fi} % \end{macrocode} % \end{macro} % diff --git a/arabluatex.lua b/arabluatex.lua index ac6a251..b578ec5 100644 --- a/arabluatex.lua +++ b/arabluatex.lua @@ -54,7 +54,6 @@ local arbargs = lpeg.Cs(spce^-1 * bsqbrackets^-1 * bcbraces) local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) local function protectarb(str) --- str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\@arb%2%3") str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\al@brk{\\arb%2%3}") str = string.gsub(str, "(\\LR%s?)(%b{})", "\\@LR%2") str = string.gsub(str, "(\\RL%s?)(%b{})", "\\@RL%2") @@ -740,18 +739,6 @@ function arbtoutf(str) body = string.gsub(body, "(\\arbmark)%s?(%b{})", "}%1%2\\ArbOutFile{") return string.format("%s{%s}", tag, body) end) - -- str = string.gsub(str, "(\\arb%s?)(%b[])(%b{})", "}%1%2%3\\ArbOutFile{") - -- str = string.gsub(str, "(\\arb)%s?(%b{})", "}%1%2\\ArbOutFile{") - -- str = gsub(str, lpeg.Cs("\\bayt") * baytargs, "}\\ArbOutFile{\\bayt}%1%2\\ArbOutFile{") --- str = gsub(str, lpeg.Cs("\\arb") * arbargs, "}%1%2\\ArbOutFile{") --- str = string.gsub(str, "(\\abjad)%s?(%b{})", "}%1%2\\ArbOutFile{") --- str = string.gsub(str, "(\\abjad)(%s?)(%b{})", "}%1%3\\ArbOutFile{") --- str = string.gsub(str, "(\\begin%s?{arab})", "}%1") --- str = string.gsub(str, "(\\end%s?{arab})", "%1\\ArbOutFile{") --- str = string.gsub(str, "(\\begin)", "\n%1") --- str = string.gsub(str, "(\\end)", "\n%1") --- str = string.gsub(str, "(\\bayt)", "\n%1") - -- str = string.gsub(str, "(\\\\)", "%1\n") return str end @@ -770,27 +757,6 @@ function al_closestream() local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "r") local o = io.open(tex.jobname..utffilesuffix..".tex", "w") local t = f:read("*a") - --[[ next lines need work! - -- t = string.gsub(t, "{\\textdir TRT\\arabicfont{}", "\\txarb{") - t = string.gsub(t, "(\\bayt%s?)\\txarb(%b{})\\txarb(%b{})\\txarb(%b{})", - function(tag, bodyi, bodyii, bodyiii) - bodyii = string.sub(bodyii, 2, -2) - return string.format("%s%s[%s]%s", - tag, bodyi, bodyii, bodyiii) - end) - t = string.gsub(t, "(\\bayt%s?)\\txarb(%b{})\\txarb(%b{})", "%1%2%3") - t = string.gsub(t, "{\\textdir TRT\\arbmetre{\\arabicfont{}", "\\arbmetre{\\txarb{") - t = string.gsub(t, "(\\bayt%s?)\\txtrans(%b{})\\txtrans(%b{})\\txtrans(%b{})", - function(tag, bodyi, bodyii, bodyiii) - bodyii = string.sub(bodyii, 2, -2) - return string.format("%s%s[%s]%s", - tag, bodyi, bodyii, bodyiii) - end) - t = string.gsub(t, "(\\bayt%s?)\\txtrans(%b{})\\txtrans(%b{})", "%1%2%3") - t = string.gsub(t, "\\txtrans{\\arbmetre{", "\\arbmetre{\\txtrans{") - t = string.gsub(t, "\\arbmetre", "\\\\\n\\hfill") - t = string.gsub(t, "(\\bayt)", "\n%1") - --]] t = string.gsub(t, "\\arabicfont{}", "") t = string.gsub(t, "\\par ", "\n\n") t = string.gsub(t, "(%s?)(\\@al@ob%s?)", "{") @@ -808,7 +774,6 @@ function al_closestream() f:close() o:close() os.remove(tex.jobname..utffilesuffix.."_tmp.tex") --- os.rename(tex.jobname.."_out_tmp.tex", tex.jobname.."_out.tex") return true end -- cgit v1.2.3