aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arabluatex.dtx88
-rw-r--r--arabluatex.lua35
2 files changed, 73 insertions, 50 deletions
diff --git a/arabluatex.dtx b/arabluatex.dtx
index e6b6e87..bb4658b 100644
--- a/arabluatex.dtx
+++ b/arabluatex.dtx
@@ -4081,6 +4081,7 @@ wa-ya.sIru ta.hta 'l-jild-i
4081\RequirePackage{xparse} 4081\RequirePackage{xparse}
4082\RequirePackage{environ} 4082\RequirePackage{environ}
4083\RequirePackage{adjustbox} 4083\RequirePackage{adjustbox}
4084\RequirePackage{xstring}
4084% \end{macrocode} 4085% \end{macrocode}
4085% The following boolean will be set to |true| in |RL| mode: 4086% The following boolean will be set to |true| in |RL| mode:
4086% \begin{macrocode} 4087% \begin{macrocode}
@@ -4471,20 +4472,26 @@ wa-ya.sIru ta.hta 'l-jild-i
4471{\bgroup\setkeys[al]{verse}[width, gutter, color, utf, delim, mode, 4472{\bgroup\setkeys[al]{verse}[width, gutter, color, utf, delim, mode,
4472 metre]{#1}% 4473 metre]{#1}%
4473 \if@pkg@export\ifal@verse@export% 4474 \if@pkg@export\ifal@verse@export%
4474 \ArbOutFile{\begin{arabverse}}% 4475 \ArbOutFile{\begin{arabverse}}%
4475 \luadirect{tooutfile(\luastringN{[#1]})}% 4476 \IfSubStr[1]{#1}{utf}%
4476 \else\fi\else\fi\egroup% 4477 {\luadirect{tooutfile(\luastringN{[#1]})}}%
4478 {\luadirect{tooutfile(\luastringN{[#1, utf]})}}%
4479 \else\fi\else\fi\egroup%
4477 \par\centering\noindent\bgroup\setkeys[al]{verse}[metre]{#1}% 4480 \par\centering\noindent\bgroup\setkeys[al]{verse}[metre]{#1}%
4478 \ifx\al@mode\al@mode@trans% 4481 \ifx\al@mode\al@mode@trans%
4479 \ifal@verse@utf\setRL\else\setLR\fi% 4482 \ifal@verse@utf\setRL\else\setLR\fi%
4480 \else\setRL\fi}% 4483 \else\setRL\fi%
4481{\hfill\setkeys[al]{verse}[width, gutter, color, utf, delim, mode, 4484 \arab@v@export{#1}
4482 export]{#1}% 4485 }%
4483 \egroup\par% 4486 {\endarab@v@export
4484 \bgroup\setkeys[al]{verse}[width, gutter, color, utf, delim, mode, 4487 \hfill\setkeys[al]{verse}[width, gutter, color, utf, delim, mode,
4485 metre]{#1}% 4488 export]{#1}%
4486 \if@pkg@export\ifal@verse@export% 4489 \egroup\par%
4487 \ArbOutFile{\end{arabverse}}\else\fi\else\fi\egroup} 4490 \bgroup\setkeys[al]{verse}[width, gutter, color, utf, delim, mode,
4491 metre]{#1}%
4492 \if@pkg@export\ifal@verse@export%
4493 \ArbOutFile{\end{arabverse}}
4494 \else\fi\else\fi\egroup}
4488% \end{macrocode} 4495% \end{macrocode}
4489% \begin{macro}{\bayt} 4496% \begin{macro}{\bayt}
4490% \changes{v1.6}{2016/12/17}{New macro \cs{bayt} for typesetting 4497% \changes{v1.6}{2016/12/17}{New macro \cs{bayt} for typesetting
@@ -4510,25 +4517,20 @@ wa-ya.sIru ta.hta 'l-jild-i
4510\def\al@hemistich@delim{*} 4517\def\al@hemistich@delim{*}
4511\NewDocumentCommand{\SetHemistichDelim}{m}{\def\al@hemistich@delim{#1}} 4518\NewDocumentCommand{\SetHemistichDelim}{m}{\def\al@hemistich@delim{#1}}
4512\def\al@verse@stroke{\leavevmode\xleaders\hbox{\arb{--}}\hfill\kern0pt} 4519\def\al@verse@stroke{\leavevmode\xleaders\hbox{\arb{--}}\hfill\kern0pt}
4513\NewDocumentCommand{\bayt}{m o m}{% 4520\NewDocumentCommand{\bayt}{s m o m}{%
4514 \if@pkg@export\ifal@verse@export% 4521 \IfBooleanTF{#1}{\relax}{\relax}%
4515 \luadirect{al_doexport("arabverse")}\else\fi\else\fi%
4516 {^^^^200b}% quick fix to a bug (or a missing feature) in either 4522 {^^^^200b}% quick fix to a bug (or a missing feature) in either
4517 % luacolor or adjustbox 4523 % luacolor or adjustbox
4518 \ifdefined\savenotes\savenotes\else\fi% 4524 \ifdefined\savenotes\savenotes\else\fi%
4519 \edef\al@tatweel{--}% 4525 \edef\al@tatweel{--}%
4520 \if@pkg@export\ifal@verse@export% 4526 \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#2}}%
4521 \ArbOutFile{\bayt\@al@ob}\else\fi\else\fi% 4527 \IfNoValueTF{#3}{%
4522 \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#1}}%
4523 \if@pkg@export\ifal@verse@export%
4524 \ArbOutFile{\@al@cb}\else\fi\else\fi%
4525 \IfNoValueTF{#2}{%
4526 \ifal@verse@delim\makebox[\al@gutter@width][c]{\al@hemistich@delim}% 4528 \ifal@verse@delim\makebox[\al@gutter@width][c]{\al@hemistich@delim}%
4527 \else% 4529 \else%
4528 \hspace{\al@gutter@width}% 4530 \hspace{\al@gutter@width}%
4529 \fi 4531 \fi
4530 }{% 4532 }{%
4531 \edef\@tempa{#2}% 4533 \edef\@tempa{#3}%
4532 \ifx\@tempa\al@tatweel% 4534 \ifx\@tempa\al@tatweel%
4533 \ifx\al@mode\al@mode@trans% 4535 \ifx\al@mode\al@mode@trans%
4534 \hspace{\al@gutter@width}% 4536 \hspace{\al@gutter@width}%
@@ -4537,29 +4539,15 @@ wa-ya.sIru ta.hta 'l-jild-i
4537 \fi% 4539 \fi%
4538 \else% 4540 \else%
4539 \ifx\al@mode\al@mode@trans% 4541 \ifx\al@mode\al@mode@trans%
4540 \if@pkg@export\ifal@verse@export% 4542 \adjustbox{width=\al@gutter@width, height=\Height}{\arb@utf{#3}}%
4541 \ArbOutFile{[}\else\fi\else\fi%
4542 \adjustbox{width=\al@gutter@width, height=\Height}{\arb@utf{#2}}%
4543 \if@pkg@export\ifal@verse@export%
4544 \ArbOutFile{]}\else\fi\else\fi%
4545 \else% 4543 \else%
4546 \if@pkg@export\ifal@verse@export% 4544 \makebox[\al@gutter@width][s]{\arb@utf{#3}}%
4547 \ArbOutFile{[}\else\fi\else\fi%
4548 \makebox[\al@gutter@width][s]{\arb@utf{#2}}%
4549 \if@pkg@export\ifal@verse@export%
4550 \ArbOutFile{]}\else\fi\else\fi%
4551 \fi\fi}% 4545 \fi\fi}%
4552 \if@pkg@export\ifal@verse@export% 4546 \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#4}}%
4553 \ArbOutFile{\@al@ob}\else\fi\else\fi%
4554 \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#3}}%
4555 \if@pkg@export\ifal@verse@export%
4556 \ArbOutFile{\@al@cb\\ }\else\fi\else\fi%
4557 \ifdefined\spewnotes\spewnotes\else\fi% 4547 \ifdefined\spewnotes\spewnotes\else\fi%
4558 \if@pkg@export\ifal@verse@export%
4559 \luadirect{al_doexport("no")}\else\fi\else\fi%
4560} 4548}
4561% \end{macrocode} 4549% \end{macrocode}
4562% \end{macro} 4550% \end{macro}
4563% \end{environment} 4551% \end{environment}
4564% \begin{macro}{\abjad} \cs{abjad}\marg{number} expresses its argument 4552% \begin{macro}{\abjad} \cs{abjad}\marg{number} expresses its argument
4565% in Arabic letters in accordance with the \arb[trans]{'abjad} 4553% in Arabic letters in accordance with the \arb[trans]{'abjad}
@@ -4691,8 +4679,26 @@ wa-ya.sIru ta.hta 'l-jild-i
4691 \BODY 4679 \BODY
4692 \luadirect{al_doexport("yes")} 4680 \luadirect{al_doexport("yes")}
4693 \luadirect{tex.sprint(arbtoutf(\luastringO{\BODY}))} 4681 \luadirect{tex.sprint(arbtoutf(\luastringO{\BODY}))}
4682 \luadirect{al_doexport("no")}
4694 \else\par\BODY\fi 4683 \else\par\BODY\fi
4695 }[\if@pkg@export\par\luadirect{al_doexport("no")}\else\par\fi] 4684 }[\par]
4685% \end{macrocode}
4686% \end{environment}
4687% \begin{environment}{arab@v@export} The |arab@v@export| environment
4688% does for |arabverse| the same as |arabexport|. It is used
4689% internally by |arabverse|.
4690% \begin{macrocode}
4691\NewEnviron{arab@v@export}[1]{%
4692 \setkeys[al]{verse}[width, gutter, color, utf, delim, mode,
4693 metre]{#1}
4694 \if@pkg@export\ifal@verse@export%
4695 \par
4696 \BODY
4697 \luadirect{al_doexport("arabverse")}
4698 \luadirect{tex.sprint(arbtoutf(\luastringO{\BODY}))}
4699 \luadirect{al_doexport("no")}
4700 \else\par\BODY\fi\else\par\BODY\fi
4701}[\par]
4696% \end{macrocode} 4702% \end{macrocode}
4697% \end{environment} 4703% \end{environment}
4698% \begin{macro}{\arbpardir} 4704% \begin{macro}{\arbpardir}
diff --git a/arabluatex.lua b/arabluatex.lua
index 13db492..9b46d01 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -672,7 +672,20 @@ function al_openstream()
672end 672end
673 673
674local function processarbtoutf(str) 674local function processarbtoutf(str)
675 str = "\\begin{arabexport}"..str 675 if export_utf ~= "arabverse" then
676 str = "\\begin{arabexport}"..str
677 else end
678 str = string.gsub(str, "(\\bayt)%s?(%b{})(%b[])(%b{})", function(tag, argi, argii, argiii)
679 argi = string.sub(argi, 2, -2)
680 argii = string.sub(argii, 2, -2)
681 argiii = string.sub(argiii, 2, -2)
682 return string.format("%s*{\\arb{%s}}[\\arb{%s}]{\\arb{%s}}", tag, argi, argii, argiii)
683 end)
684 str = string.gsub(str, "(\\bayt)%s?(%b{})(%b{})", function(tag, argi, argii)
685 argi = string.sub(argi, 2, -2)
686 argii = string.sub(argii, 2, -2)
687 return string.format("%s*{\\arb{%s}}{\\arb{%s}}", tag, argi, argii)
688 end)
676 str = string.gsub(str, "(\\prname)%s?(%b{})", function(tag, body) 689 str = string.gsub(str, "(\\prname)%s?(%b{})", function(tag, body)
677 body = string.sub(body, 2, -2) 690 body = string.sub(body, 2, -2)
678 if string.find(body, "\\uc%s?%b{}") then 691 if string.find(body, "\\uc%s?%b{}") then
@@ -727,7 +740,9 @@ local function processarbtoutf(str)
727 body = string.gsub(body, "(\\@al@cb)(%s?)", "}%2") 740 body = string.gsub(body, "(\\@al@cb)(%s?)", "}%2")
728 return string.format("{%s}", body) 741 return string.format("{%s}", body)
729 end) 742 end)
730 str = str.."\\end{arabexport}" 743 if export_utf ~= "arabverse" then
744 str = str.."\\end{arabexport}"
745 else end
731 return str 746 return str
732end 747end
733 748
@@ -785,7 +800,9 @@ function al_closestream()
785 t = string.gsub(t, "(\\end%s?)(%b{})", "%1%2\n") 800 t = string.gsub(t, "(\\end%s?)(%b{})", "%1%2\n")
786 t = string.gsub(t, "([^\n]%s-)(\\end)%s?(%b{})", "%1\n%2%3") 801 t = string.gsub(t, "([^\n]%s-)(\\end)%s?(%b{})", "%1\n%2%3")
787 t = string.gsub(t, "\n\n\n", "\n\n") 802 t = string.gsub(t, "\n\n\n", "\n\n")
788 if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") then 803 if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") or
804 string.find(t, "\\begin%s?{document}.-\\[Uu]c%s?%b{}")
805 then
789 tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{There are still 'arabtex' strings to be converted. Open ]]..tex.jobname..utffilesuffix..".tex"..[[ and compile it one more time}}]]) 806 tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{There are still 'arabtex' strings to be converted. Open ]]..tex.jobname..utffilesuffix..".tex"..[[ and compile it one more time}}]])
790 else end 807 else end
791 t = t.."\n\\end{document}" 808 t = t.."\n\\end{document}"
@@ -820,7 +837,7 @@ function processvoc(str, rules, scheme)
820 elseif export_utf == "arabverse" then 837 elseif export_utf == "arabverse" then
821 tofile = str 838 tofile = str
822 tooutfile(tofile) 839 tooutfile(tofile)
823 return str 840-- return str
824 else 841 else
825 return str 842 return str
826 end 843 end
@@ -851,7 +868,7 @@ function processfullvoc(str, rules, scheme)
851 elseif export_utf == "arabverse" then 868 elseif export_utf == "arabverse" then
852 tofile = str 869 tofile = str
853 tooutfile(tofile) 870 tooutfile(tofile)
854 return str 871-- return str
855 else 872 else
856 return str 873 return str
857 end 874 end
@@ -880,7 +897,7 @@ function processnovoc(str, rules, scheme)
880 elseif export_utf == "arabverse" then 897 elseif export_utf == "arabverse" then
881 tofile = str 898 tofile = str
882 tooutfile(tofile) 899 tooutfile(tofile)
883 return str 900-- return str
884 else 901 else
885 return str 902 return str
886 end 903 end
@@ -912,7 +929,7 @@ function processtrans(str, mode, rules, scheme)
912 elseif export_utf == "arabverse" then 929 elseif export_utf == "arabverse" then
913 tofile = str 930 tofile = str
914 tooutfile(tofile) 931 tooutfile(tofile)
915 return str 932-- return str
916 else 933 else
917 return str 934 return str
918 end 935 end
@@ -956,7 +973,7 @@ function processarbmarks(str)
956 elseif export_utf == "arabverse" then 973 elseif export_utf == "arabverse" then
957 tofile = str 974 tofile = str
958 tooutfile(tofile) 975 tooutfile(tofile)
959 return str 976-- return str
960 else 977 else
961 return str 978 return str
962 end 979 end
@@ -1022,7 +1039,7 @@ function uc(str)
1022 elseif export_utf == "arabverse" then 1039 elseif export_utf == "arabverse" then
1023 tofile = "\\txtrans{"..str.."}" 1040 tofile = "\\txtrans{"..str.."}"
1024 tooutfile(tofile) 1041 tooutfile(tofile)
1025 return "\\txtrans{"..str.."}" 1042-- return "\\txtrans{"..str.."}"
1026 else 1043 else
1027 return "\\txtrans{"..str.."}" 1044 return "\\txtrans{"..str.."}"
1028 end 1045 end