aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2018-07-23 20:17:52 +0200
committerRobert Alessi <alessi@robertalessi.net>2018-07-23 20:17:52 +0200
commit6adbeb0de2abb8d50efb0fbf579531a76ec37b45 (patch)
tree9396c09592afcd13158ba82ac1ca7df73b0cb40d
parent7beb697c73f45e63cbc83b531e11d021cf475116 (diff)
downloadarabluatex-6adbeb0de2abb8d50efb0fbf579531a76ec37b45.tar.gz
arabtex to utf8 texfile: first tests
-rw-r--r--arabluatex.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/arabluatex.lua b/arabluatex.lua
index deb963b..197a40e 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -50,6 +50,8 @@ local bsqbracketsii = lpeg.Cs(bsqbrackets^-2)
50local bcbracesii = lpeg.Cs(bcbraces^-2) 50local bcbracesii = lpeg.Cs(bcbraces^-2)
51local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1) 51local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1)
52local cmdargs = lpeg.Cs(spce * bsqbracketsii * bcbracesii * bsqbrackets^-1) 52local cmdargs = lpeg.Cs(spce * bsqbracketsii * bcbracesii * bsqbrackets^-1)
53local arbargs = lpeg.Cs(spce * bsqbrackets^-1 * bcbraces)
54local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces)
53 55
54local function protectarb(str) 56local function protectarb(str)
55 str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\@arb%2%3") 57 str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\@arb%2%3")
@@ -639,6 +641,24 @@ local function processbuckw(str)
639return str 641return str
640end 642end
641 643
644function processexport(str)
645 str = "\\tooutfile{"..str.."}"
646 str = gsub(str, lpeg.Cs("\\arb") * arbargs, "}%1%2\\tooutfile{")
647 str = gsub(str, lpeg.Cs("\\bayt") * baytargs, "}\\tof{\\bayt}%1%2\\tooutfile{")
648 return str
649end
650
651function tooutfile(str, nl)
652 local f = io.open(tex.jobname.."_out.tex", "a+")
653 if nl == "yes" then
654 f:write(str, "\n\n")
655 else
656 f:write(str)
657 end
658 f:close()
659 return true
660end
661
642function processvoc(str, rules, scheme) 662function processvoc(str, rules, scheme)
643 str = takeoutarb(str) 663 str = takeoutarb(str)
644 str = processarbnull(str, scheme) 664 str = processarbnull(str, scheme)
@@ -655,6 +675,8 @@ function processvoc(str, rules, scheme)
655 str = voc(str, rules) 675 str = voc(str, rules)
656 else end 676 else end
657 str = unprotectarb(str) 677 str = unprotectarb(str)
678 tofile = "{\\textdir TRT"..str.."}"
679 tooutfile(tofile)
658return str 680return str
659end 681end
660 682
@@ -717,6 +739,7 @@ function processtrans(str, mode, rules, scheme)
717 str = transarabica(str) 739 str = transarabica(str)
718 end 740 end
719 str = unprotectarb(str) 741 str = unprotectarb(str)
742 tooutfile(str)
720return str 743return str
721end 744end
722 745