aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2016-03-02 17:27:51 +0100
committerRobert Alessi <alessi@robertalessi.net>2016-03-02 17:27:51 +0100
commite81d65fbcd01afbbd7900b00e65e793b430f8dd0 (patch)
tree92d56a28be4bef90ba9c567674cf8fd1b276a614
parentc8dccd1fa1da5e45bdd951746b942f8de1ffcb29 (diff)
downloadarabluatex-e81d65fbcd01afbbd7900b00e65e793b430f8dd0.tar.gz
add \cap{} command; correct transliteration tables
-rw-r--r--arabluatex.dtx2
-rw-r--r--arabluatex.lua32
-rw-r--r--arabluatex_trans.lua50
3 files changed, 76 insertions, 8 deletions
diff --git a/arabluatex.dtx b/arabluatex.dtx
index 1dbfd3d..09b848c 100644
--- a/arabluatex.dtx
+++ b/arabluatex.dtx
@@ -225,6 +225,8 @@
225\def\al@trans@style{\itshape}% 225\def\al@trans@style{\itshape}%
226\NewDocumentCommand{\SetTranslitStyle}{m}{\def\al@trans@style{#1}} 226\NewDocumentCommand{\SetTranslitStyle}{m}{\def\al@trans@style{#1}}
227\NewDocumentCommand{\SetTranslitConvention}{m}{\def\al@trans@convention{#1}} 227\NewDocumentCommand{\SetTranslitConvention}{m}{\def\al@trans@convention{#1}}
228\DeclareDocumentCommand{\cap}{m}%
229 {\luadirect{tex.sprint(cap(\luastringN{#1}))}}
228\def\al@trans@convention{dmg} 230\def\al@trans@convention{dmg}
229\DeclareDocumentCommand{\txarb}{+m}{\bgroup\textdir 231\DeclareDocumentCommand{\txarb}{+m}{\bgroup\textdir
230 TRT\arabicfont#1\egroup} 232 TRT\arabicfont#1\egroup}
diff --git a/arabluatex.lua b/arabluatex.lua
index d76a284..df23ddc 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -108,6 +108,14 @@ local function indnum(str)
108 return str 108 return str
109end 109end
110 110
111local function takeoutcap(str)
112 str = string.gsub(str, "(\\cap.?)(%b{})", function(tag, body)
113 body = string.sub(body, 2, -2)
114 return string.format("%s", body)
115 end)
116 return str
117end
118
111local function voc(str) 119local function voc(str)
112 str = string.gsub(str, "\\arb(%b{})", function(inside) 120 str = string.gsub(str, "\\arb(%b{})", function(inside)
113 inside = string.sub(inside, 2, -2) 121 inside = string.sub(inside, 2, -2)
@@ -270,6 +278,7 @@ end
270 278
271function processvoc(str) 279function processvoc(str)
272 str = "\\arb{".. str.."}" 280 str = "\\arb{".. str.."}"
281 str = takeoutcap(str)
273 str = protectarb(str) 282 str = protectarb(str)
274 str = breakcmd(str) 283 str = breakcmd(str)
275 str = holdcmd(str) 284 str = holdcmd(str)
@@ -280,6 +289,7 @@ end
280 289
281function processfullvoc(str) 290function processfullvoc(str)
282 str = "\\arb{".. str.."}" 291 str = "\\arb{".. str.."}"
292 str = takeoutcap(str)
283 str = protectarb(str) 293 str = protectarb(str)
284 str = breakcmd(str) 294 str = breakcmd(str)
285 str = holdcmd(str) 295 str = holdcmd(str)
@@ -290,6 +300,7 @@ end
290 300
291function processnovoc(str) 301function processnovoc(str)
292 str = "\\arb{".. str.."}" 302 str = "\\arb{".. str.."}"
303 str = takeoutcap(str)
293 str = protectarb(str) 304 str = protectarb(str)
294 str = breakcmd(str) 305 str = breakcmd(str)
295 str = holdcmd(str) 306 str = holdcmd(str)
@@ -312,6 +323,27 @@ function processtrans(str, mode)
312return str 323return str
313end 324end
314 325
326function cap(str)
327 str = string.gsub(str, "(\\txtrans.?)(%b{})", function(tag, body)
328 body = string.sub(body, 2, -2)
329 return string.format("%s", body)
330 end)
331 if string.find(str, "%-['`ʾʿ]") then
332 str = string.gsub(str, "(%-['`])", "%1\\MakeUppercase ")
333 str = string.gsub(str, "(%-ʿ)", "%1\\MakeUppercase ")
334 str = string.gsub(str, "(%-ʾ)", "%1\\MakeUppercase ")
335 elseif string.find(str, "%-[^'`ʾʿ]") then
336 str = string.gsub(str, "(%-)", "%1\\MakeUppercase ")
337 elseif string.find(str, "^['`ʾʿ]") then
338 str = string.gsub(str, "^(['`])", "%1\\MakeUppercase ")
339 str = string.gsub(str, "^(ʿ)", "%1\\MakeUppercase ")
340 str = string.gsub(str, "^(ʾ)", "%1\\MakeUppercase ")
341 else
342 str = "\\MakeUppercase "..str
343 end
344return str
345end
346
315--print(processvoc("'at_A .sadIquN 'il_A ju.hA ya.tlubu min-hu .himAra-hu li-yarkiba-hu fI safraTiN qa.sIraTiN wa-qAla la-hu sawfa 'u`Idu-hu 'ilay-ka fI 'l-masA'i wa-'adfa`u la-ka 'ujraTaN 'at_A .sadIquN 'il_A ju.hA ya.tlubu min-hu .himAra-hu li-yarkiba-hu fI safraTiN qa.sIraTiN wa-qAla la-hu sawfa 'u`Idu-hu 'ilay-ka fI 'l-masA'i wa-'adfa`u la-ka 'ujraTaN")) 347--print(processvoc("'at_A .sadIquN 'il_A ju.hA ya.tlubu min-hu .himAra-hu li-yarkiba-hu fI safraTiN qa.sIraTiN wa-qAla la-hu sawfa 'u`Idu-hu 'ilay-ka fI 'l-masA'i wa-'adfa`u la-ka 'ujraTaN 'at_A .sadIquN 'il_A ju.hA ya.tlubu min-hu .himAra-hu li-yarkiba-hu fI safraTiN qa.sIraTiN wa-qAla la-hu sawfa 'u`Idu-hu 'ilay-ka fI 'l-masA'i wa-'adfa`u la-ka 'ujraTaN"))
316--print(arbnum("bop 0123456789")) 348--print(arbnum("bop 0123456789"))
317--print(processvoc("daxala \\arb[novoc]{mubtasimaN}")) 349--print(processvoc("daxala \\arb[novoc]{mubtasimaN}"))
diff --git a/arabluatex_trans.lua b/arabluatex_trans.lua
index 8a9aee8..19411f1 100644
--- a/arabluatex_trans.lua
+++ b/arabluatex_trans.lua
@@ -70,14 +70,14 @@ trigraphstrdmg = { -- trigraphs or more
70 {a="^'ll(a)([%_]?[dt])", b="'ll%1%2"}, 70 {a="^'ll(a)([%_]?[dt])", b="'ll%1%2"},
71 {a="(%s)'ll(a)([%_]?[dt])", b="%1'll%2%3"}, 71 {a="(%s)'ll(a)([%_]?[dt])", b="%1'll%2%3"},
72 -- al- + lām 72 -- al- + lām
73 {a="^(a)l%-(l)", b="%1l-%2%2"}, 73 {a="^(a)l%-(l)", b="%1l-%2"},
74 {a="(%s)(a)l%-(l)", b="%1%2l-%3%3"}, 74 {a="(%s)(a)l%-(l)", b="%1%2l-%3"},
75 -- al- + solar consonant 75 -- al- + solar consonant
76 {a="^(a)l%-([%_%^%.]?[tdrzsn])", b="%1%2-%2"}, 76 {a="^(a)l%-([%_%^%.]?[tdrzsn])", b="%1%2-"},
77 {a="(%s)(a)l%-([%_%^%.]?[tdrzsn])", b="%1%2%3-%3"}, 77 {a="(%s)(a)l%-([%_%^%.]?[tdrzsn])", b="%1%2%3-"},
78 -- assim. art. + solar consonant 78 -- assim. art. + solar consonant
79 {a="^(a)([%_%^%.]?[tdrzsn])%-", b="%1%2-%2"}, 79 {a="^(a)([%_%^%.]?[tdrzsn])%-", b="%1%2-"},
80 {a="(%s)(a)([%_%^%.]?[tdrzsn])%-", b="%1%2%3-%3"}, 80 {a="(%s)(a)([%_%^%.]?[tdrzsn])%-", b="%1%2%3-"},
81 -- al- + initial unstable hamza 81 -- al- + initial unstable hamza
82 {a="^(a)l%-([uai])", b="%1l-%2"}, 82 {a="^(a)l%-([uai])", b="%1l-%2"},
83 {a="(%s)(a)l%-([uai])", b="%1%2l-%3"}, 83 {a="(%s)(a)l%-([uai])", b="%1%2l-%3"},
@@ -231,8 +231,8 @@ trigraphstrloc = { -- trigraphs or more
231 {a="^(a)l%-([%_%^%.]?[tdrzsn])", b="%1l-%2"}, 231 {a="^(a)l%-([%_%^%.]?[tdrzsn])", b="%1l-%2"},
232 {a="(%s)(a)l%-([%_%^%.]?[tdrzsn])", b="%1%2l-%3"}, 232 {a="(%s)(a)l%-([%_%^%.]?[tdrzsn])", b="%1%2l-%3"},
233 -- assim. art. + solar consonant 233 -- assim. art. + solar consonant
234 {a="^(a)([%_%^%.]?[tdrzsn])%-", b="%1l-%2"}, 234 {a="^(a)([%_%^%.]?[tdrzsn])%-", b="%1l-"},
235 {a="(%s)(a)([%_%^%.]?[tdrzsn])%-", b="%1%2l-%3"}, 235 {a="(%s)(a)([%_%^%.]?[tdrzsn])%-", b="%1%2l-"},
236 -- al- + initial unstable hamza 236 -- al- + initial unstable hamza
237 {a="^(a)l%-([uai])", b="%1l-%2"}, 237 {a="^(a)l%-([uai])", b="%1l-%2"},
238 {a="(%s)(a)l%-([uai])", b="%1%2l-%3"}, 238 {a="(%s)(a)l%-([uai])", b="%1%2l-%3"},
@@ -339,6 +339,40 @@ finaltrloc = {
339 {a="ʾ", b="'"}, 339 {a="ʾ", b="'"},
340} 340}
341 341
342-- cap
343captr = {
344 -- dmg (defaut); loc as well
345 {a="ā", b="Ā"},
346 {a="b", b="B"},
347 {a="t", b="T"},
348 {a="ṯ", b="Ṯ"},
349 {a="ǧ", b="Ǧ"},
350 {a="ḥ", b="Ḥ"},
351 {a="ḫ", b="Ḫ"},
352 {a="d", b="D"},
353 {a="ḏ", b="Ḏ"},
354 {a="r", b="R"},
355 {a="z", b="Z"},
356 {a="s", b="S"},
357 {a="š", b="Š"},
358 {a="ṣ", b="Ṣ"},
359 {a="ḍ", b="Ḍ"},
360 {a="ṭ", b="Ṭ"},
361 {a="ẓ", b="Ẓ"},
362 {a="ġ", b="Ġ"},
363 {a="f", b="F"},
364 {a="q", b="Q"},
365 {a="k", b="K"},
366 {a="l", b="L"},
367 {a="m", b="M"},
368 {a="n", b="N"},
369 {a="h", b="H"},
370 {a="w", b="W"},
371 {a="ū", b="Ū"},
372 {a="y", b="Y"},
373 {a="ī", b="Ī"}
374}
375
342-- return { 376-- return {
343-- raw = raw, 377-- raw = raw,
344-- hamza = hamza, 378-- hamza = hamza,