aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arabluatex.dtx14
-rw-r--r--arabluatex.lua56
-rw-r--r--arabluatex_fullvoc.lua267
-rw-r--r--arabluatex_novoc.lua6
-rw-r--r--arabluatex_voc.lua5
5 files changed, 335 insertions, 13 deletions
diff --git a/arabluatex.dtx b/arabluatex.dtx
index 72792db..67fa916 100644
--- a/arabluatex.dtx
+++ b/arabluatex.dtx
@@ -175,9 +175,11 @@
175% \begin{macrocode} 175% \begin{macrocode}
176\DeclareOption{voc}{\def\al@mode{voc}} 176\DeclareOption{voc}{\def\al@mode{voc}}
177\DeclareOption{novoc}{\def\al@mode{novoc}} 177\DeclareOption{novoc}{\def\al@mode{novoc}}
178\DeclareOption{fullvoc}{\def\al@mode{fullvoc}}
178\ExecuteOptions{voc} 179\ExecuteOptions{voc}
179\ProcessOptions\relax 180\ProcessOptions\relax
180\def\al@mode@voc{voc} 181\def\al@mode@voc{voc}
182\def\al@mode@fullvoc{fullvoc}
181\def\al@mode@novoc{novoc} 183\def\al@mode@novoc{novoc}
182% \newif\ifal@mode@defined 184% \newif\ifal@mode@defined
183\RequirePackage{amsmath} 185\RequirePackage{amsmath}
@@ -208,11 +210,15 @@
208 \bgroup\textdir TRT\arabicfont% 210 \bgroup\textdir TRT\arabicfont%
209 \luadirect{tex.sprint(processvoc("\luaescapestring{#2}"))}\egroup% 211 \luadirect{tex.sprint(processvoc("\luaescapestring{#2}"))}\egroup%
210 \else% 212 \else%
213 \ifx\@tempa\al@mode@fullvoc%
214 \bgroup\textdir TRT\arabicfont%
215 \luadirect{tex.sprint(processfullvoc("\luaescapestring{#2}"))}\egroup%
216 \else%
211 \ifx\@tempa\al@mode@novoc% 217 \ifx\@tempa\al@mode@novoc%
212 \bgroup\textdir TRT\arabicfont% 218 \bgroup\textdir TRT\arabicfont%
213 \luadirect{tex.sprint(processnovoc("\luaescapestring{#2}"))}\egroup% 219 \luadirect{tex.sprint(processnovoc("\luaescapestring{#2}"))}\egroup%
214 \else% 220 \else%
215 \fi\fi} 221 \fi\fi\fi}
216\DeclareDocumentCommand{\aemph}{m}{$\overline{\text{#1}}$} 222\DeclareDocumentCommand{\aemph}{m}{$\overline{\text{#1}}$}
217\NewEnviron{arab}[1][\al@mode]% 223\NewEnviron{arab}[1][\al@mode]%
218{\par\edef\@tempa{#1}% 224{\par\edef\@tempa{#1}%
@@ -220,12 +226,16 @@
220 \bgroup\pardir TRT\textdir TRT\arabicfont% 226 \bgroup\pardir TRT\textdir TRT\arabicfont%
221 \luadirect{tex.sprint(processvoc("\luaescapestring{\BODY}"))}\egroup% 227 \luadirect{tex.sprint(processvoc("\luaescapestring{\BODY}"))}\egroup%
222 \else% 228 \else%
229 \ifx\@tempa\al@mode@fullvoc%
230 \bgroup\pardir TRT\textdir TRT\arabicfont%
231 \luadirect{tex.sprint(processfullvoc("\luaescapestring{\BODY}"))}\egroup%
232 \else%
223 \ifx\@tempa\al@mode@novoc% 233 \ifx\@tempa\al@mode@novoc%
224 \bgroup\pardir TRT\textdir TRT\arabicfont% 234 \bgroup\pardir TRT\textdir TRT\arabicfont%
225 \luadirect{tex.sprint(processnovoc("\luaescapestring{\BODY}"))}\egroup% 235 \luadirect{tex.sprint(processnovoc("\luaescapestring{\BODY}"))}\egroup%
226 \else 236 \else
227 \BODY% 237 \BODY%
228 \fi\fi}[\par] 238 \fi\fi\fi}[\par]
229\robustify{\textbf} 239\robustify{\textbf}
230\robustify{\emph} 240\robustify{\emph}
231\robustify{\footnote} 241\robustify{\footnote}
diff --git a/arabluatex.lua b/arabluatex.lua
index 087ee82..76d61b3 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23--]] 23--]]
24 24
25require("arabluatex_voc") 25require("arabluatex_voc")
26require("arabluatex_fullvoc")
26require("arabluatex_novoc") 27require("arabluatex_novoc")
27 28
28local function protectarb(str) 29local function protectarb(str)
@@ -133,14 +134,47 @@ local function voc(str)
133return str 134return str
134end 135end
135 136
137local function fullvoc(str)
138 str = string.gsub(str, "\\arb(%b{})", function(inside)
139 inside = string.sub(inside, 2, -2)
140 for i = 1,#hamzafv do
141 inside = string.gsub(inside, hamzafv[i].a, hamzafv[i].b)
142 end
143 for i = 1,#tanwin do
144 inside = string.gsub(inside, tanwin[i].a, tanwin[i].b)
145 end
146 for i = 1,#trigraphs do
147 inside = string.gsub(inside, trigraphs[i].a, trigraphs[i].b)
148 end
149 for i = 1,#digraphsfv do
150 inside = string.gsub(inside, digraphsfv[i].a, digraphsfv[i].b)
151 end
152 for i = 1,#single do
153 inside = string.gsub(inside, single[i].a, single[i].b)
154 end
155 for i = 1,#longv do
156 inside = string.gsub(inside, longv[i].a, longv[i].b)
157 end
158 for i = 1,#shortv do
159 inside = string.gsub(inside, shortv[i].a, shortv[i].b)
160 end
161 for i = 1,#null do
162 inside = string.gsub(inside, null[i].a, null[i].b)
163 end
164 inside = indnum(inside)
165 return string.format("\\txarb{%s}", inside)
166 end)
167return str
168end
169
136local function novoc(str) 170local function novoc(str)
137 str = string.gsub(str, "\\arb(%b{})", function(inside) 171 str = string.gsub(str, "\\arb(%b{})", function(inside)
138 inside = string.sub(inside, 2, -2) 172 inside = string.sub(inside, 2, -2)
139 for i = 1,#hamza do 173 for i = 1,#hamza do
140 inside = string.gsub(inside, hamza[i].a, hamza[i].b) 174 inside = string.gsub(inside, hamza[i].a, hamza[i].b)
141 end 175 end
142 for i = 1,#tanwinnovoc do 176 for i = 1,#tanwinnv do
143 inside = string.gsub(inside, tanwinnovoc[i].a, tanwinnovoc[i].b) 177 inside = string.gsub(inside, tanwinnv[i].a, tanwinnv[i].b)
144 end 178 end
145 for i = 1,#trigraphs do 179 for i = 1,#trigraphs do
146 inside = string.gsub(inside, trigraphs[i].a, trigraphs[i].b) 180 inside = string.gsub(inside, trigraphs[i].a, trigraphs[i].b)
@@ -151,11 +185,11 @@ local function novoc(str)
151 for i = 1,#single do 185 for i = 1,#single do
152 inside = string.gsub(inside, single[i].a, single[i].b) 186 inside = string.gsub(inside, single[i].a, single[i].b)
153 end 187 end
154 for i = 1,#longvnovoc do 188 for i = 1,#longvnv do
155 inside = string.gsub(inside, longvnovoc[i].a, longvnovoc[i].b) 189 inside = string.gsub(inside, longvnv[i].a, longvnv[i].b)
156 end 190 end
157 for i = 1,#shortvnovoc do 191 for i = 1,#shortvnv do
158 inside = string.gsub(inside, shortvnovoc[i].a, shortvnovoc[i].b) 192 inside = string.gsub(inside, shortvnv[i].a, shortvnv[i].b)
159 end 193 end
160 for i = 1,#null do 194 for i = 1,#null do
161 inside = string.gsub(inside, null[i].a, null[i].b) 195 inside = string.gsub(inside, null[i].a, null[i].b)
@@ -176,6 +210,16 @@ function processvoc(str)
176return str 210return str
177end 211end
178 212
213function processfullvoc(str)
214 str = "\\arb{".. str.."}"
215 str = protectarb(str)
216 str = breakcmd(str)
217 str = holdcmd(str)
218 str = fullvoc(str)
219 str = unprotectarb(str)
220return str
221end
222
179function processnovoc(str) 223function processnovoc(str)
180 str = "\\arb{".. str.."}" 224 str = "\\arb{".. str.."}"
181 str = protectarb(str) 225 str = protectarb(str)
diff --git a/arabluatex_fullvoc.lua b/arabluatex_fullvoc.lua
new file mode 100644
index 0000000..9a6f35a
--- /dev/null
+++ b/arabluatex_fullvoc.lua
@@ -0,0 +1,267 @@
1--[[
2This file is part of the `arabluatex' package
3
4copyright (C) 2016 Robert Alessi
5
6Please send error reports and suggestions for improvements to
7Robert Alessi <alessi@robertalessi.net>
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2202111-1307, USA.
23--]]
24
25numbers = {
26 {a="0", b="٠"},
27 {a="1", b="١"},
28 {a="2", b="٢"},
29 {a="3", b="٣"},
30 {a="4", b="٤"},
31 {a="5", b="٥"},
32 {a="6", b="٦"},
33 {a="7", b="٧"},
34 {a="8", b="٨"},
35 {a="9", b="٩"}
36}
37
38raw = {
39 {a="A", b="َا"},
40 {a="U", b="ُو"},
41 {a="I", b="ِي"},
42 {a="b", b="ب"},
43 {a="t", b="ت"},
44 {a="j", b="ج"},
45 {a="x", b="خ"},
46 {a="d", b="د"},
47 {a="r", b="ر"},
48 {a="z", b="ز"},
49 {a="s", b="س"},
50 {a="f", b="ف"},
51 {a="`", b="ع"},
52 {a="f", b="ف"},
53 {a="q", b="ق"},
54 {a="k", b="ك"},
55 {a="l", b="ل"},
56 {a="m", b="م"},
57 {a="n", b="ن"},
58 {a="h", b="ه"},
59 {a="w", b="و"},
60 {a="y", b="ي"},
61 {a="T", b="ة"},
62 {a="u", b="ُ"},
63 {a="a", b="َ"},
64 {a="i", b="ِ"}
65}
66
67-- this will eventually be new
68hamzafv = {
69 -- initial long u
70 {a="%'%_U", b="أU"},
71 -- madda (historic writing below)
72 {a="'A", b="آ"},
73 -- initial (needs both ^ and %W patterns)
74 {a="^(')([ua])", b="أ%2"},
75 {a="^(')(i)", b="إ%2"},
76 {a="(%W)(')([ua])", b="%1أ%3"},
77 {a="(%W)(')(i)", b="%1إ%3"},
78 -- final
79 {a="([^uai])(')([uai]N?)$", b="%1ء%3"},
80 {a="([^uai])(')([uai]N?)(%W)", b="%1ء%3%4"},
81 {a="([UI])(')([uai])$", b="%1ء%3"},
82 {a="([UI])(')([uai])(%W)", b="%1ء%3%4"},
83 -- middle
84 {a="(A)(')(i)", b="aآئ%3"}, -- historic madda
85 {a="(A)(')", b="aآء"}, -- historic madda
86 {a="([UI])(')", b="%1ء"},
87 {a="([^uai])(')([uU])", b="%1ؤ%3"},
88 {a="([^uai])(')([aA])", b="%1أ%3"},
89 {a="([^uai])(')([iI])", b="%1ئ%3"},
90 {a="(u)(')([uU])", b="%1ؤ%3"},
91 {a="(u)(')([aA])", b="%1ؤ%3"},
92 {a="(u)(')([iI])", b="%1ئ%3"},
93 {a="(a)(')([aA])", b="%1أ%3"},
94 {a="(a)(')([uU])", b="%1ؤ%3"},
95 {a="(a)(')([iI])", b="%1ئ%3"},
96 {a="(i)(')([aA])", b="%1ئ%3"},
97 {a="(i)(')([uU])", b="%1ئ%3"},
98 {a="(i)(')([iI])", b="%1ئ%3"},
99 {a="(a)(')([^uaiUAI])", b="%1أ%3"},
100 {a="(u)(')([^uaiUAI])", b="%1ؤ%3"},
101 {a="(i)(')([^uaiUAI])", b="%1ئ%3"}
102}
103
104trigraphs = { -- trigraphs or more
105 -- 'llatI / 'llad_I
106 {a="^'ll(a)([%_]?[dt])", b="الّ%1%2"},
107 {a="(%s)'ll(a)([%_]?[dt])", b="%1الّ%2%3"},
108 -- al- + lām
109 {a="^(a)l%-(l)", b="ا%1ل%2%2"},
110 {a="(%s)(a)l%-(l)", b="%1ا%2ل%3%3"},
111 -- al- + solar consonant
112 {a="^(a)l%-([%_%^%.]?[tdrzsn])", b="ا%1ل%2%2"},
113 {a="(%s)(a)l%-([%_%^%.]?[tdrzsn])", b="%1ا%2ل%3%3"},
114 -- assim. art. + solar consonant
115 {a="^(a)([%_%^%.]?[tdrzsn])%-", b="ا%1ل%2"},
116 {a="(%s)(a)([%_%^%.]?[tdrzsn])%-", b="%1ا%2ل%3"},
117 -- al- + initial unstable hamza
118 {a="^(a)l%-([uai])", b="ا%1لا%2"},
119 {a="(%s)(a)l%-([uai])", b="%1ا%2لا%3"},
120 -- li- + art. + initial unstable hamza is a special orthography
121 {a="l(i)%-l%-([uai])", b="ل%1لا%2"},
122 -- al- + lunar consonant (i.e. what remains)
123 {a="^(a)l%-", b="ا%1ل"},
124 {a="(%s)(a)l%-", b="%1ا%2ل"},
125 -- art. with waṣla + lām
126 {a="'l%-(l)", b="ال%1%1"},
127 -- art. with waṣla + solar consonant
128 {a="'l%-([%_%^%.]?[tdrzsn])", b="ال%1%1"},
129 -- li- + art. + lām
130 {a="l(i)%-l%-(l)", b="ل%1ل%2%2"},
131 -- assim. art. with waṣla + solar consonant
132 {a="'([%_%^%.]?[tdrzsn])%-", b="ال%1"},
133 -- li- + art. + solar consonant is a special orthography
134 {a="l(i)%-l%-([%_%^%.]?[tdrzsn])", b="ل%1ل%2%2"},
135 -- li- + assim. art. + solar consonant is a special orthography
136 {a="l(i)%-([%_%^%.]?[tdrzsn])%-([%_%^%.]?[tdrzsn])", b="ل%1ل%3%3"},
137 -- art. with waṣla + initial unstable hamza
138 {a="'l%-([uai])", b="الا%1"},
139 -- art. with waṣla + lunar consonant (i.e. what remains)
140 {a="'l%-", b="ال"}
141}
142
143tanwin = {
144 {a="uN", b="ٌ"},
145 {a="(aN)(_A)", b="ًى"},
146 {a="(aN)(Y)", b="ًى"},
147 {a="(T)(aN)", b="%1ً"},
148 {a="([^TA])(aN)", b="%1ًا"},
149 {a="iN", b="ٍ"}
150}
151
152-- this is new
153digraphsfv = {
154 {a="^([uai])", b="ا%1"}, -- initial alif without hamza
155 {a="(%s)([uai])", b="%1ا%2"}, -- initial alif without hamza
156 {a="%-%-", b="ـ"},
157 {a="bb", b="بّ"},
158 {a="BB", b="ـّ"},
159 {a="tt", b="تّ"},
160 {a="%_t%_t", b="ثّ"},
161 {a="jj", b="جّ"},
162 {a="%^g%^g", b="جّ"},
163 {a="xx", b="خّ"},
164 {a="%_h%_h", b="خّ"},
165 {a="dd", b="دّ"},
166 {a="%_d%_d", b="ذّ"},
167 {a="rr", b="رّ"},
168 {a="zz", b="زّ"},
169 {a="ss", b="سّ"},
170 {a="%^s%^s", b="شّ"},
171 {a="%.s%.s", b="صّ"},
172 {a="%.d%.d", b="ضّ"},
173 {a="%.t%.t", b="طّ"},
174 {a="%.z%.z", b="ظّ"},
175 {a="%`%`", b="عّ"},
176 {a="%.g%.g", b="غّ"},
177 {a="ff", b="فّ"},
178 {a="qq", b="قّ"},
179 {a="kk", b="كّ"},
180 {a="ll", b="لّ"},
181 {a="mm", b="مّ"},
182 {a="nn", b="نّ"},
183 {a="hh", b="هّ"},
184 {a="ww", b="وّ"},
185 {a="yy", b="يّ"},
186 -- sukūn end
187 {a="([%_%^%.]?[btjghxdzs%`fqklmnwy])([%s])", b="%1ْ%2"},
188 {a="([%_%^%.]?[btjghxdzs%`fqklmnwy])([^%_uaiUAIًٌٍ])", b="%1ْ%2"},
189 -- sukūn end
190 {a="_t", b="ث"},
191 {a="%^g", b="ج"},
192 {a="%.h", b="ح"},
193 {a="_h", b="خ"},
194 {a="_d", b="ذ"},
195 {a="%^s", b="ش"},
196 {a="%.s", b="ص"},
197 {a="%.d", b="ض"},
198 {a="%.t", b="ط"},
199 {a="%.z", b="ظ"},
200 {a="%.g", b="غ"},
201 {a="(U)(A)", b="%1ا"},
202 {a="WA", b="وا"},
203 {a="(a)W", b="%1وا"},
204 {a="_A", b="aى"},
205 {a="_u", b="ٗ"},
206 {a="_a", b="ٰ"},
207 {a="_i", b="ٖ"},
208 {a="%.b", b="ٮ"},
209 {a="%.f", b="ڡ"},
210 {a="%.k", b="ک"},
211 {a="%.n", b="ں"}
212}
213
214single = {
215 {a="b", b="ب"},
216 {a="t", b="ت"},
217 {a="j", b="ج"},
218 {a="x", b="خ"},
219 {a="d", b="د"},
220 {a="r", b="ر"},
221 {a="z", b="ز"},
222 {a="s", b="س"},
223 {a="f", b="ف"},
224 {a="`", b="ع"},
225 {a="f", b="ف"},
226 {a="q", b="ق"},
227 {a="k", b="ك"},
228 {a="l", b="ل"},
229 {a="m", b="م"},
230 {a="n", b="ن"},
231 {a="h", b="ه"},
232 {a="w", b="و"},
233 {a="y", b="ي"},
234 {a="T", b="ة"},
235 {a="Y", b="aى"},
236 {a='"', b='ْ'},
237 {a="([^0-9])%-([^0-9])", b="%1%2"},
238 {a="B", b="ـ"}
239}
240
241longv = {
242 {a="A", b="َا"},
243 {a="U", b="ُو"},
244 {a="I", b="ِي"}
245}
246
247shortv = {
248 {a="u", b="ُ"},
249 {a="a", b="َ"},
250 {a="i", b="ِ"}
251}
252
253null = {
254 {a="%|", b=""}
255}
256
257-- return {
258-- raw = raw,
259-- hamza = hamza,
260-- trigraphs = trigraphs,
261-- tanwin = tanwin,
262-- digraphs = digraphs,
263-- single = single,
264-- longv = longv,
265-- shortv = shortv,
266-- null =null
267-- }
diff --git a/arabluatex_novoc.lua b/arabluatex_novoc.lua
index b62c1cc..ef8b0ff 100644
--- a/arabluatex_novoc.lua
+++ b/arabluatex_novoc.lua
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2202111-1307, USA. 2202111-1307, USA.
23--]] 23--]]
24 24
25tanwinnovoc = { 25tanwinnv = {
26 {a="uN", b=""}, 26 {a="uN", b=""},
27 {a="(aN)(_A)", b="ى"}, 27 {a="(aN)(_A)", b="ى"},
28 {a="(T)(aN)", b="%1"}, 28 {a="(T)(aN)", b="%1"},
@@ -30,13 +30,13 @@ tanwinnovoc = {
30 {a="iN", b=""} 30 {a="iN", b=""}
31} 31}
32 32
33longvnovoc = { 33longvnv = {
34 {a="A", b="ا"}, 34 {a="A", b="ا"},
35 {a="U", b="و"}, 35 {a="U", b="و"},
36 {a="I", b="ي"} 36 {a="I", b="ي"}
37} 37}
38 38
39shortvnovoc = { 39shortvnv = {
40 {a="u", b=""}, 40 {a="u", b=""},
41 {a="a", b=""}, 41 {a="a", b=""},
42 {a="i", b=""} 42 {a="i", b=""}
diff --git a/arabluatex_voc.lua b/arabluatex_voc.lua
index 5ea68ee..5d35a82 100644
--- a/arabluatex_voc.lua
+++ b/arabluatex_voc.lua
@@ -67,9 +67,8 @@ raw = {
67hamza = { 67hamza = {
68 -- initial long u 68 -- initial long u
69 {a="%'%_U", b="أU"}, 69 {a="%'%_U", b="أU"},
70 -- madda and its historic writing 70 -- madda (historic writing below)
71 {a="'A", b="آ"}, 71 {a="'A", b="آ"},
72 {a="(A)(')", b="aآء"},
73 -- initial (needs both ^ and %W patterns) 72 -- initial (needs both ^ and %W patterns)
74 {a="^(')([ua])", b="أ%2"}, 73 {a="^(')([ua])", b="أ%2"},
75 {a="^(')(i)", b="إ%2"}, 74 {a="^(')(i)", b="إ%2"},
@@ -81,6 +80,8 @@ hamza = {
81 {a="([UI])(')([uai])$", b="%1ء%3"}, 80 {a="([UI])(')([uai])$", b="%1ء%3"},
82 {a="([UI])(')([uai])(%W)", b="%1ء%3%4"}, 81 {a="([UI])(')([uai])(%W)", b="%1ء%3%4"},
83 -- middle 82 -- middle
83 {a="(A)(')(i)", b="aآئ%3"}, -- historic madda
84 {a="(A)(')", b="aآء"}, -- historic madda
84 {a="([UI])(')", b="%1ء"}, 85 {a="([UI])(')", b="%1ء"},
85 {a="([^uai])(')([uU])", b="%1ؤ%3"}, 86 {a="([^uai])(')([uU])", b="%1ؤ%3"},
86 {a="([^uai])(')([aA])", b="%1أ%3"}, 87 {a="([^uai])(')([aA])", b="%1أ%3"},