aboutsummaryrefslogtreecommitdiff
path: root/arabluatex.lua
diff options
context:
space:
mode:
Diffstat (limited to 'arabluatex.lua')
-rw-r--r--arabluatex.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/arabluatex.lua b/arabluatex.lua
index 102974a..0f3984b 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -388,24 +388,27 @@ local abjad = {
388{".g"} 388{".g"}
389} 389}
390 390
391-- this function is adapted from an 'obsolete project' of Khaled
392-- Hosny's that dates back to 2010. Thanks to him.
393-- See https://github.com/khaledhosny/lualatex-arabic
391function abjadify(n) 394function abjadify(n)
392 local result = "" 395 local abjadnum = ""
393 if n >= 1000 then 396 if n >= 1000 then
394 for i=1,math.floor(n/1000) do 397 for i=1,math.floor(n/1000) do
395 result = result .. abjad[4][1] 398 abjadnum = abjadnum .. abjad[4][1]
396 end 399 end
397 n = math.fmod(n,1000) 400 n = math.fmod(n,1000)
398 end 401 end
399 if n >= 100 then 402 if n >= 100 then
400 result = result .. abjad[3][math.floor(n/100)] 403 abjadnum = abjadnum .. abjad[3][math.floor(n/100)]
401 n = math.fmod(n, 100) 404 n = math.fmod(n, 100)
402 end 405 end
403 if n >= 10 then 406 if n >= 10 then
404 result = result .. abjad[2][math.floor(n/10)] 407 abjadnum = abjadnum .. abjad[2][math.floor(n/10)]
405 n = math.fmod(n, 10) 408 n = math.fmod(n, 10)
406 end 409 end
407 if n >= 1 then 410 if n >= 1 then
408 result = result .. abjad[1][math.floor(n/1)] 411 abjadnum = abjadnum .. abjad[1][math.floor(n/1)]
409 end 412 end
410 return "\\arb{"..result.."}" 413 return "\\arb{"..abjadnum.."}"
411end 414end