aboutsummaryrefslogtreecommitdiff
path: root/arabluatex.lua
diff options
context:
space:
mode:
Diffstat (limited to 'arabluatex.lua')
-rw-r--r--arabluatex.lua42
1 files changed, 40 insertions, 2 deletions
diff --git a/arabluatex.lua b/arabluatex.lua
index f6597e8..102974a 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -72,11 +72,11 @@ local function breakcmd(str)
72 body = string.sub(body, 2, -2) 72 body = string.sub(body, 2, -2)
73 return string.format("}\\%s{%s}\\arb{", tag, body) 73 return string.format("}\\%s{%s}\\arb{", tag, body)
74 end) 74 end)
75 -- Abjad (Needs polyglossia) 75 -- Abjad
76 str = string.gsub(str, "\\(abjad.-)(%b{})", 76 str = string.gsub(str, "\\(abjad.-)(%b{})",
77 function(tag, body) 77 function(tag, body)
78 body = string.sub(body, 2, -2) 78 body = string.sub(body, 2, -2)
79 return string.format("}\\aemph{\\txarb{\\%s{%s}}}\\arb{", tag, body) 79 return string.format("}\\aemph{\\%s{%s}}\\arb{", tag, body)
80 end) 80 end)
81 return str 81 return str
82end 82end
@@ -115,6 +115,14 @@ local function indnum(str)
115 return str 115 return str
116end 116end
117 117
118local function takeoutabjad(str)
119 str = string.gsub(str, "(\\abjad.?)(%b{})", function(tag, body)
120 body = string.sub(body, 2, -2)
121 return string.format("%s", body)
122 end)
123 return str
124end
125
118local function takeoutcap(str) 126local function takeoutcap(str)
119 str = string.gsub(str, "(\\cap.?)(%b{})", function(tag, body) 127 str = string.gsub(str, "(\\cap.?)(%b{})", function(tag, body)
120 body = string.sub(body, 2, -2) 128 body = string.sub(body, 2, -2)
@@ -339,6 +347,7 @@ end
339 347
340function processtrans(str, mode) 348function processtrans(str, mode)
341 str = "\\arb{".. str.."}" 349 str = "\\arb{".. str.."}"
350 str = takeoutabjad(str)
342 str = protectarb(str) 351 str = protectarb(str)
343 str = breakcmd(str) 352 str = breakcmd(str)
344 str = holdcmd(str) 353 str = holdcmd(str)
@@ -371,3 +380,32 @@ function cap(str)
371 end 380 end
372return str 381return str
373end 382end
383
384local abjad = {
385{"a\"'", "b", "j", "d", "h", "w", "z", ".h", ".t"},
386{"y", "k", "l", "m", "n", "s", "`", "f", ".s", },
387{"q", "r", "^s", "t", "_t", "x", "_d", ".d", ".z", },
388{".g"}
389}
390
391function abjadify(n)
392 local result = ""
393 if n >= 1000 then
394 for i=1,math.floor(n/1000) do
395 result = result .. abjad[4][1]
396 end
397 n = math.fmod(n,1000)
398 end
399 if n >= 100 then
400 result = result .. abjad[3][math.floor(n/100)]
401 n = math.fmod(n, 100)
402 end
403 if n >= 10 then
404 result = result .. abjad[2][math.floor(n/10)]
405 n = math.fmod(n, 10)
406 end
407 if n >= 1 then
408 result = result .. abjad[1][math.floor(n/1)]
409 end
410 return "\\arb{"..result.."}"
411end