aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2019-06-18 08:30:52 +0200
committerRobert Alessi <alessi@robertalessi.net>2019-06-18 08:30:52 +0200
commit67d484712e6f6f2d26894c8858a220dc8de5c3c8 (patch)
tree631a4239c9d0ac4a4d05dbc88228706fc45922bf
parentd2f60b95cedce281a8f2da807a7e9688ce69eae0 (diff)
downloadarabluatex-67d484712e6f6f2d26894c8858a220dc8de5c3c8.tar.gz
new function processarind() for indexing Arabic words
-rw-r--r--arabluatex.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/arabluatex.lua b/arabluatex.lua
index df03156..67e4fc3 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -56,6 +56,7 @@ local aftercmd = lpeg.Cs(lpeg.S("*[{,.?;:'`\"") + dblbkslash)
56local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1) 56local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1)
57local arbargs = lpeg.Cs(spce^-1 * bsqbrackets^-1 * bcbraces) 57local arbargs = lpeg.Cs(spce^-1 * bsqbrackets^-1 * bcbraces)
58local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) 58local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces)
59local arind = lpeg.Cs(dblbkslash * lpeg.P("arind") * spce^-1 * bsqbracketsii)
59 60
60local function protectarb(str) 61local function protectarb(str)
61 str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\al@brk{\\arb%2%3}") 62 str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\al@brk{\\arb%2%3}")
@@ -655,6 +656,20 @@ local function processbuckw(str)
655 return str 656 return str
656end 657end
657 658
659local function processarind(str, mode)
660 str = gsub(str, arind * bcbraces, function(tag, arg)
661 arg = string.sub(arg, 2, -2)
662 if mode == "trans" then
663 return string.format("%s{\\txtrans{%s}}", tag, arg)
664 else
665 arg = novoc(arg)
666 arg = string.gsub(arg, "\\arabicfont%s?{}", "")
667 return string.format("%s{\\txarb{%s}}", tag, arg)
668 end
669 end)
670 return str
671end
672
658-- The following functions produce a copy of the original .tex source 673-- The following functions produce a copy of the original .tex source
659-- file in which all arabtex strings are replaced with Unicode 674-- file in which all arabtex strings are replaced with Unicode
660-- equivalents 675-- equivalents
@@ -892,6 +907,7 @@ function arabluatex.processvoc(str, rules, scheme)
892 str = protectarb(str) 907 str = protectarb(str)
893 str = breakcmd(str) 908 str = breakcmd(str)
894 str = holdcmd(str) 909 str = holdcmd(str)
910 str = processarind(str)
895 if scheme == "buckwalter" then 911 if scheme == "buckwalter" then
896 str = processbuckw(str) 912 str = processbuckw(str)
897 else end 913 else end
@@ -920,6 +936,7 @@ function arabluatex.processfullvoc(str, rules, scheme)
920 str = protectarb(str) 936 str = protectarb(str)
921 str = breakcmd(str) 937 str = breakcmd(str)
922 str = holdcmd(str) 938 str = holdcmd(str)
939 str = processarind(str)
923 if scheme == "buckwalter" then 940 if scheme == "buckwalter" then
924 str = processbuckw(str) 941 str = processbuckw(str)
925 else end 942 else end
@@ -950,6 +967,7 @@ function arabluatex.processnovoc(str, rules, scheme)
950 str = protectarb(str) 967 str = protectarb(str)
951 str = breakcmd(str) 968 str = breakcmd(str)
952 str = holdcmd(str) 969 str = holdcmd(str)
970 str = processarind(str)
953 if scheme == "buckwalter" then 971 if scheme == "buckwalter" then
954 str = processbuckw(str) 972 str = processbuckw(str)
955 else end 973 else end
@@ -979,6 +997,7 @@ function arabluatex.processtrans(str, mode, rules, scheme)
979 str = protectarb(str) 997 str = protectarb(str)
980 str = breakcmd(str) 998 str = breakcmd(str)
981 str = holdcmd(str) 999 str = holdcmd(str)
1000 str = processarind(str, "trans")
982 if scheme == "buckwalter" then 1001 if scheme == "buckwalter" then
983 str = processbuckw(str) 1002 str = processbuckw(str)
984 end 1003 end