From e80c0d99f7d2511e6e3f3e70cd922f119a1fc217 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sun, 8 May 2016 11:24:20 +0200 Subject: first implementation of 'easy' rules set --- arabluatex.dtx | 22 ++++++++++++++++++++-- arabluatex.lua | 44 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 4 deletions(-) diff --git a/arabluatex.dtx b/arabluatex.dtx index dc7193f..f44b309 100644 --- a/arabluatex.dtx +++ b/arabluatex.dtx @@ -189,7 +189,7 @@ % % \fi % -% \CheckSum{286} +% \CheckSum{0} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -2060,6 +2060,23 @@ wa-ya.sIru ta.hta 'l-jildi {\NewDocumentCommand{\aemph}{m}{$\overline{\text{#1}}$}}} % \end{macrocode} % \end{macro} +% \begin{macro}{\SetArbEasy} +% \begin{macro}{\SetArbDeflt} +% By default, \package{arabluatex} applies complex rules to generate +% euphonic \arb[trans]{ta^sdId}, \arb[trans]{'alif mamdUdaT} +% \linebreak and \arb[trans]{sukUn} depending on the modes which are +% selected, either |voc|, |fullvoc| or |trans|. Such refinements can +% be discarded with \cs{SetArbEasy}, either globally in the preamble +% or at any point of the document. Default complex rules can be set +% back at any point of the document with \cs{\SetArbDflt} +% \changes{}{}{} +% \begin{macrocode} +\def\al@arb@rules{dflt} +\NewDocumentCommand{\SetArbEasy}{}{\def\al@arb@rules{easy}} +\NewDocumentCommand{\SetArbDflt}{}{\def\al@arb@rules{default}} +% \end{macrocode} +% \end{macro} +% \end{macro} % \begin{macro}{\SetTranslitStyle} By default any transliterated % Arabic text is printed in italics. This can be changed globally in % the preamble or at any point of the document: @@ -2108,7 +2125,8 @@ wa-ya.sIru ta.hta 'l-jildi {\edef\@tempa{#1}% \ifx\@tempa\al@mode@voc% \bgroup\textdir TRT\arabicfont% - \luadirect{tex.sprint(processvoc(\luastringN{#2}))}\egroup% + \luadirect{tex.sprint(processvoc(\luastringN{#2}, + \luastringO{\al@arb@rules}))}\egroup% \else% \ifx\@tempa\al@mode@fullvoc% \bgroup\textdir TRT\arabicfont% diff --git a/arabluatex.lua b/arabluatex.lua index 4484c27..d999548 100644 --- a/arabluatex.lua +++ b/arabluatex.lua @@ -167,6 +167,42 @@ local function voc(str) return str end +local function voceasy(str) + str = string.gsub(str, "\\arb(%b{})", function(inside) + inside = string.sub(inside, 2, -2) + for i = 1,#hamza do + inside = string.gsub(inside, hamza[i].a, hamza[i].b) + end + for i = 1,#tanwin do + inside = string.gsub(inside, tanwin[i].a, tanwin[i].b) + end + for i = 1,#trigraphs do + inside = string.gsub(inside, trigraphs[i].a, trigraphs[i].b) + end + for i = 1,#digraphs do + inside = string.gsub(inside, digraphs[i].a, digraphs[i].b) + end + for i = 1,#single do + inside = string.gsub(inside, single[i].a, single[i].b) + end + for i = 1,#longv do + inside = string.gsub(inside, longv[i].a, longv[i].b) + end + for i = 1,#shortv do + inside = string.gsub(inside, shortv[i].a, shortv[i].b) + end + for i = 1,#punctuation do + inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) + end + for i = 1,#null do + inside = string.gsub(inside, null[i].a, null[i].b) + end + inside = indnum(inside) + return string.format("\\txarb{%s}", inside) + end) +return str +end + local function fullvoc(str) str = string.gsub(str, "\\arb(%b{})", function(inside) inside = string.sub(inside, 2, -2) @@ -312,13 +348,17 @@ local function transloc(str) return str end -function processvoc(str) +function processvoc(str, rules) str = "\\arb{".. str.."}" str = takeoutcap(str) str = protectarb(str) str = breakcmd(str) str = holdcmd(str) - str = voc(str) + if rules == "easy" then + str = voceasy(str) + elseif mode == "dflt" then + str = voc(str) + else end str = unprotectarb(str) return str end -- cgit v1.2.3