diff options
author | Robert Alessi <alessi@robertalessi.net> | 2018-07-23 20:17:52 +0200 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2018-07-23 20:17:52 +0200 |
commit | 6adbeb0de2abb8d50efb0fbf579531a76ec37b45 (patch) | |
tree | 9396c09592afcd13158ba82ac1ca7df73b0cb40d | |
parent | 7beb697c73f45e63cbc83b531e11d021cf475116 (diff) | |
download | arabluatex-6adbeb0de2abb8d50efb0fbf579531a76ec37b45.tar.gz |
arabtex to utf8 texfile: first tests
-rw-r--r-- | arabluatex.lua | 23 |
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) | |||
50 | local bcbracesii = lpeg.Cs(bcbraces^-2) | 50 | local bcbracesii = lpeg.Cs(bcbraces^-2) |
51 | local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1) | 51 | local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1) |
52 | local cmdargs = lpeg.Cs(spce * bsqbracketsii * bcbracesii * bsqbrackets^-1) | 52 | local cmdargs = lpeg.Cs(spce * bsqbracketsii * bcbracesii * bsqbrackets^-1) |
53 | local arbargs = lpeg.Cs(spce * bsqbrackets^-1 * bcbraces) | ||
54 | local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) | ||
53 | 55 | ||
54 | local function protectarb(str) | 56 | local 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) | |||
639 | return str | 641 | return str |
640 | end | 642 | end |
641 | 643 | ||
644 | function 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 | ||
649 | end | ||
650 | |||
651 | function 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 | ||
660 | end | ||
661 | |||
642 | function processvoc(str, rules, scheme) | 662 | function 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) | ||
658 | return str | 680 | return str |
659 | end | 681 | end |
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) | ||
720 | return str | 743 | return str |
721 | end | 744 | end |
722 | 745 | ||