aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2018-08-23 13:14:38 +0200
committerRobert Alessi <alessi@robertalessi.net>2018-08-23 13:14:38 +0200
commitc799c8d68ac88a340328d9f26e480a1811753e46 (patch)
treeb72c00256520c5c291c136aba6498a11925af16e
parent873360215487c7c7cb45a9324fc25f9d89f0a137 (diff)
downloadarabluatex-c799c8d68ac88a340328d9f26e480a1811753e46.tar.gz
arabtex2utf: \abjad and \arbmark now work
-rw-r--r--arabluatex.lua59
1 files changed, 40 insertions, 19 deletions
diff --git a/arabluatex.lua b/arabluatex.lua
index 23ed8a6..8bb9572 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -675,6 +675,27 @@ local function processarbtoutf(str)
675 if export_utf ~= "arabverse" then 675 if export_utf ~= "arabverse" then
676 str = "\\begin{arabexport}"..str 676 str = "\\begin{arabexport}"..str
677 else end 677 else end
678 str = string.gsub(str, "(\\txtrans%s?)(%b{})", function(tag, body)
679 body = string.sub(body, 2, -2)
680 body = string.gsub(body, "(\\abjad%s?)(%b{})", function(btag, bbody)
681 bbody = string.sub(bbody, 2, -2)
682 return string.format("%s", bbody)
683 end)
684 return string.format("%s{%s}", tag, body)
685 end)
686 str = string.gsub(str, "(\\txarb%s?)(%b{})", function(tag, body)
687 body = string.sub(body, 2, -2)
688 body = string.gsub(body, "(\\abjad%s?)(%b{})", function(btag, bbody)
689 bbody = string.sub(bbody, 2, -2)
690 bbody = abjadify(bbody)
691 return string.format("\\aemph{\\arb[novoc]{%s}}", bbody)
692 end)
693 body = string.gsub(body, "(\\arbmark%s?)(%b{})", function(btag, bbody)
694 bbody = string.sub(bbody, 2, -2)
695 return string.format("%s[rl]{%s}", btag, bbody)
696 end)
697 return string.format("%s{%s}", tag, body)
698 end)
678 str = string.gsub(str, "(\\bayt)%s?(%b{})(%b[])(%b{})", function(tag, argi, argii, argiii) 699 str = string.gsub(str, "(\\bayt)%s?(%b{})(%b[])(%b{})", function(tag, argi, argii, argiii)
679 argi = string.sub(argi, 2, -2) 700 argi = string.sub(argi, 2, -2)
680 argii = string.sub(argii, 2, -2) 701 argii = string.sub(argii, 2, -2)
@@ -703,11 +724,6 @@ local function processarbtoutf(str)
703 end) 724 end)
704 str = string.gsub(str, "(\\begin%s?{arab})", "\\par\\bgroup\\arbpardir\\arb{") 725 str = string.gsub(str, "(\\begin%s?{arab})", "\\par\\bgroup\\arbpardir\\arb{")
705 str = string.gsub(str, "\\end%s?{arab}", "}\\egroup\\par") 726 str = string.gsub(str, "\\end%s?{arab}", "}\\egroup\\par")
706 str = string.gsub(str, "(\\abjad)%s?(%b{})", function(tag, body)
707 body = string.sub(body, 2, -2)
708 body = abjadify(body)
709 return string.format("\\aemph{\\arb[novoc]{%s}}", body)
710 end)
711 -- This does not work, while the following two do. Look into this later. 727 -- This does not work, while the following two do. Look into this later.
712 -- str = gsub(str, lpeg.Cs("\\arb") * spcenc * bsqbrackets^-1 * bcbraces, function(tag, opt, body) 728 -- str = gsub(str, lpeg.Cs("\\arb") * spcenc * bsqbrackets^-1 * bcbraces, function(tag, opt, body)
713 -- body = string.sub(body, 2, -2) 729 -- body = string.sub(body, 2, -2)
@@ -721,6 +737,10 @@ local function processarbtoutf(str)
721 body = string.sub(body, 2, -2) 737 body = string.sub(body, 2, -2)
722 return string.format("%s\\@al@pr@ob%s\\@al@pr@cb", tag, body) 738 return string.format("%s\\@al@pr@ob%s\\@al@pr@cb", tag, body)
723 end) 739 end)
740 str = string.gsub(str, "(\\arbmark)%s?(%b[])(%b{})", function(tag, opt, body)
741 body = string.sub(body, 2, -2)
742 return string.format("%s%s\\@al@pr@ob%s\\@al@pr@cb", tag, opt, body)
743 end)
724 str = string.gsub(str, "(\\arbmark)%s?(%b{})", function(tag, body) 744 str = string.gsub(str, "(\\arbmark)%s?(%b{})", function(tag, body)
725 body = string.sub(body, 2, -2) 745 body = string.sub(body, 2, -2)
726 return string.format("%s\\@al@pr@ob%s\\@al@pr@cb", tag, body) 746 return string.format("%s\\@al@pr@ob%s\\@al@pr@cb", tag, body)
@@ -761,9 +781,9 @@ function arbtoutf(str)
761 return string.format("%s{%s}", tag, body) 781 return string.format("%s{%s}", tag, body)
762 end) 782 end)
763 str = string.gsub(str, "(\\ArbOutFile)%s?(%b{})", function(tag, body) 783 str = string.gsub(str, "(\\ArbOutFile)%s?(%b{})", function(tag, body)
764 body = string.sub(body, 2, -2) 784 body = string.sub(body, 2, -2)
765 body = string.gsub(body, "(\\arbmark)%s?(%b{})", "}%1%2\\ArbOutFile{") 785 body = gsub(body, lpeg.Cs("\\arbmark") * arbargs, "}%1%2\\ArbOutFile{")
766 return string.format("%s{%s}", tag, body) 786 return string.format("%s{%s}", tag, body)
767 end) 787 end)
768 return str 788 return str
769end 789end
@@ -945,11 +965,19 @@ local function isintable(table, element)
945 return false 965 return false
946end 966end
947 967
948function processarbmarks(str) 968function processarbmarks(str, dir)
949 if not isintable(arbmarks, str) then 969 if not isintable(arbmarks, str) then
950 str = "\\LR{<??>}"..atletter.."\\al@wrong@mark{}"..atother 970 str = "\\LR{<??>}"..atletter.."\\al@wrong@mark{}"..atother
951 else 971 else
952 if tex.textdir == "TLT" then 972 if dir == "lr" then
973 for i = 1,#arbmarks do
974 str = string.gsub(str, arbmarks[i].a, arbmarks[i].c)
975 end
976 elseif dir == "rl" then
977 for i = 1,#arbmarks do
978 str = string.gsub(str, arbmarks[i].a, arbmarks[i].b)
979 end
980 elseif tex.textdir == "TLT" then
953 for i = 1,#arbmarks do 981 for i = 1,#arbmarks do
954 str = string.gsub(str, arbmarks[i].a, arbmarks[i].c) 982 str = string.gsub(str, arbmarks[i].a, arbmarks[i].c)
955 end 983 end
@@ -963,7 +991,7 @@ function processarbmarks(str)
963 tofile = str 991 tofile = str
964 tooutfile(tofile) 992 tooutfile(tofile)
965 elseif export_utf == "arabverse" then 993 elseif export_utf == "arabverse" then
966 tofile = "\\txarb{"..str.."}" 994 tofile = str
967 tooutfile(tofile) 995 tooutfile(tofile)
968 else 996 else
969 return str 997 return str
@@ -1057,14 +1085,7 @@ function abjadify(n)
1057 if n >= 1 then 1085 if n >= 1 then
1058 abjadnum = abjadnum .. abjad[1][math.floor(n/1)] 1086 abjadnum = abjadnum .. abjad[1][math.floor(n/1)]
1059 end 1087 end
1060 if export_utf == "yes" then 1088 return "\\arb[novoc]{"..abjadnum.."}"
1061 return abjadnum
1062 elseif export_utf == "arabverse" then
1063 return abjadnum
1064 else
1065 return "\\arb[novoc]{"..abjadnum.."}"
1066 end
1067 return ""
1068end 1089end
1069 1090
1070function abraces(str) 1091function abraces(str)