diff options
author | Robert Alessi <alessi@robertalessi.net> | 2016-05-08 11:24:20 +0200 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2016-05-08 11:24:20 +0200 |
commit | e80c0d99f7d2511e6e3f3e70cd922f119a1fc217 (patch) | |
tree | cf8de357e12abc01a0699df5acf57f7da29effa9 | |
parent | 3a541689af28f049f62be1f1b4df97763179f847 (diff) | |
download | arabluatex-e80c0d99f7d2511e6e3f3e70cd922f119a1fc217.tar.gz |
first implementation of 'easy' rules set
-rw-r--r-- | arabluatex.dtx | 22 | ||||
-rw-r--r-- | 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 @@ | |||
189 | %</driver> | 189 | %</driver> |
190 | % \fi | 190 | % \fi |
191 | % | 191 | % |
192 | % \CheckSum{286} | 192 | % \CheckSum{0} |
193 | % | 193 | % |
194 | % \CharacterTable | 194 | % \CharacterTable |
195 | % {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 | 195 | % {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 | |||
2060 | {\NewDocumentCommand{\aemph}{m}{$\overline{\text{#1}}$}}} | 2060 | {\NewDocumentCommand{\aemph}{m}{$\overline{\text{#1}}$}}} |
2061 | % \end{macrocode} | 2061 | % \end{macrocode} |
2062 | % \end{macro} | 2062 | % \end{macro} |
2063 | % \begin{macro}{\SetArbEasy} | ||
2064 | % \begin{macro}{\SetArbDeflt} | ||
2065 | % By default, \package{arabluatex} applies complex rules to generate | ||
2066 | % euphonic \arb[trans]{ta^sdId}, \arb[trans]{'alif mamdUdaT} | ||
2067 | % \linebreak and \arb[trans]{sukUn} depending on the modes which are | ||
2068 | % selected, either |voc|, |fullvoc| or |trans|. Such refinements can | ||
2069 | % be discarded with \cs{SetArbEasy}, either globally in the preamble | ||
2070 | % or at any point of the document. Default complex rules can be set | ||
2071 | % back at any point of the document with \cs{\SetArbDflt} | ||
2072 | % \changes{}{}{} | ||
2073 | % \begin{macrocode} | ||
2074 | \def\al@arb@rules{dflt} | ||
2075 | \NewDocumentCommand{\SetArbEasy}{}{\def\al@arb@rules{easy}} | ||
2076 | \NewDocumentCommand{\SetArbDflt}{}{\def\al@arb@rules{default}} | ||
2077 | % \end{macrocode} | ||
2078 | % \end{macro} | ||
2079 | % \end{macro} | ||
2063 | % \begin{macro}{\SetTranslitStyle} By default any transliterated | 2080 | % \begin{macro}{\SetTranslitStyle} By default any transliterated |
2064 | % Arabic text is printed in italics. This can be changed globally in | 2081 | % Arabic text is printed in italics. This can be changed globally in |
2065 | % the preamble or at any point of the document: | 2082 | % the preamble or at any point of the document: |
@@ -2108,7 +2125,8 @@ wa-ya.sIru ta.hta 'l-jildi | |||
2108 | {\edef\@tempa{#1}% | 2125 | {\edef\@tempa{#1}% |
2109 | \ifx\@tempa\al@mode@voc% | 2126 | \ifx\@tempa\al@mode@voc% |
2110 | \bgroup\textdir TRT\arabicfont% | 2127 | \bgroup\textdir TRT\arabicfont% |
2111 | \luadirect{tex.sprint(processvoc(\luastringN{#2}))}\egroup% | 2128 | \luadirect{tex.sprint(processvoc(\luastringN{#2}, |
2129 | \luastringO{\al@arb@rules}))}\egroup% | ||
2112 | \else% | 2130 | \else% |
2113 | \ifx\@tempa\al@mode@fullvoc% | 2131 | \ifx\@tempa\al@mode@fullvoc% |
2114 | \bgroup\textdir TRT\arabicfont% | 2132 | \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) | |||
167 | return str | 167 | return str |
168 | end | 168 | end |
169 | 169 | ||
170 | local function voceasy(str) | ||
171 | str = string.gsub(str, "\\arb(%b{})", function(inside) | ||
172 | inside = string.sub(inside, 2, -2) | ||
173 | for i = 1,#hamza do | ||
174 | inside = string.gsub(inside, hamza[i].a, hamza[i].b) | ||
175 | end | ||
176 | for i = 1,#tanwin do | ||
177 | inside = string.gsub(inside, tanwin[i].a, tanwin[i].b) | ||
178 | end | ||
179 | for i = 1,#trigraphs do | ||
180 | inside = string.gsub(inside, trigraphs[i].a, trigraphs[i].b) | ||
181 | end | ||
182 | for i = 1,#digraphs do | ||
183 | inside = string.gsub(inside, digraphs[i].a, digraphs[i].b) | ||
184 | end | ||
185 | for i = 1,#single do | ||
186 | inside = string.gsub(inside, single[i].a, single[i].b) | ||
187 | end | ||
188 | for i = 1,#longv do | ||
189 | inside = string.gsub(inside, longv[i].a, longv[i].b) | ||
190 | end | ||
191 | for i = 1,#shortv do | ||
192 | inside = string.gsub(inside, shortv[i].a, shortv[i].b) | ||
193 | end | ||
194 | for i = 1,#punctuation do | ||
195 | inside = string.gsub(inside, punctuation[i].a, punctuation[i].b) | ||
196 | end | ||
197 | for i = 1,#null do | ||
198 | inside = string.gsub(inside, null[i].a, null[i].b) | ||
199 | end | ||
200 | inside = indnum(inside) | ||
201 | return string.format("\\txarb{%s}", inside) | ||
202 | end) | ||
203 | return str | ||
204 | end | ||
205 | |||
170 | local function fullvoc(str) | 206 | local function fullvoc(str) |
171 | str = string.gsub(str, "\\arb(%b{})", function(inside) | 207 | str = string.gsub(str, "\\arb(%b{})", function(inside) |
172 | inside = string.sub(inside, 2, -2) | 208 | inside = string.sub(inside, 2, -2) |
@@ -312,13 +348,17 @@ local function transloc(str) | |||
312 | return str | 348 | return str |
313 | end | 349 | end |
314 | 350 | ||
315 | function processvoc(str) | 351 | function processvoc(str, rules) |
316 | str = "\\arb{".. str.."}" | 352 | str = "\\arb{".. str.."}" |
317 | str = takeoutcap(str) | 353 | str = takeoutcap(str) |
318 | str = protectarb(str) | 354 | str = protectarb(str) |
319 | str = breakcmd(str) | 355 | str = breakcmd(str) |
320 | str = holdcmd(str) | 356 | str = holdcmd(str) |
321 | str = voc(str) | 357 | if rules == "easy" then |
358 | str = voceasy(str) | ||
359 | elseif mode == "dflt" then | ||
360 | str = voc(str) | ||
361 | else end | ||
322 | str = unprotectarb(str) | 362 | str = unprotectarb(str) |
323 | return str | 363 | return str |
324 | end | 364 | end |