aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arabluatex.lua53
1 files changed, 46 insertions, 7 deletions
diff --git a/arabluatex.lua b/arabluatex.lua
index 20f1ecf..6e40efd 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -88,7 +88,8 @@ local albrkcmds = {
88 "par", 88 "par",
89 "LRmarginpar", 89 "LRmarginpar",
90 "arbmark", 90 "arbmark",
91 "abjad" 91 "abjad",
92 "ayah"
92} 93}
93local brkcmds = {} 94local brkcmds = {}
94 95
@@ -201,11 +202,19 @@ local function processarbnull(str, scheme)
201 return str 202 return str
202end 203end
203 204
204local function takeoutabjad(str) 205local function takeout_abjad_ayah(str)
205 str = string.gsub(str, "(\\abjad.?)(%b{})", function(tag, body) 206 str = string.gsub(str, "(\\abjad.?)(%b{})", function(tag, body)
206 body = string.sub(body, 2, -2) 207 body = string.sub(body, 2, -2)
207 return string.format("%s", body) 208 return string.format("%s", body)
208 end) 209 end)
210 str = string.gsub(str, "(\\ayah.?)(%b{})", function(tag, body)
211 body = string.sub(body, 2, -2)
212 if tonumber(body) ~= nil and str.len(body) < 4 then
213 return string.format("(%s)", body)
214 else
215 return "<??>"
216 end
217 end)
209 return str 218 return str
210end 219end
211 220
@@ -675,15 +684,20 @@ local function processarbtoutf(str)
675 if export_utf ~= "arabverse" then 684 if export_utf ~= "arabverse" then
676 str = "\\begin{arabexport}"..str 685 str = "\\begin{arabexport}"..str
677 else end 686 else end
687 --[[ -- of no use, see above takeout_abjad_ayah()
678 str = string.gsub(str, "(\\txtrans%s?)(%b{})", function(tag, body) 688 str = string.gsub(str, "(\\txtrans%s?)(%b{})", function(tag, body)
679 body = string.sub(body, 2, -2) 689 body = string.sub(body, 2, -2)
680 body = string.gsub(body, "(\\abjad%s?)(%b{})", function(btag, bbody) 690 body = string.gsub(body, "(\\abjad%s?)(%b{})", function(btag, bbody)
681 bbody = string.sub(bbody, 2, -2) 691 bbody = string.sub(bbody, 2, -2)
682 return string.format("%s", bbody) 692 return string.format("%s", bbody)
683 end) 693 end)
694 body = string.gsub(body, "(\\ayah%s?)(%b{})", function(btag, bbody)
695 bbody = string.sub(bbody, 2, -2)
696 return string.format("(%s)", bbody)
697 end)
684 return string.format("%s{%s}", tag, body) 698 return string.format("%s{%s}", tag, body)
685 end) 699 end)
686 700 --]]
687 str = string.gsub(str, "(\\txarb%s?)(%b{})", function(tag, body) 701 str = string.gsub(str, "(\\txarb%s?)(%b{})", function(tag, body)
688 body = string.sub(body, 2, -2) 702 body = string.sub(body, 2, -2)
689 body = string.gsub(body, "(\\abjad%s?)(%b{})", function(btag, bbody) 703 body = string.gsub(body, "(\\abjad%s?)(%b{})", function(btag, bbody)
@@ -699,6 +713,10 @@ local function processarbtoutf(str)
699 bbody = string.sub(bbody, 2, -2) 713 bbody = string.sub(bbody, 2, -2)
700 return string.format("%s[rl]{%s}", btag, bbody) 714 return string.format("%s[rl]{%s}", btag, bbody)
701 end) 715 end)
716 body = string.gsub(body, "(\\ayah%s?)(%b{})", function(btag, bbody)
717 bbody = string.sub(bbody, 2, -2)
718 return string.format("\\arb[novoc]{%s^^^^06dd}", bbody)
719 end)
702 return string.format("%s{%s}", tag, body) 720 return string.format("%s{%s}", tag, body)
703 end) 721 end)
704 str = string.gsub(str, "(\\bayt)%s?(%b{})(%b[])(%b{})", function(tag, argi, argii, argiii) 722 str = string.gsub(str, "(\\bayt)%s?(%b{})(%b[])(%b{})", function(tag, argi, argii, argiii)
@@ -837,11 +855,19 @@ function al_closestream()
837 if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") 855 if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]")
838 or 856 or
839 string.find(t, "\\begin%s?{document}.-\\[Uu]c%s?%b{}") 857 string.find(t, "\\begin%s?{document}.-\\[Uu]c%s?%b{}")
858 or
859 string.find(t, "\\begin%s?{document}.-\\abjad%s?%b{}")
860 or
861 string.find(t, "\\begin%s?{document}.-\\ayah%s?%b{}")
840 then 862 then
841 tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{ 863 -- issue a warning:
842 There are still 'arabtex' strings to be converted. 864 tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{]]
843 Please open ]] .. tex.jobname .. utffilesuffix .. ".tex" .. 865 ..
866 [[There are still 'arabtex' strings to be converted. ]]
867 ..
868 [[Please open ]] .. tex.jobname .. utffilesuffix .. ".tex" ..
844 [[ and compile it one more time}}]]) 869 [[ and compile it one more time}}]])
870 --
845 else end 871 else end
846 t = t.."\n\\end{document}" 872 t = t.."\n\\end{document}"
847 io.write(t) 873 io.write(t)
@@ -943,7 +969,7 @@ function processtrans(str, mode, rules, scheme)
943 str = takeoutarb(str) 969 str = takeoutarb(str)
944 str = processdiscretionary(str) 970 str = processdiscretionary(str)
945 str = processarbnull(str, scheme) 971 str = processarbnull(str, scheme)
946 str = takeoutabjad(str) 972 str = takeout_abjad_ayah(str)
947 str = protectarb(str) 973 str = protectarb(str)
948 str = breakcmd(str) 974 str = breakcmd(str)
949 str = holdcmd(str) 975 str = holdcmd(str)
@@ -1130,3 +1156,16 @@ function aemph(str, opt)
1130 end 1156 end
1131 return str 1157 return str
1132end 1158end
1159
1160function ayah(str)
1161 if tonumber(str) ~= nil and str.len(str) < 4 then
1162 if tex.textdir == "TRT" then
1163 str = "\\arb[novoc]{"..str.."^^^^06dd}"
1164 elseif tex.textdir == "TLT" then
1165 str = "\\arb[trans]{("..str..")}"
1166 end
1167 return str
1168 else
1169 return "\\LR{<??>}"
1170 end
1171end