aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2018-08-15 11:42:50 +0200
committerRobert Alessi <alessi@robertalessi.net>2018-08-15 11:42:50 +0200
commitc6543e722b554437618e19fcb6ccb5caf73cfc40 (patch)
treef8ecb572d1452be076e441295803cec221064332
parent136c4a8f6ce140ecf7325c0fb0a92dc4bb6464a9 (diff)
downloadarabluatex-c6543e722b554437618e19fcb6ccb5caf73cfc40.tar.gz
arabtex2utf: done programming functions exporting running paragraphs or Arabic verses
-rw-r--r--arabluatex.dtx118
-rw-r--r--arabluatex.lua84
2 files changed, 165 insertions, 37 deletions
diff --git a/arabluatex.dtx b/arabluatex.dtx
index 3dcfc1f..d54290a 100644
--- a/arabluatex.dtx
+++ b/arabluatex.dtx
@@ -3481,9 +3481,15 @@ muhaddamaTaN mi'_danatu-hu}: \arb[trans]{ra'aytu
3481% 'l-\uc{`AdAt-i}}}.\footnote{This is odd in Arabic script, but 3481% 'l-\uc{`AdAt-i}}}.\footnote{This is odd in Arabic script, but
3482% using such features as \cs{emph} or \cs{textbf} is a matter of 3482% using such features as \cs{emph} or \cs{textbf} is a matter of
3483% personal taste.} 3483% personal taste.}
3484% 3484% \NewDocumentCommand{\rlframebox}{o o m}{
3485% |\arb{\abjad{45} \framebox[1in][s]{kitAbu-hu fI 'l-`AdAti}}|\\ 3485% \IfNoValueTF{#2}{\IfNoValueTF{#1}{
3486% \arb{\abjad{45} \framebox[1in][s]{kitAbu-hu fI 'l-`AdAti}} 3486% \framebox{\setRL#3}}{\framebox[#1]{\setRL#3}}
3487% }{\framebox[#1][#2]{\setRL#3}}}
3488%
3489% |\arb{\abjad{45} \rlframebox[1in][s]{kitAbu-hu fI 'l-`AdAti}}|\\
3490% \arb{\abjad{45} \rlframebox[1in][s]{kitAbu-hu fI
3491% 'l-`AdAti}}\,\footnote{\cs{rlframefox} has been adapted from
3492% \cs{framebox} for insertions of right-to-left text.}
3487% \end{quote} 3493% \end{quote}
3488% 3494%
3489% The same applies to footnotes:--- 3495% The same applies to footnotes:---
@@ -4051,6 +4057,11 @@ wa-ya.sIru ta.hta 'l-jild-i
4051\DeclareOptionX{fullvoc}{\def\al@mode{fullvoc}} 4057\DeclareOptionX{fullvoc}{\def\al@mode{fullvoc}}
4052\DeclareOptionX{novoc}{\def\al@mode{novoc}} 4058\DeclareOptionX{novoc}{\def\al@mode{novoc}}
4053\DeclareOptionX{trans}{\def\al@mode{trans}} 4059\DeclareOptionX{trans}{\def\al@mode{trans}}
4060\define@boolkey{arabluatex.sty}[@pkg@]{export}[true]{%
4061 \AtBeginDocument{\luadirect{al_openstream()}%
4062 \MkArbBreak{@al@ob, @al@cb}}
4063 \AtEndDocument{\luadirect{al_closestream()}}
4064}
4054\ExecuteOptionsX{voc} 4065\ExecuteOptionsX{voc}
4055\ProcessOptionsX\relax 4066\ProcessOptionsX\relax
4056\def\al@mode@voc{voc} 4067\def\al@mode@voc{voc}
@@ -4315,10 +4326,10 @@ wa-ya.sIru ta.hta 'l-jild-i
4315% Lua functions to insert transliterated Arabic text. Therefore, it is 4326% Lua functions to insert transliterated Arabic text. Therefore, it is
4316% not documented. 4327% not documented.
4317% \begin{macrocode} 4328% \begin{macrocode}
4318\NewDocumentCommand{\txarb}{+m}{\bgroup\textdir 4329\NewDocumentCommand{\txarb}{+m}{%
4319 TRT\arabicfont#1\egroup} 4330 \bgroup\textdir TRT\arabicfont#1\egroup}
4320\NewDocumentCommand{\txtrans}{+m}{\bgroup\textdir 4331\NewDocumentCommand{\txtrans}{+m}{%
4321 TLT\al@trans@font\al@trans@style#1\egroup} 4332 \bgroup\textdir TLT\al@trans@font\al@trans@style#1\egroup}
4322% \end{macrocode} 4333% \end{macrocode}
4323% \end{macro} 4334% \end{macro}
4324% \end{macro} 4335% \end{macro}
@@ -4451,6 +4462,7 @@ wa-ya.sIru ta.hta 'l-jild-i
4451\define@key[al]{verse}{color}[]{\color{#1}} 4462\define@key[al]{verse}{color}[]{\color{#1}}
4452\define@boolkey[al]{verse}{utf}[true]{} 4463\define@boolkey[al]{verse}{utf}[true]{}
4453\define@boolkey[al]{verse}{delim}[true]{} 4464\define@boolkey[al]{verse}{delim}[true]{}
4465\define@boolkey[al]{verse}{export}[true]{}
4454\define@choicekey[al]{verse}{mode}{fullvoc, voc, novoc, 4466\define@choicekey[al]{verse}{mode}{fullvoc, voc, novoc,
4455 trans}{\def\al@mode{#1}} 4467 trans}{\def\al@mode{#1}}
4456\presetkeys[al]{verse}{metre={}, utf=false, 4468\presetkeys[al]{verse}{metre={}, utf=false,
@@ -4459,11 +4471,21 @@ wa-ya.sIru ta.hta 'l-jild-i
4459% Then follows the environment itself: 4471% Then follows the environment itself:
4460% \begin{macrocode} 4472% \begin{macrocode}
4461\NewDocumentEnvironment{arabverse}{O{}}% 4473\NewDocumentEnvironment{arabverse}{O{}}%
4462{\par\centering\noindent\bgroup\setkeys[al]{verse}[metre]{#1}% 4474{\bgroup\setkeys[al]{verse}[width,gutter,color,utf,delim,mode,metre]{#1}%
4475 \if@pkg@export\ifal@verse@export%
4476 \ArbOutFile{\begin{arabverse}}%
4477 \luadirect{tooutfile(\luastringN{[#1]})}%
4478 \else\fi\else\fi\egroup%
4479 \par\centering\noindent\bgroup\setkeys[al]{verse}[metre]{#1}%
4463 \ifx\al@mode\al@mode@trans% 4480 \ifx\al@mode\al@mode@trans%
4464 \ifal@verse@utf\setRL\else\setLR\fi% 4481 \ifal@verse@utf\setRL\else\setLR\fi%
4465 \else\setRL\fi}% 4482 \else\setRL\fi}%
4466{\hfill\setkeys[al]{verse}[width,gutter,utf,mode]{#1}\egroup\par} 4483%{\hfill\setkeys[al]{verse}[width,gutter,utf,mode]{#1}\egroup\par}
4484{\hfill\setkeys[al]{verse}[width,gutter,color,utf,delim,mode,export]{#1}%
4485 \egroup\par%
4486 \bgroup\setkeys[al]{verse}[width,gutter,color,utf,delim,mode,metre]{#1}%
4487 \if@pkg@export\ifal@verse@export%
4488 \ArbOutFile{\end{arabverse}}\else\fi\else\fi\egroup}
4467% \end{macrocode} 4489% \end{macrocode}
4468% \begin{macro}{\bayt} 4490% \begin{macro}{\bayt}
4469% \changes{v1.6}{2016/12/17}{New macro \cs{bayt} for typesetting 4491% \changes{v1.6}{2016/12/17}{New macro \cs{bayt} for typesetting
@@ -4490,11 +4512,17 @@ wa-ya.sIru ta.hta 'l-jild-i
4490\NewDocumentCommand{\SetHemistichDelim}{m}{\def\al@hemistich@delim{#1}} 4512\NewDocumentCommand{\SetHemistichDelim}{m}{\def\al@hemistich@delim{#1}}
4491\def\al@verse@stroke{\leavevmode\xleaders\hbox{\arb{--}}\hfill\kern0pt} 4513\def\al@verse@stroke{\leavevmode\xleaders\hbox{\arb{--}}\hfill\kern0pt}
4492\NewDocumentCommand{\bayt}{m o m}{% 4514\NewDocumentCommand{\bayt}{m o m}{%
4515 \if@pkg@export\ifal@verse@export%
4516 \luadirect{al_doexport("arabverse")}\else\fi\else\fi%
4493 {^^^^200b}% quick fix to a bug (or a missing feature) in either 4517 {^^^^200b}% quick fix to a bug (or a missing feature) in either
4494 % luacolor or adjustbox 4518 % luacolor or adjustbox
4495 \ifdefined\savenotes\savenotes\else\fi% 4519 \ifdefined\savenotes\savenotes\else\fi%
4496 \edef\al@tatweel{--}% 4520 \edef\al@tatweel{--}%
4521 \if@pkg@export\ifal@verse@export%
4522 \ArbOutFile{\bayt\@al@ob}\else\fi\else\fi%
4497 \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#1}}% 4523 \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#1}}%
4524 \if@pkg@export\ifal@verse@export%
4525 \ArbOutFile{\@al@cb}\else\fi\else\fi%
4498 \IfNoValueTF{#2}{% 4526 \IfNoValueTF{#2}{%
4499 \ifal@verse@delim\makebox[\al@gutter@width][c]{\al@hemistich@delim}% 4527 \ifal@verse@delim\makebox[\al@gutter@width][c]{\al@hemistich@delim}%
4500 \else% 4528 \else%
@@ -4510,12 +4538,26 @@ wa-ya.sIru ta.hta 'l-jild-i
4510 \fi% 4538 \fi%
4511 \else% 4539 \else%
4512 \ifx\al@mode\al@mode@trans% 4540 \ifx\al@mode\al@mode@trans%
4541 \if@pkg@export\ifal@verse@export%
4542 \ArbOutFile{[}\else\fi\else\fi%
4513 \adjustbox{width=\al@gutter@width, height=\Height}{\arb@utf{#2}}% 4543 \adjustbox{width=\al@gutter@width, height=\Height}{\arb@utf{#2}}%
4544 \if@pkg@export\ifal@verse@export%
4545 \ArbOutFile{]}\else\fi\else\fi%
4514 \else% 4546 \else%
4547 \if@pkg@export\ifal@verse@export%
4548 \ArbOutFile{[}\else\fi\else\fi%
4515 \makebox[\al@gutter@width][s]{\arb@utf{#2}}% 4549 \makebox[\al@gutter@width][s]{\arb@utf{#2}}%
4550 \if@pkg@export\ifal@verse@export%
4551 \ArbOutFile{]}\else\fi\else\fi%
4516 \fi\fi}% 4552 \fi\fi}%
4553 \if@pkg@export\ifal@verse@export%
4554 \ArbOutFile{\@al@ob}\else\fi\else\fi%
4517 \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#3}}% 4555 \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#3}}%
4556 \if@pkg@export\ifal@verse@export%
4557 \ArbOutFile{\@al@cb\\ }\else\fi\else\fi%
4518 \ifdefined\spewnotes\spewnotes\else\fi% 4558 \ifdefined\spewnotes\spewnotes\else\fi%
4559 \if@pkg@export\ifal@verse@export%
4560 \luadirect{al_doexport("no")}\else\fi\else\fi%
4519} 4561}
4520% \end{macrocode} 4562% \end{macrocode}
4521% \end{macro} 4563% \end{macro}
@@ -4599,6 +4641,64 @@ wa-ya.sIru ta.hta 'l-jild-i
4599 \AtBeginDocument{\deffootnote{2em}{1.6em}{\LR{\thefootnotemark}.\enskip}}}} 4641 \AtBeginDocument{\deffootnote{2em}{1.6em}{\LR{\thefootnotemark}.\enskip}}}}
4600% \end{macrocode} 4642% \end{macrocode}
4601% \end{macro} 4643% \end{macro}
4644%
4645% \paragraph{Exporting Unicode Arabic to external file}
4646% \begin{macro}{\SetArbOutSuffix}
4647% \changes{v1.13}{2018/08/13}{Sets a suffix to be appended to the
4648% filename of the external Unicode file.}By default, |_out| is the
4649% suffix to be appended to the external file in which
4650% \package{arabluatex} exports Unicode in place of
4651% |arabtex| or |buckwalter| strings. Any other suffix may be
4652% set with \cs{SetArbOutSuffix}\marg{suffix}.
4653% \begin{macrocode}
4654\NewDocumentCommand{\SetArbOutSuffix}{m}{
4655 \luadirect{al_utffilesuffix(\luastringN{#1})}}
4656% \end{macrocode}
4657% \end{macro}
4658% \begin{macro}{\ArbOutFile}
4659% \changes{v1.13}{2018/08/13}{Silently exports its argument in the selected
4660% external file.} \cs{ArbOutFile}\oarg{newline}\marg{string} silently
4661% exports \meta{string} to the external selected file. It may take
4662% |newline| as an optional argument in which case a carriage return is
4663% appended to |string|.
4664% \begin{macrocode}
4665\NewDocumentCommand{\ArbOutFile}{O{no} +m}{%
4666 \if@pkg@export%
4667 \luadirect{tooutfile(\luastringN{#2}, "#1")}\else\fi}
4668% \end{macrocode}
4669% \end{macro}
4670% \begin{environment}{arabexport}
4671% \changes{v1.13}{2018/08/13}{Processes and print its argument in
4672% the current file and exports it in full Unicode in the external
4673% selected \texttt{.tex} file.} The |arabexport| environment
4674% processes and prints its argument unchanged to the current |.pdf|
4675% file. Additionally, if \package{arabluatex} is loaded with the
4676% |export| option, this argument is exported to the external
4677% selected |.tex| file with Unicode in place of the original
4678% |arabtex| or |buckwalter| strings.
4679% \begin{macrocode}
4680\NewEnviron{arabexport}{%
4681 \if@pkg@export%
4682 \par
4683 \BODY
4684 \luadirect{al_doexport("yes")}
4685 \luadirect{tex.sprint(arbtoutf(\luastringO{\BODY}))}
4686 \else\par\BODY\fi
4687 }[\if@pkg@export\par\luadirect{al_doexport("no")}\else\par\fi]
4688% \end{macrocode}
4689% \end{environment}
4690% \begin{macro}{\arbpardir}
4691% \changes{v1.13}{2018/08/13}{Sets the direction of Arabic paragraphs
4692% once they are converted to Unicode.} \cs{arbpardir} is automatically
4693% inserted by \package{arabluatex} at the beginning of Arabic
4694% paragraphs converted to Unicode so that they are printed in the
4695% right direction.
4696% \begin{macrocode}
4697\NewDocumentCommand{\arbpardir}{}{%
4698 \ifx\al@mode\al@mode@trans\setLR\else\setRL\fi}
4699% \end{macrocode}
4700% \end{macro}
4701%
4602% \subsection*{Errors and Warnings} 4702% \subsection*{Errors and Warnings}
4603% \begin{macrocode} 4703% \begin{macrocode}
4604\newcommand{\al@warning}[1]{\PackageWarning{arabluatex}{#1}} 4704\newcommand{\al@warning}[1]{\PackageWarning{arabluatex}{#1}}
diff --git a/arabluatex.lua b/arabluatex.lua
index c0d9022..ac6a251 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -49,7 +49,7 @@ local cmdstar = lpeg.Cs(spce * lpeg.P("*"))
49local bsqbracketsii = lpeg.Cs(bsqbrackets^-2) 49local bsqbracketsii = lpeg.Cs(bsqbrackets^-2)
50local bcbracesii = lpeg.Cs(bcbraces^-2) 50local bcbracesii = lpeg.Cs(bcbraces^-2)
51local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1) 51local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1)
52local cmdargs = lpeg.Cs(spce * bsqbracketsii * bcbracesii * bsqbrackets^-1) 52local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1)
53local arbargs = lpeg.Cs(spce^-1 * bsqbrackets^-1 * bcbraces) 53local arbargs = lpeg.Cs(spce^-1 * bsqbrackets^-1 * bcbraces)
54local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) 54local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces)
55 55
@@ -642,7 +642,9 @@ local function processbuckw(str)
642return str 642return str
643end 643end
644 644
645--- *** 645-- The following functions produce a copy of the original .tex source
646-- file in which all arabtex strings are replaced with Unicode
647-- equivalents
646local utffilesuffix = "_out" 648local utffilesuffix = "_out"
647local export_utf = "no" 649local export_utf = "no"
648 650
@@ -671,14 +673,21 @@ function al_openstream()
671end 673end
672 674
673local function processarbtoutf(str) 675local function processarbtoutf(str)
674 str = "\n\\begin{arbexport}\n"..str 676 str = "\\begin{arabexport}"..str
675 str = string.gsub(str, "(\\prname)%s?(%b{})", function(tag, body) 677 str = string.gsub(str, "(\\prname)%s?(%b{})", function(tag, body)
676 body = string.sub(body, 2, -2) 678 body = string.sub(body, 2, -2)
677 return string.format("\\arb[trans]{\\uc{%s}}", body) 679 return string.format("\\arb[trans]{\\uc{%s}}", body)
678 end) 680 end)
679 str = string.gsub(str, "(\\begin%s?{arab})(%b[])", "\\par\\bgroup\\arbpardir\\arb%2{") 681 str = string.gsub(str, "(\\begin%s?{arab})(%b[])", function(tag, body)
682 if string.find(body, "trans") then
683 return string.format("\\par\\bgroup\\setLR\\arb%s{", body)
684 else
685 return string.format("\\par\\bgroup\\setRL\\arb%s{", body)
686 end
687 end)
680 str = string.gsub(str, "(\\begin%s?{arab})", "\\par\\bgroup\\arbpardir\\arb{") 688 str = string.gsub(str, "(\\begin%s?{arab})", "\\par\\bgroup\\arbpardir\\arb{")
681 str = string.gsub(str, "\\end%s?{arab}", "}\\egroup\\par") 689 str = string.gsub(str, "\\end%s?{arab}", "}\\egroup\\par")
690 -- This does not work, while the following two do. Look into this later.
682 -- str = gsub(str, lpeg.Cs("\\arb") * spcenc * bsqbrackets^-1 * bcbraces, function(tag, opt, body) 691 -- str = gsub(str, lpeg.Cs("\\arb") * spcenc * bsqbrackets^-1 * bcbraces, function(tag, opt, body)
683 -- body = string.sub(body, 2, -2) 692 -- body = string.sub(body, 2, -2)
684 -- return string.format("%s%s\\@al@pr@ob%s\\@al@pr@cb", tag, opt, body) 693 -- return string.format("%s%s\\@al@pr@ob%s\\@al@pr@cb", tag, opt, body)
@@ -699,50 +708,50 @@ local function processarbtoutf(str)
699 body = string.sub(body, 2, -2) 708 body = string.sub(body, 2, -2)
700 return string.format("%s\\@al@pr@ob%s\\@al@pr@cb", tag, body) 709 return string.format("%s\\@al@pr@ob%s\\@al@pr@cb", tag, body)
701 end) 710 end)
702 str = string.gsub(str, "{", "\\@al@ob ") 711 str = string.gsub(str, "{", "\\@al@ob")
703 str = string.gsub(str, "}", "\\@al@cb ") 712 str = string.gsub(str, "}", "\\@al@cb")
704 str = string.gsub(str, "\\@al@pr@ob", "{") 713 str = string.gsub(str, "\\@al@pr@ob", "{")
705 str = string.gsub(str, "\\@al@pr@cb", "}") 714 str = string.gsub(str, "\\@al@pr@cb", "}")
706 str = string.gsub(str, "(%b{})", function(body) 715 str = string.gsub(str, "(%b{})", function(body)
707 body = string.sub(body, 2, -2) 716 body = string.sub(body, 2, -2)
708 body = string.gsub(body, "\\@al@ob%s?", "{") 717 body = string.gsub(body, "(%s?)(\\@al@ob)", "%1{")
709 body = string.gsub(body, "\\@al@cb%s?", "}") 718 body = string.gsub(body, "(\\@al@cb)(%s?)", "}%2")
710 return string.format("{%s}", body) 719 return string.format("{%s}", body)
711 end) 720 end)
712 str = str.."\n\\end{arbexport}" 721 str = str.."\\end{arabexport}"
713 return str 722 return str
714end 723end
715 724
716function arbtoutf(str) 725function arbtoutf(str)
717 str = processarbtoutf(str) 726 str = processarbtoutf(str)
718 str = "\\ToOutFile{"..str.."}" 727 str = "\\ArbOutFile{"..str.."}"
719 str = string.gsub(str, "(\\ToOutFile)%s?(%b{})", function(tag, body) 728 str = string.gsub(str, "(\\ArbOutFile)%s?(%b{})", function(tag, body)
720 body = string.sub(body, 2, -2) 729 body = string.sub(body, 2, -2)
721 body = gsub(body, lpeg.Cs("\\arb") * arbargs, "}%1%2\\ToOutFile{") 730 body = gsub(body, lpeg.Cs("\\arb") * arbargs, "}%1%2\\ArbOutFile{")
722 return string.format("%s{%s}", tag, body) 731 return string.format("%s{%s}", tag, body)
723 end) 732 end)
724 str = string.gsub(str, "(\\ToOutFile)%s?(%b{})", function(tag, body) 733 str = string.gsub(str, "(\\ArbOutFile)%s?(%b{})", function(tag, body)
725 body = string.sub(body, 2, -2) 734 body = string.sub(body, 2, -2)
726 body = string.gsub(body, "(\\abjad)%s?(%b{})", "}%1%2\\ToOutFile{") 735 body = string.gsub(body, "(\\abjad)%s?(%b{})", "}%1%2\\ArbOutFile{")
727 return string.format("%s{%s}", tag, body) 736 return string.format("%s{%s}", tag, body)
728 end) 737 end)
729 str = string.gsub(str, "(\\ToOutFile)%s?(%b{})", function(tag, body) 738 str = string.gsub(str, "(\\ArbOutFile)%s?(%b{})", function(tag, body)
730 body = string.sub(body, 2, -2) 739 body = string.sub(body, 2, -2)
731 body = string.gsub(body, "(\\arbmark)%s?(%b{})", "}%1%2\\ToOutFile{") 740 body = string.gsub(body, "(\\arbmark)%s?(%b{})", "}%1%2\\ArbOutFile{")
732 return string.format("%s{%s}", tag, body) 741 return string.format("%s{%s}", tag, body)
733 end) 742 end)
734 -- str = string.gsub(str, "(\\arb%s?)(%b[])(%b{})", "}%1%2%3\\ToOutFile{") 743 -- str = string.gsub(str, "(\\arb%s?)(%b[])(%b{})", "}%1%2%3\\ArbOutFile{")
735 -- str = string.gsub(str, "(\\arb)%s?(%b{})", "}%1%2\\ToOutFile{") 744 -- str = string.gsub(str, "(\\arb)%s?(%b{})", "}%1%2\\ArbOutFile{")
736 -- str = gsub(str, lpeg.Cs("\\bayt") * baytargs, "}\\ToOutFile{\\bayt}%1%2\\ToOutFile{") 745 -- str = gsub(str, lpeg.Cs("\\bayt") * baytargs, "}\\ArbOutFile{\\bayt}%1%2\\ArbOutFile{")
737-- str = gsub(str, lpeg.Cs("\\arb") * arbargs, "}%1%2\\ToOutFile{") 746-- str = gsub(str, lpeg.Cs("\\arb") * arbargs, "}%1%2\\ArbOutFile{")
738-- str = string.gsub(str, "(\\abjad)%s?(%b{})", "}%1%2\\ToOutFile{") 747-- str = string.gsub(str, "(\\abjad)%s?(%b{})", "}%1%2\\ArbOutFile{")
739-- str = string.gsub(str, "(\\abjad)(%s?)(%b{})", "}%1%3\\tooutfile{") 748-- str = string.gsub(str, "(\\abjad)(%s?)(%b{})", "}%1%3\\ArbOutFile{")
740-- str = string.gsub(str, "(\\begin%s?{arab})", "}%1") 749-- str = string.gsub(str, "(\\begin%s?{arab})", "}%1")
741-- str = string.gsub(str, "(\\end%s?{arab})", "%1\\ToOutFile{") 750-- str = string.gsub(str, "(\\end%s?{arab})", "%1\\ArbOutFile{")
742-- str = string.gsub(str, "(\\begin)", "\n%1") 751-- str = string.gsub(str, "(\\begin)", "\n%1")
743-- str = string.gsub(str, "(\\end)", "\n%1") 752-- str = string.gsub(str, "(\\end)", "\n%1")
744-- str = string.gsub(str, "(\\bayt)", "\n%1") 753-- str = string.gsub(str, "(\\bayt)", "\n%1")
745-- str = string.gsub(str, "(\\\\)", "%1\n") 754 -- str = string.gsub(str, "(\\\\)", "%1\n")
746 return str 755 return str
747end 756end
748 757
@@ -784,8 +793,11 @@ function al_closestream()
784 --]] 793 --]]
785 t = string.gsub(t, "\\arabicfont{}", "") 794 t = string.gsub(t, "\\arabicfont{}", "")
786 t = string.gsub(t, "\\par ", "\n\n") 795 t = string.gsub(t, "\\par ", "\n\n")
787 t = string.gsub(t, "\\@al@ob%s?", "{") 796 t = string.gsub(t, "(%s?)(\\@al@ob%s?)", "{")
788 t = string.gsub(t, "\\@al@cb", "}") 797 t = string.gsub(t, "(\\@al@cb)(%s?)", "}%2")
798 t = gsub(t, lpeg.Cs("\\begin") * spcenc^-1 * bcbraces * cmdargs, "\n%1%2%3\n")
799 t = string.gsub(t, "(\\\\)", "%1\n")
800 t = string.gsub(t, "(\\end%s?)(%b{})", "\n%1%2")
789 t = string.gsub(t, "\n\n\n", "\n\n") 801 t = string.gsub(t, "\n\n\n", "\n\n")
790 if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") then 802 if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") then
791 tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{There are still 'arabtex' strings to be converted. Open ]]..tex.jobname..utffilesuffix..".tex"..[[ and compile it one more time}}]]) 803 tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{There are still 'arabtex' strings to be converted. Open ]]..tex.jobname..utffilesuffix..".tex"..[[ and compile it one more time}}]])
@@ -800,7 +812,7 @@ function al_closestream()
800 return true 812 return true
801end 813end
802 814
803 815-- Process standard arabluatex modes:
804function processvoc(str, rules, scheme) 816function processvoc(str, rules, scheme)
805 str = takeoutarb(str) 817 str = takeoutarb(str)
806 str = processarbnull(str, scheme) 818 str = processarbnull(str, scheme)
@@ -820,6 +832,10 @@ function processvoc(str, rules, scheme)
820 if export_utf == "yes" then 832 if export_utf == "yes" then
821 tofile = "\\txarb{"..str.."}" 833 tofile = "\\txarb{"..str.."}"
822 tooutfile(tofile) 834 tooutfile(tofile)
835 elseif export_utf == "arabverse" then
836 tofile = "\\txarb{"..str.."}"
837 tooutfile(tofile)
838 return str
823 else 839 else
824 return str 840 return str
825 end 841 end
@@ -847,6 +863,10 @@ function processfullvoc(str, rules, scheme)
847 if export_utf == "yes" then 863 if export_utf == "yes" then
848 tofile = "\\txarb{"..str.."}" 864 tofile = "\\txarb{"..str.."}"
849 tooutfile(tofile) 865 tooutfile(tofile)
866 elseif export_utf == "arabverse" then
867 tofile = "\\txarb{"..str.."}"
868 tooutfile(tofile)
869 return str
850 else 870 else
851 return str 871 return str
852 end 872 end
@@ -872,6 +892,10 @@ function processnovoc(str, rules, scheme)
872 if export_utf == "yes" then 892 if export_utf == "yes" then
873 tofile = "\\txarb{"..str.."}" 893 tofile = "\\txarb{"..str.."}"
874 tooutfile(tofile) 894 tooutfile(tofile)
895 elseif export_utf == "arabverse" then
896 tofile = "\\txarb{"..str.."}"
897 tooutfile(tofile)
898 return str
875 else 899 else
876 return str 900 return str
877 end 901 end
@@ -899,7 +923,11 @@ function processtrans(str, mode, rules, scheme)
899 str = unprotectarb(str) 923 str = unprotectarb(str)
900 if export_utf == "yes" then 924 if export_utf == "yes" then
901 tofile = str 925 tofile = str
902 tooutfile(str) 926 tooutfile(str)
927 elseif export_utf == "arabverse" then
928 tofile = str
929 tooutfile(tofile)
930 return str
903 else 931 else
904 return str 932 return str
905 end 933 end