diff options
author | Robert Alessi <alessi@robertalessi.net> | 2018-08-15 12:01:04 +0200 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2018-08-15 12:01:04 +0200 |
commit | b7b8ca1722448ffcd363bcbac38ccede672c5644 (patch) | |
tree | c04fb431e40656f3b42190dc33781d5c48a2ee12 | |
parent | c6543e722b554437618e19fcb6ccb5caf73cfc40 (diff) | |
download | arabluatex-b7b8ca1722448ffcd363bcbac38ccede672c5644.tar.gz |
tidy up
-rw-r--r-- | arabluatex.dtx | 18 | ||||
-rw-r--r-- | 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 | |||
4059 | \DeclareOptionX{trans}{\def\al@mode{trans}} | 4059 | \DeclareOptionX{trans}{\def\al@mode{trans}} |
4060 | \define@boolkey{arabluatex.sty}[@pkg@]{export}[true]{% | 4060 | \define@boolkey{arabluatex.sty}[@pkg@]{export}[true]{% |
4061 | \AtBeginDocument{\luadirect{al_openstream()}% | 4061 | \AtBeginDocument{\luadirect{al_openstream()}% |
4062 | \MkArbBreak{@al@ob, @al@cb}} | 4062 | \MkArbBreak{@al@ob,@al@cb}} |
4063 | \AtEndDocument{\luadirect{al_closestream()}} | 4063 | \AtEndDocument{\luadirect{al_closestream()}} |
4064 | } | 4064 | } |
4065 | \ExecuteOptionsX{voc} | 4065 | \ExecuteOptionsX{voc} |
@@ -4094,8 +4094,8 @@ wa-ya.sIru ta.hta 'l-jild-i | |||
4094 | % and attempt to load the Amiri font which is included in \TeX{}live: | 4094 | % and attempt to load the Amiri font which is included in \TeX{}live: |
4095 | % \begin{macrocode} | 4095 | % \begin{macrocode} |
4096 | \AtBeginDocument{\ifdefined\arabicfont\relax\else | 4096 | \AtBeginDocument{\ifdefined\arabicfont\relax\else |
4097 | \PackageWarning{arabluatex}{\string\arabicfont\ is not defined.^^JI | 4097 | \PackageWarning{arabluatex}{\string\arabicfont\ is not defined.^^J |
4098 | will try to load Amiri}% | 4098 | I will try to load Amiri}% |
4099 | \newfontfamily\arabicfont[Script=Arabic]{Amiri}\fi}% | 4099 | \newfontfamily\arabicfont[Script=Arabic]{Amiri}\fi}% |
4100 | % \end{macrocode} | 4100 | % \end{macrocode} |
4101 | % \begin{macro}{\setRL} | 4101 | % \begin{macro}{\setRL} |
@@ -4471,7 +4471,8 @@ wa-ya.sIru ta.hta 'l-jild-i | |||
4471 | % Then follows the environment itself: | 4471 | % Then follows the environment itself: |
4472 | % \begin{macrocode} | 4472 | % \begin{macrocode} |
4473 | \NewDocumentEnvironment{arabverse}{O{}}% | 4473 | \NewDocumentEnvironment{arabverse}{O{}}% |
4474 | {\bgroup\setkeys[al]{verse}[width,gutter,color,utf,delim,mode,metre]{#1}% | 4474 | {\bgroup\setkeys[al]{verse}[width, gutter, color, utf, delim, mode, |
4475 | metre]{#1}% | ||
4475 | \if@pkg@export\ifal@verse@export% | 4476 | \if@pkg@export\ifal@verse@export% |
4476 | \ArbOutFile{\begin{arabverse}}% | 4477 | \ArbOutFile{\begin{arabverse}}% |
4477 | \luadirect{tooutfile(\luastringN{[#1]})}% | 4478 | \luadirect{tooutfile(\luastringN{[#1]})}% |
@@ -4480,10 +4481,11 @@ wa-ya.sIru ta.hta 'l-jild-i | |||
4480 | \ifx\al@mode\al@mode@trans% | 4481 | \ifx\al@mode\al@mode@trans% |
4481 | \ifal@verse@utf\setRL\else\setLR\fi% | 4482 | \ifal@verse@utf\setRL\else\setLR\fi% |
4482 | \else\setRL\fi}% | 4483 | \else\setRL\fi}% |
4483 | %{\hfill\setkeys[al]{verse}[width,gutter,utf,mode]{#1}\egroup\par} | 4484 | {\hfill\setkeys[al]{verse}[width, gutter, color, utf, delim, mode, |
4484 | {\hfill\setkeys[al]{verse}[width,gutter,color,utf,delim,mode,export]{#1}% | 4485 | export]{#1}% |
4485 | \egroup\par% | 4486 | \egroup\par% |
4486 | \bgroup\setkeys[al]{verse}[width,gutter,color,utf,delim,mode,metre]{#1}% | 4487 | \bgroup\setkeys[al]{verse}[width, gutter, color, utf, delim, mode, |
4488 | metre]{#1}% | ||
4487 | \if@pkg@export\ifal@verse@export% | 4489 | \if@pkg@export\ifal@verse@export% |
4488 | \ArbOutFile{\end{arabverse}}\else\fi\else\fi\egroup} | 4490 | \ArbOutFile{\end{arabverse}}\else\fi\else\fi\egroup} |
4489 | % \end{macrocode} | 4491 | % \end{macrocode} |
@@ -4695,7 +4697,7 @@ wa-ya.sIru ta.hta 'l-jild-i | |||
4695 | % right direction. | 4697 | % right direction. |
4696 | % \begin{macrocode} | 4698 | % \begin{macrocode} |
4697 | \NewDocumentCommand{\arbpardir}{}{% | 4699 | \NewDocumentCommand{\arbpardir}{}{% |
4698 | \ifx\al@mode\al@mode@trans\setLR\else\setRL\fi} | 4700 | \ifx\al@mode\al@mode@trans\setLR\else\booltrue{al@rlmode}\setRL\fi} |
4699 | % \end{macrocode} | 4701 | % \end{macrocode} |
4700 | % \end{macro} | 4702 | % \end{macro} |
4701 | % | 4703 | % |
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) | |||
54 | local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) | 54 | local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) |
55 | 55 | ||
56 | local function protectarb(str) | 56 | local function protectarb(str) |
57 | -- str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\@arb%2%3") | ||
58 | str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\al@brk{\\arb%2%3}") | 57 | str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\al@brk{\\arb%2%3}") |
59 | str = string.gsub(str, "(\\LR%s?)(%b{})", "\\@LR%2") | 58 | str = string.gsub(str, "(\\LR%s?)(%b{})", "\\@LR%2") |
60 | str = string.gsub(str, "(\\RL%s?)(%b{})", "\\@RL%2") | 59 | str = string.gsub(str, "(\\RL%s?)(%b{})", "\\@RL%2") |
@@ -740,18 +739,6 @@ function arbtoutf(str) | |||
740 | body = string.gsub(body, "(\\arbmark)%s?(%b{})", "}%1%2\\ArbOutFile{") | 739 | body = string.gsub(body, "(\\arbmark)%s?(%b{})", "}%1%2\\ArbOutFile{") |
741 | return string.format("%s{%s}", tag, body) | 740 | return string.format("%s{%s}", tag, body) |
742 | end) | 741 | end) |
743 | -- str = string.gsub(str, "(\\arb%s?)(%b[])(%b{})", "}%1%2%3\\ArbOutFile{") | ||
744 | -- str = string.gsub(str, "(\\arb)%s?(%b{})", "}%1%2\\ArbOutFile{") | ||
745 | -- str = gsub(str, lpeg.Cs("\\bayt") * baytargs, "}\\ArbOutFile{\\bayt}%1%2\\ArbOutFile{") | ||
746 | -- str = gsub(str, lpeg.Cs("\\arb") * arbargs, "}%1%2\\ArbOutFile{") | ||
747 | -- str = string.gsub(str, "(\\abjad)%s?(%b{})", "}%1%2\\ArbOutFile{") | ||
748 | -- str = string.gsub(str, "(\\abjad)(%s?)(%b{})", "}%1%3\\ArbOutFile{") | ||
749 | -- str = string.gsub(str, "(\\begin%s?{arab})", "}%1") | ||
750 | -- str = string.gsub(str, "(\\end%s?{arab})", "%1\\ArbOutFile{") | ||
751 | -- str = string.gsub(str, "(\\begin)", "\n%1") | ||
752 | -- str = string.gsub(str, "(\\end)", "\n%1") | ||
753 | -- str = string.gsub(str, "(\\bayt)", "\n%1") | ||
754 | -- str = string.gsub(str, "(\\\\)", "%1\n") | ||
755 | return str | 742 | return str |
756 | end | 743 | end |
757 | 744 | ||
@@ -770,27 +757,6 @@ function al_closestream() | |||
770 | local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "r") | 757 | local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "r") |
771 | local o = io.open(tex.jobname..utffilesuffix..".tex", "w") | 758 | local o = io.open(tex.jobname..utffilesuffix..".tex", "w") |
772 | local t = f:read("*a") | 759 | local t = f:read("*a") |
773 | --[[ next lines need work! | ||
774 | -- t = string.gsub(t, "{\\textdir TRT\\arabicfont{}", "\\txarb{") | ||
775 | t = string.gsub(t, "(\\bayt%s?)\\txarb(%b{})\\txarb(%b{})\\txarb(%b{})", | ||
776 | function(tag, bodyi, bodyii, bodyiii) | ||
777 | bodyii = string.sub(bodyii, 2, -2) | ||
778 | return string.format("%s%s[%s]%s", | ||
779 | tag, bodyi, bodyii, bodyiii) | ||
780 | end) | ||
781 | t = string.gsub(t, "(\\bayt%s?)\\txarb(%b{})\\txarb(%b{})", "%1%2%3") | ||
782 | t = string.gsub(t, "{\\textdir TRT\\arbmetre{\\arabicfont{}", "\\arbmetre{\\txarb{") | ||
783 | t = string.gsub(t, "(\\bayt%s?)\\txtrans(%b{})\\txtrans(%b{})\\txtrans(%b{})", | ||
784 | function(tag, bodyi, bodyii, bodyiii) | ||
785 | bodyii = string.sub(bodyii, 2, -2) | ||
786 | return string.format("%s%s[%s]%s", | ||
787 | tag, bodyi, bodyii, bodyiii) | ||
788 | end) | ||
789 | t = string.gsub(t, "(\\bayt%s?)\\txtrans(%b{})\\txtrans(%b{})", "%1%2%3") | ||
790 | t = string.gsub(t, "\\txtrans{\\arbmetre{", "\\arbmetre{\\txtrans{") | ||
791 | t = string.gsub(t, "\\arbmetre", "\\\\\n\\hfill") | ||
792 | t = string.gsub(t, "(\\bayt)", "\n%1") | ||
793 | --]] | ||
794 | t = string.gsub(t, "\\arabicfont{}", "") | 760 | t = string.gsub(t, "\\arabicfont{}", "") |
795 | t = string.gsub(t, "\\par ", "\n\n") | 761 | t = string.gsub(t, "\\par ", "\n\n") |
796 | t = string.gsub(t, "(%s?)(\\@al@ob%s?)", "{") | 762 | t = string.gsub(t, "(%s?)(\\@al@ob%s?)", "{") |
@@ -808,7 +774,6 @@ function al_closestream() | |||
808 | f:close() | 774 | f:close() |
809 | o:close() | 775 | o:close() |
810 | os.remove(tex.jobname..utffilesuffix.."_tmp.tex") | 776 | os.remove(tex.jobname..utffilesuffix.."_tmp.tex") |
811 | -- os.rename(tex.jobname.."_out_tmp.tex", tex.jobname.."_out.tex") | ||
812 | return true | 777 | return true |
813 | end | 778 | end |
814 | 779 | ||