diff options
-rw-r--r-- | arabluatex.lua | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/arabluatex.lua b/arabluatex.lua index b578ec5..3bb9211 100644 --- a/arabluatex.lua +++ b/arabluatex.lua | |||
@@ -675,7 +675,7 @@ local function processarbtoutf(str) | |||
675 | str = "\\begin{arabexport}"..str | 675 | str = "\\begin{arabexport}"..str |
676 | str = string.gsub(str, "(\\prname)%s?(%b{})", function(tag, body) | 676 | str = string.gsub(str, "(\\prname)%s?(%b{})", function(tag, body) |
677 | body = string.sub(body, 2, -2) | 677 | body = string.sub(body, 2, -2) |
678 | return string.format("\\arb[trans]{\\uc{%s}}", body) | 678 | return string.format("%s{\\arb[trans]{\\uc{%s}}}", tag, body) |
679 | end) | 679 | end) |
680 | str = string.gsub(str, "(\\begin%s?{arab})(%b[])", function(tag, body) | 680 | str = string.gsub(str, "(\\begin%s?{arab})(%b[])", function(tag, body) |
681 | if string.find(body, "trans") then | 681 | if string.find(body, "trans") then |
@@ -708,12 +708,14 @@ local function processarbtoutf(str) | |||
708 | return string.format("%s\\@al@pr@ob%s\\@al@pr@cb", tag, body) | 708 | return string.format("%s\\@al@pr@ob%s\\@al@pr@cb", tag, body) |
709 | end) | 709 | end) |
710 | str = string.gsub(str, "{", "\\@al@ob") | 710 | str = string.gsub(str, "{", "\\@al@ob") |
711 | str = string.gsub(str, "} ", "\\@al@cb@sp") | ||
711 | str = string.gsub(str, "}", "\\@al@cb") | 712 | str = string.gsub(str, "}", "\\@al@cb") |
712 | str = string.gsub(str, "\\@al@pr@ob", "{") | 713 | str = string.gsub(str, "\\@al@pr@ob", "{") |
713 | str = string.gsub(str, "\\@al@pr@cb", "}") | 714 | str = string.gsub(str, "\\@al@pr@cb", "}") |
714 | str = string.gsub(str, "(%b{})", function(body) | 715 | str = string.gsub(str, "(%b{})", function(body) |
715 | body = string.sub(body, 2, -2) | 716 | body = string.sub(body, 2, -2) |
716 | body = string.gsub(body, "(%s?)(\\@al@ob)", "%1{") | 717 | body = string.gsub(body, "(%s?)(\\@al@ob)", "%1{") |
718 | body = string.gsub(body, "(\\@al@cb@sp)", "} ") | ||
717 | body = string.gsub(body, "(\\@al@cb)(%s?)", "}%2") | 719 | body = string.gsub(body, "(\\@al@cb)(%s?)", "}%2") |
718 | return string.format("{%s}", body) | 720 | return string.format("{%s}", body) |
719 | end) | 721 | end) |
@@ -759,11 +761,16 @@ function al_closestream() | |||
759 | local t = f:read("*a") | 761 | local t = f:read("*a") |
760 | t = string.gsub(t, "\\arabicfont{}", "") | 762 | t = string.gsub(t, "\\arabicfont{}", "") |
761 | t = string.gsub(t, "\\par ", "\n\n") | 763 | t = string.gsub(t, "\\par ", "\n\n") |
762 | t = string.gsub(t, "(%s?)(\\@al@ob%s?)", "{") | 764 | t = string.gsub(t, "(\\@al@ob%s?)", "{") |
763 | t = string.gsub(t, "(\\@al@cb)(%s?)", "}%2") | 765 | t = string.gsub(t, "(\\@al@cb@sp)", "} ") |
766 | t = string.gsub(t, "(\\@al@cb)(%s?)", "}") | ||
764 | t = gsub(t, lpeg.Cs("\\begin") * spcenc^-1 * bcbraces * cmdargs, "\n%1%2%3\n") | 767 | t = gsub(t, lpeg.Cs("\\begin") * spcenc^-1 * bcbraces * cmdargs, "\n%1%2%3\n") |
765 | t = string.gsub(t, "(\\\\)", "%1\n") | 768 | t = string.gsub(t, "(\\\\)(%s?)", "%1\n") |
766 | t = string.gsub(t, "(\\end%s?)(%b{})", "\n%1%2") | 769 | t = string.gsub(t, "(\\\\)(\n)(\\end%s?)(%b{})", "%1%3%4") |
770 | t = string.gsub(t, "(\\item)", "\n%1") | ||
771 | t = string.gsub(t, "\n\n(\\item)", "\n%1") | ||
772 | t = string.gsub(t, "(\\end%s?)(%b{})", "%1%2\n") | ||
773 | t = string.gsub(t, "([^\n]%s-)(\\end)%s?(%b{})", "%1\n%2%3") | ||
767 | t = string.gsub(t, "\n\n\n", "\n\n") | 774 | t = string.gsub(t, "\n\n\n", "\n\n") |
768 | if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") then | 775 | if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") then |
769 | tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{There are still 'arabtex' strings to be converted. Open ]]..tex.jobname..utffilesuffix..".tex"..[[ and compile it one more time}}]]) | 776 | tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{There are still 'arabtex' strings to be converted. Open ]]..tex.jobname..utffilesuffix..".tex"..[[ and compile it one more time}}]]) |