diff options
-rw-r--r-- | arabluatex.dtx | 247 | ||||
-rw-r--r-- | arabluatex.ins | 74 | ||||
-rw-r--r-- | arabluatex.lua | 195 | ||||
-rw-r--r-- | arabluatex_novoc.lua | 55 | ||||
-rw-r--r-- | arabluatex_voc.lua | 257 | ||||
-rw-r--r-- | makefile | 32 |
6 files changed, 860 insertions, 0 deletions
diff --git a/arabluatex.dtx b/arabluatex.dtx new file mode 100644 index 0000000..96261bc --- /dev/null +++ b/arabluatex.dtx | |||
@@ -0,0 +1,247 @@ | |||
1 | % \iffalse meta-comment | ||
2 | % copyright (C) 2016 Robert Alessi | ||
3 | % | ||
4 | % Please send error reports and suggestions for improvements to | ||
5 | % Robert Alessi <alessi@robertalessi.net> | ||
6 | % | ||
7 | % This program is free software; you can redistribute it and/or | ||
8 | % modify it under the terms of the GNU General Public License | ||
9 | % as published by the Free Software Foundation; either version 2 | ||
10 | % of the License, or (at your option) any later version. | ||
11 | % | ||
12 | % This program is distributed in the hope that it will be useful, | ||
13 | % but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | % GNU General Public License for more details. | ||
16 | % | ||
17 | % You should have received a copy of the GNU General Public License | ||
18 | % along with this program; if not, write to the Free Software | ||
19 | % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
20 | % 02111-1307, USA. | ||
21 | % \fi | ||
22 | % | ||
23 | % \iffalse | ||
24 | %<*driver> | ||
25 | \ProvidesFile{arabluatex.dtx} | ||
26 | %</driver> | ||
27 | %<package-info>\NeedsTeXFormat{LaTeX2e}[1999/12/01] | ||
28 | %<package-info>\ProvidesPackage{arabluatex} | ||
29 | %<*package-info> | ||
30 | [2016/01/26 v1.0 This is ArabTeX for LuaLaTeX] | ||
31 | %</package-info> | ||
32 | % | ||
33 | %<*driver> | ||
34 | \documentclass{ltxdoc} | ||
35 | \usepackage[english]{babel} | ||
36 | \usepackage{fontspec,luatextra,realscripts} | ||
37 | \defaultfontfeatures{RawFeature={+liga}} | ||
38 | \setmainfont{Libertinus Serif} | ||
39 | \setsansfont{Libertinus Sans} | ||
40 | \setmonofont[Scale=.9]{Libertinus Mono} | ||
41 | \usepackage{arabluatex}[2016/01/26] | ||
42 | \usepackage{hypdoc} | ||
43 | \hypersetup{colorlinks, allcolors=blue} | ||
44 | \usepackage{multicol} | ||
45 | \newcommand{\package}[1]{\textsf{#1}} | ||
46 | \usepackage{paralist} | ||
47 | \setdefaultitem{\textendash}{\textendash}{\textendash}{\textendash} | ||
48 | \usepackage{tikz} | ||
49 | \usepackage[skins]{tcolorbox} | ||
50 | \usepackage{csquotes} | ||
51 | \EnableCrossrefs | ||
52 | \CodelineIndex | ||
53 | \RecordChanges | ||
54 | \begin{document} | ||
55 | \DocInput{arabluatex.dtx} | ||
56 | \PrintChanges | ||
57 | \PrintIndex | ||
58 | \end{document} | ||
59 | %</driver> | ||
60 | % \fi | ||
61 | % | ||
62 | % \CheckSum{0} | ||
63 | % | ||
64 | % \CharacterTable | ||
65 | % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z | ||
66 | % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z | ||
67 | % Digits \0\1\2\3\4\5\6\7\8\9 | ||
68 | % Exclamation \! Double quote \" Hash (number) \# | ||
69 | % Dollar \$ Percent \% Ampersand \& | ||
70 | % Acute accent \' Left paren \( Right paren \) | ||
71 | % Asterisk \* Plus \+ Comma \, | ||
72 | % Minus \- Point \. Solidus \/ | ||
73 | % Colon \: Semicolon \; Less than \< | ||
74 | % Equals \= Greater than \> Question mark \? | ||
75 | % Commercial at \@ Left bracket \[ Backslash \\ | ||
76 | % Right bracket \] Circumflex \^ Underscore \_ | ||
77 | % Grave accent \` Left brace \{ Vertical bar \| | ||
78 | % Right brace \} Tilde \~} | ||
79 | % | ||
80 | % | ||
81 | % \changes{1.0}{2016/01/26}{Converted to DTX file} | ||
82 | % | ||
83 | % \DoNotIndex{\newcommand,\newenvironment,\renewcommand} | ||
84 | % | ||
85 | % \providecommand*{\url}{\texttt} | ||
86 | % \GetFileInfo{arabluatex.dtx} | ||
87 | % | ||
88 | % \title{\tcbox[enhanced, tikznode, drop lifted shadow, colback=white, | ||
89 | % boxrule=.25mm]% | ||
90 | % {The \textsf{arabluatex} package\\ | ||
91 | % \fileversion~from \filedate}} | ||
92 | % | ||
93 | % \newcommand*{\NEWfeature}[1]{% | ||
94 | % \hskip 1sp \marginpar{\small\sffamily\raggedright | ||
95 | % New feature\\#1}} | ||
96 | % | ||
97 | % \author{Robert Alessi \\ \url{alessi@robertalessi.net}} | ||
98 | % \date{} | ||
99 | % | ||
100 | % \maketitle | ||
101 | % | ||
102 | % \begin{multicols}{2} | ||
103 | % \footnotesize | ||
104 | % \tableofcontents | ||
105 | % \end{multicols} | ||
106 | % | ||
107 | % \begin{abstract} | ||
108 | % This package provides for \LuaLaTeX\ an Arab{\TeX}-like interface | ||
109 | % to generate Arabic writing from an \textsc{ascii} | ||
110 | % transliteration. It is particularly well-suited for complex | ||
111 | % documents such as technical documents or critical editions where a | ||
112 | % lot of left-to-right commands intertwine with Arabic | ||
113 | % writing. \package{arabluatex} is able to process any Arab\TeX\ | ||
114 | % input notation. Its output can be set in the same modes of | ||
115 | % vocalization as Arab\TeX\ ones, or in different roman | ||
116 | % transliterations. It further allows some typographical | ||
117 | % refinements. | ||
118 | % \end{abstract} | ||
119 | % | ||
120 | % \section*{License and disclamer} | ||
121 | % \addcontentsline{toc}{section}{License and disclamer} | ||
122 | % Please send error reports and suggestions for improvements to | ||
123 | % Robert Alessi <\url{alessi@robertalessi.net}> | ||
124 | % | ||
125 | % This program is free software; you can redistribute it and/or | ||
126 | % modify it under the terms of the GNU General Public License | ||
127 | % as published by the Free Software Foundation; either version 2 | ||
128 | % of the License, or (at your option) any later version. | ||
129 | % | ||
130 | % This program is distributed in the hope that it will be useful, | ||
131 | % but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
132 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
133 | % GNU General Public License for more details. | ||
134 | % | ||
135 | % You should have received a copy of the GNU General Public License | ||
136 | % along with this program; if not, write to the Free Software | ||
137 | % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
138 | % 02111-1307, USA. | ||
139 | % | ||
140 | % \section{Introduction} | ||
141 | % In comparison to Prof. Lagally's outstanding Arab\TeX,\footnote{See | ||
142 | % \url{http://ctan.org/pkg/arabtex}} Arab\LuaTeX\ is at present | ||
143 | % nothing more than a modest piece of software. Hopefully---if I may | ||
144 | % say so---it will eventually provide all of its valuable qualities to | ||
145 | % the \LuaLaTeX\ users. | ||
146 | % | ||
147 | % \section{Usage} | ||
148 | % | ||
149 | % Usage goes here. | ||
150 | % | ||
151 | % \StopEventually{} | ||
152 | % | ||
153 | % \section{Implementation} | ||
154 | % | ||
155 | % \iffalse | ||
156 | %<*package> | ||
157 | % \fi | ||
158 | % | ||
159 | % \begin{macrocode} | ||
160 | \NeedsTeXFormat{LaTeX2e} | ||
161 | \ProvidesPackage{arabluatex}% | ||
162 | [2016/01/26 v1.0 ArabTeX-like interface for LuaLaTeX] | ||
163 | \RequirePackage{ifluatex} | ||
164 | % \end{macrocode} | ||
165 | % \package{arabluatex} requires \LuaLaTeX\ of course. | ||
166 | % \begin{macrocode} | ||
167 | \ifluatex\else | ||
168 | \PackageError{arabluatex}{lualatex needed}{% | ||
169 | Package `arabluatex' needs LuaTeX.\MessageBreak | ||
170 | So you should use `lualatex' to process you document!\MessageBreak | ||
171 | See documentation of `arabluatex' for further information.}% | ||
172 | \expandafter\expandafter\expandafter\csname endinput\endcsname | ||
173 | \fi | ||
174 | % \end{macrocode} | ||
175 | % \begin{macrocode} | ||
176 | \DeclareOption{voc}{\def\al@mode{voc}} | ||
177 | \DeclareOption{novoc}{\def\al@mode{novoc}} | ||
178 | \ExecuteOptions{voc} | ||
179 | \ProcessOptions\relax | ||
180 | \def\al@mode@voc{voc} | ||
181 | \def\al@mode@novoc{novoc} | ||
182 | % \newif\ifal@mode@defined | ||
183 | \RequirePackage{amsmath} | ||
184 | \RequirePackage{etoolbox} | ||
185 | \RequirePackage{luacode} | ||
186 | \RequirePackage{xparse} | ||
187 | \RequirePackage{environ} | ||
188 | \luadirect{dofile(kpse.find_file("arabluatex.lua"))} | ||
189 | % \end{macrocode} | ||
190 | % This is needed by the current version of \package{luabidi}. | ||
191 | % \begin{macrocode} | ||
192 | \luadirect{tex.enableprimitives("luatex",tex.extraprimitives("omega"))} | ||
193 | % \end{macrocode} | ||
194 | % \package{luabidi} provides a \cs{Footnote} command. Use it for now. | ||
195 | % \begin{macrocode} | ||
196 | \RequirePackage{luabidi} | ||
197 | % \end{macrocode} | ||
198 | % \begin{macrocode} | ||
199 | \AtBeginDocument{\ifdefined\arabicfont\relax\else | ||
200 | \PackageWarning{arabluatex}{\string\arabicfont\ is not defined!^^JI | ||
201 | will try to load Amiri}% | ||
202 | \newfontfamily\arabicfont[Script=Arabic]{Amiri}\fi}% | ||
203 | \DeclareDocumentCommand{\LR}{+m}{\bgroup\textdir TLT\rmfamily#1\egroup} | ||
204 | \DeclareDocumentCommand{\txarb}{+m}{\bgroup\textdir TRT\arabicfont#1\egroup} | ||
205 | \DeclareDocumentCommand{\arb}{O{\al@mode} +m}% | ||
206 | {\edef\@tempa{#1}% | ||
207 | \ifx\@tempa\al@mode@voc% | ||
208 | \bgroup\textdir TRT\arabicfont% | ||
209 | \luadirect{tex.sprint(processvoc("\luaescapestring{#2}"))}\egroup% | ||
210 | \else% | ||
211 | \ifx\@tempa\al@mode@novoc% | ||
212 | \bgroup\textdir TRT\arabicfont% | ||
213 | \luadirect{tex.sprint(processnovoc("\luaescapestring{#2}"))}\egroup% | ||
214 | \else% | ||
215 | \fi\fi} | ||
216 | \DeclareDocumentCommand{\aemph}{m}{$\overline{\text{#1}}$} | ||
217 | \NewEnviron{arab}[1][\al@mode]% | ||
218 | {\par\edef\@tempa{#1}% | ||
219 | \ifx\@tempa\al@mode@voc% | ||
220 | \bgroup\pardir TRT\textdir TRT\arabicfont% | ||
221 | \luadirect{tex.sprint(processvoc("\luaescapestring{\BODY}"))}\egroup% | ||
222 | \else% | ||
223 | \ifx\@tempa\al@mode@novoc% | ||
224 | \bgroup\pardir TRT\textdir TRT\arabicfont% | ||
225 | \luadirect{tex.sprint(processnovoc("\luaescapestring{\BODY}"))}\egroup% | ||
226 | \else | ||
227 | \BODY% | ||
228 | \fi\fi}[\par] | ||
229 | \robustify{\textbf} | ||
230 | \robustify{\emph} | ||
231 | \robustify{\footnote} | ||
232 | \robustify{\marginpar} | ||
233 | \DeclareDocumentCommand{\Marginpar}{m}{\marginpar{\textdir TLT #1}} | ||
234 | \RenewDocumentCommand{\thefootnote}{}{\bgroup\textdir | ||
235 | TLT\arabic{footnote}\egroup} | ||
236 | \AtBeginDocument{\ifdef{\abjad}{\robustify{\abjad}}{}} | ||
237 | \AtBeginDocument{\ifdef{\Footnote}{\robustify{\Footnote}}{}} | ||
238 | \endinput | ||
239 | % \end{macrocode} | ||
240 | |||
241 | % | ||
242 | % \iffalse | ||
243 | %</package> | ||
244 | % \fi | ||
245 | % | ||
246 | % \Finale | ||
247 | \endinput | ||
diff --git a/arabluatex.ins b/arabluatex.ins new file mode 100644 index 0000000..20337ad --- /dev/null +++ b/arabluatex.ins | |||
@@ -0,0 +1,74 @@ | |||
1 | %% copyright (C) 2016 Robert Alessi | ||
2 | %% | ||
3 | %% Please send error reports and suggestions for improvements to | ||
4 | %% Robert Alessi <alessi@robertalessi.net> | ||
5 | %% | ||
6 | %% This program is free software; you can redistribute it and/or | ||
7 | %% modify it under the terms of the GNU General Public License | ||
8 | %% as published by the Free Software Foundation; either version 2 | ||
9 | %% of the License, or (at your option) any later version. | ||
10 | %% | ||
11 | %% This program is distributed in the hope that it will be useful, | ||
12 | %% but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | %% GNU General Public License for more details. | ||
15 | %% | ||
16 | %% You should have received a copy of the GNU General Public License | ||
17 | %% along with this program; if not, write to the Free Software | ||
18 | %% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | %% | ||
20 | |||
21 | \input docstrip.tex | ||
22 | \keepsilent | ||
23 | |||
24 | \usedir{tex/lualatex/arabluatex} | ||
25 | |||
26 | \preamble | ||
27 | |||
28 | This is a generated file. | ||
29 | |||
30 | copyright (C) 2016 Robert Alessi | ||
31 | |||
32 | Please send error reports and suggestions for improvements to | ||
33 | Robert Alessi <alessi@robertalessi.net> | ||
34 | |||
35 | This program is free software; you can redistribute it and/or | ||
36 | modify it under the terms of the GNU General Public License | ||
37 | as published by the Free Software Foundation; either version 2 | ||
38 | of the License, or (at your option) any later version. | ||
39 | |||
40 | This program is distributed in the hope that it will be useful, | ||
41 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
42 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
43 | GNU General Public License for more details. | ||
44 | |||
45 | You should have received a copy of the GNU General Public License | ||
46 | along with this program; if not, write to the Free Software | ||
47 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | ||
48 | USA. | ||
49 | |||
50 | \endpreamble | ||
51 | |||
52 | \generate{\file{arabluatex.sty}{\from{arabluatex.dtx}{package}}} | ||
53 | |||
54 | \Msg{***********************************************************} | ||
55 | \Msg{*} | ||
56 | \Msg{* To finish the installation you have to move the following} | ||
57 | \Msg{* file(s) into a directory searched by LaTeX. See the FAQ on} | ||
58 | \Msg{* CTAN at /help/uk-tex-faq for more on this.} | ||
59 | \Msg{*} | ||
60 | \Msg{* \space\space arabluatex.sty} | ||
61 | \Msg{* \space\space arabluatex.lua} | ||
62 | \Msg{*} | ||
63 | \Msg{* To produce the documentation run the files ending with} | ||
64 | \Msg{* `.dtx' through LuaLaTeX.} | ||
65 | \Msg{*} | ||
66 | \Msg{* For an index, do:} | ||
67 | \Msg{* \space makeindex -s gind.ist -o arabluatex.ind arabluatex.idx} | ||
68 | \Msg{* For a list of changes, do:} | ||
69 | \Msg{* \space makeindex -s gglo.ist -o arabluatex.gls arabluatex.glo} | ||
70 | \Msg{*} | ||
71 | \Msg{* Happy TeXing!} | ||
72 | \Msg{***********************************************************} | ||
73 | |||
74 | \endbatchfile | ||
diff --git a/arabluatex.lua b/arabluatex.lua new file mode 100644 index 0000000..087ee82 --- /dev/null +++ b/arabluatex.lua | |||
@@ -0,0 +1,195 @@ | |||
1 | --[[ | ||
2 | This file is part of the `arabluatex' package | ||
3 | |||
4 | copyright (C) 2016 Robert Alessi | ||
5 | |||
6 | Please send error reports and suggestions for improvements to | ||
7 | Robert Alessi <alessi@robertalessi.net> | ||
8 | |||
9 | This program is free software; you can redistribute it and/or | ||
10 | modify it under the terms of the GNU General Public License | ||
11 | as published by the Free Software Foundation; either version 2 | ||
12 | of the License, or (at your option) any later version. | ||
13 | |||
14 | This program is distributed in the hope that it will be useful, | ||
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | GNU General Public License for more details. | ||
18 | |||
19 | You should have received a copy of the GNU General Public License | ||
20 | along with this program; if not, write to the Free Software | ||
21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
22 | 02111-1307, USA. | ||
23 | --]] | ||
24 | |||
25 | require("arabluatex_voc") | ||
26 | require("arabluatex_novoc") | ||
27 | |||
28 | local function protectarb(str) | ||
29 | str = string.gsub(str, "(\\arb.?)(%[.-%])(%b{})", "\\@arb%2%3") | ||
30 | str = string.gsub(str, "\\par", "\\p@r{}") | ||
31 | str = string.gsub(str, "\\@@par", "\\p@r{}") | ||
32 | return str | ||
33 | end | ||
34 | |||
35 | local function unprotectarb(str) | ||
36 | str = string.gsub(str, "(\\@arb)(%[.-%])(%b{})", "\\arb%2%3") | ||
37 | str = string.gsub(str, "\\p@r{}", "\\par") | ||
38 | return str | ||
39 | end | ||
40 | |||
41 | local function breakcmd(str) | ||
42 | -- \LR | ||
43 | str = string.gsub(str, "\\(LR.-)(%b{})", | ||
44 | function(tag, body) | ||
45 | body = string.sub(body, 2, -2) | ||
46 | return string.format("}\\%s{%s}\\arb{", tag, body) | ||
47 | end) | ||
48 | -- Footnote | ||
49 | str = string.gsub(str, "\\(Footnote.-)(%b{})", | ||
50 | function(tag, body) | ||
51 | body = string.sub(body, 2, -2) | ||
52 | return string.format("}\\%s{%s}\\arb{", tag, body) | ||
53 | end) | ||
54 | -- Marginpar | ||
55 | str = string.gsub(str, "\\(Marginpar.-)(%b{})", | ||
56 | function(tag, body) | ||
57 | body = string.sub(body, 2, -2) | ||
58 | return string.format("}\\%s{%s}\\arb{", tag, body) | ||
59 | end) | ||
60 | -- Abjad (Needs polyglossia) | ||
61 | str = string.gsub(str, "\\(abjad.-)(%b{})", | ||
62 | function(tag, body) | ||
63 | body = string.sub(body, 2, -2) | ||
64 | return string.format("}\\aemph{\\txarb{\\%s{%s}}}\\arb{", tag, body) | ||
65 | end) | ||
66 | return str | ||
67 | end | ||
68 | |||
69 | local function holdcmd(str) | ||
70 | str = string.gsub(str, "\\(arb)(%b{})", function(tag, body) | ||
71 | body = string.sub(body, 2, -2) | ||
72 | body = string.gsub(body, "\\(.-)(%b{})", function(btag, bbody) | ||
73 | bbody = string.sub(bbody, 2, -2) | ||
74 | if string.find(btag, "@") then | ||
75 | return holdcmd(string.format("}\\%s{%s}\\arb{", btag, bbody)) | ||
76 | else | ||
77 | return holdcmd(string.format("}\\%s{\\arb{%s}}\\arb{", btag, bbody)) | ||
78 | end | ||
79 | end) | ||
80 | return string.format("\\%s{%s}", tag, body) | ||
81 | end) | ||
82 | str = string.gsub(str, "\\arb{}", "") | ||
83 | return str | ||
84 | end | ||
85 | |||
86 | local function arbnum(str) | ||
87 | str = string.gsub(str, "([0-9%,%-%/]+)", function(num) | ||
88 | return string.reverse(num) | ||
89 | end) | ||
90 | return str | ||
91 | end | ||
92 | |||
93 | local function indnum(str) | ||
94 | str = string.gsub(str, "([0-9%,%-%/]+)", function(num) | ||
95 | return string.reverse(num) | ||
96 | end) | ||
97 | for i = 1,#numbers do | ||
98 | str = string.gsub(str, numbers[i].a, numbers[i].b) | ||
99 | end | ||
100 | return str | ||
101 | end | ||
102 | |||
103 | local function voc(str) | ||
104 | str = string.gsub(str, "\\arb(%b{})", function(inside) | ||
105 | inside = string.sub(inside, 2, -2) | ||
106 | for i = 1,#hamza do | ||
107 | inside = string.gsub(inside, hamza[i].a, hamza[i].b) | ||
108 | end | ||
109 | for i = 1,#tanwin do | ||
110 | inside = string.gsub(inside, tanwin[i].a, tanwin[i].b) | ||
111 | end | ||
112 | for i = 1,#trigraphs do | ||
113 | inside = string.gsub(inside, trigraphs[i].a, trigraphs[i].b) | ||
114 | end | ||
115 | for i = 1,#digraphs do | ||
116 | inside = string.gsub(inside, digraphs[i].a, digraphs[i].b) | ||
117 | end | ||
118 | for i = 1,#single do | ||
119 | inside = string.gsub(inside, single[i].a, single[i].b) | ||
120 | end | ||
121 | for i = 1,#longv do | ||
122 | inside = string.gsub(inside, longv[i].a, longv[i].b) | ||
123 | end | ||
124 | for i = 1,#shortv do | ||
125 | inside = string.gsub(inside, shortv[i].a, shortv[i].b) | ||
126 | end | ||
127 | for i = 1,#null do | ||
128 | inside = string.gsub(inside, null[i].a, null[i].b) | ||
129 | end | ||
130 | inside = indnum(inside) | ||
131 | return string.format("\\txarb{%s}", inside) | ||
132 | end) | ||
133 | return str | ||
134 | end | ||
135 | |||
136 | local function novoc(str) | ||
137 | str = string.gsub(str, "\\arb(%b{})", function(inside) | ||
138 | inside = string.sub(inside, 2, -2) | ||
139 | for i = 1,#hamza do | ||
140 | inside = string.gsub(inside, hamza[i].a, hamza[i].b) | ||
141 | end | ||
142 | for i = 1,#tanwinnovoc do | ||
143 | inside = string.gsub(inside, tanwinnovoc[i].a, tanwinnovoc[i].b) | ||
144 | end | ||
145 | for i = 1,#trigraphs do | ||
146 | inside = string.gsub(inside, trigraphs[i].a, trigraphs[i].b) | ||
147 | end | ||
148 | for i = 1,#digraphs do | ||
149 | inside = string.gsub(inside, digraphs[i].a, digraphs[i].b) | ||
150 | end | ||
151 | for i = 1,#single do | ||
152 | inside = string.gsub(inside, single[i].a, single[i].b) | ||
153 | end | ||
154 | for i = 1,#longvnovoc do | ||
155 | inside = string.gsub(inside, longvnovoc[i].a, longvnovoc[i].b) | ||
156 | end | ||
157 | for i = 1,#shortvnovoc do | ||
158 | inside = string.gsub(inside, shortvnovoc[i].a, shortvnovoc[i].b) | ||
159 | end | ||
160 | for i = 1,#null do | ||
161 | inside = string.gsub(inside, null[i].a, null[i].b) | ||
162 | end | ||
163 | inside = indnum(inside) | ||
164 | return string.format("\\txarb{%s}", inside) | ||
165 | end) | ||
166 | return str | ||
167 | end | ||
168 | |||
169 | function processvoc(str) | ||
170 | str = "\\arb{".. str.."}" | ||
171 | str = protectarb(str) | ||
172 | str = breakcmd(str) | ||
173 | str = holdcmd(str) | ||
174 | str = voc(str) | ||
175 | str = unprotectarb(str) | ||
176 | return str | ||
177 | end | ||
178 | |||
179 | function processnovoc(str) | ||
180 | str = "\\arb{".. str.."}" | ||
181 | str = protectarb(str) | ||
182 | str = breakcmd(str) | ||
183 | str = holdcmd(str) | ||
184 | str = novoc(str) | ||
185 | str = unprotectarb(str) | ||
186 | return str | ||
187 | end | ||
188 | |||
189 | --print(processvoc("'at_A .sadIquN 'il_A ju.hA ya.tlubu min-hu .himAra-hu li-yarkiba-hu fI safraTiN qa.sIraTiN wa-qAla la-hu sawfa 'u`Idu-hu 'ilay-ka fI 'l-masA'i wa-'adfa`u la-ka 'ujraTaN 'at_A .sadIquN 'il_A ju.hA ya.tlubu min-hu .himAra-hu li-yarkiba-hu fI safraTiN qa.sIraTiN wa-qAla la-hu sawfa 'u`Idu-hu 'ilay-ka fI 'l-masA'i wa-'adfa`u la-ka 'ujraTaN")) | ||
190 | --print(arbnum("bop 0123456789")) | ||
191 | --print(processvoc("daxala \\arb[novoc]{mubtasimaN}")) | ||
192 | --print(processvoc("\\emph{daxala} \\arb[novoc]{mufakkiruN}\\Footnote{\\arb{kataba \\arb[novoc]{mubtasimaN}} Je pense que c'est bien \\arb{kataba}} faqa.t")) | ||
193 | --print(processvoc("daxala \\abjad{45} mubtasimaN")) | ||
194 | --print(process("daxala\\Footnote{Et là c'est toujours \\arb{mubtasimaN}?")) | ||
195 | --print(process("\\emph{daxala}\\Footnote{texte arabe: \\arb{\\emph{kataba}}} \\textbf{\\emph{mubtasimaN}} faqa.t")) | ||
diff --git a/arabluatex_novoc.lua b/arabluatex_novoc.lua new file mode 100644 index 0000000..b62c1cc --- /dev/null +++ b/arabluatex_novoc.lua | |||
@@ -0,0 +1,55 @@ | |||
1 | --[[ | ||
2 | This file is part of the `arabluatex' package | ||
3 | |||
4 | copyright (C) 2016 Robert Alessi | ||
5 | |||
6 | Please send error reports and suggestions for improvements to | ||
7 | Robert Alessi <alessi@robertalessi.net> | ||
8 | |||
9 | This program is free software; you can redistribute it and/or | ||
10 | modify it under the terms of the GNU General Public License | ||
11 | as published by the Free Software Foundation; either version 2 | ||
12 | of the License, or (at your option) any later version. | ||
13 | |||
14 | This program is distributed in the hope that it will be useful, | ||
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | GNU General Public License for more details. | ||
18 | |||
19 | You should have received a copy of the GNU General Public License | ||
20 | along with this program; if not, write to the Free Software | ||
21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
22 | 02111-1307, USA. | ||
23 | --]] | ||
24 | |||
25 | tanwinnovoc = { | ||
26 | {a="uN", b=""}, | ||
27 | {a="(aN)(_A)", b="ى"}, | ||
28 | {a="(T)(aN)", b="%1"}, | ||
29 | {a="([^TA])(aN)", b="%1ا"}, | ||
30 | {a="iN", b=""} | ||
31 | } | ||
32 | |||
33 | longvnovoc = { | ||
34 | {a="A", b="ا"}, | ||
35 | {a="U", b="و"}, | ||
36 | {a="I", b="ي"} | ||
37 | } | ||
38 | |||
39 | shortvnovoc = { | ||
40 | {a="u", b=""}, | ||
41 | {a="a", b=""}, | ||
42 | {a="i", b=""} | ||
43 | } | ||
44 | |||
45 | -- return { | ||
46 | -- raw = raw, | ||
47 | -- hamza = hamza, | ||
48 | -- trigraphs = trigraphs, | ||
49 | -- tanwin = tanwin, | ||
50 | -- digraphs = digraphs, | ||
51 | -- single = single, | ||
52 | -- longv = longv, | ||
53 | -- shortv = shortv, | ||
54 | -- null =null | ||
55 | -- } | ||
diff --git a/arabluatex_voc.lua b/arabluatex_voc.lua new file mode 100644 index 0000000..6e712db --- /dev/null +++ b/arabluatex_voc.lua | |||
@@ -0,0 +1,257 @@ | |||
1 | --[[ | ||
2 | This file is part of the `arabluatex' package | ||
3 | |||
4 | copyright (C) 2016 Robert Alessi | ||
5 | |||
6 | Please send error reports and suggestions for improvements to | ||
7 | Robert Alessi <alessi@robertalessi.net> | ||
8 | |||
9 | This program is free software; you can redistribute it and/or | ||
10 | modify it under the terms of the GNU General Public License | ||
11 | as published by the Free Software Foundation; either version 2 | ||
12 | of the License, or (at your option) any later version. | ||
13 | |||
14 | This program is distributed in the hope that it will be useful, | ||
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | GNU General Public License for more details. | ||
18 | |||
19 | You should have received a copy of the GNU General Public License | ||
20 | along with this program; if not, write to the Free Software | ||
21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
22 | 02111-1307, USA. | ||
23 | --]] | ||
24 | |||
25 | numbers = { | ||
26 | {a="0", b="٠"}, | ||
27 | {a="1", b="١"}, | ||
28 | {a="2", b="٢"}, | ||
29 | {a="3", b="٣"}, | ||
30 | {a="4", b="٤"}, | ||
31 | {a="5", b="٥"}, | ||
32 | {a="6", b="٦"}, | ||
33 | {a="7", b="٧"}, | ||
34 | {a="8", b="٨"}, | ||
35 | {a="9", b="٩"} | ||
36 | } | ||
37 | |||
38 | raw = { | ||
39 | {a="A", b="َا"}, | ||
40 | {a="U", b="ُو"}, | ||
41 | {a="I", b="ِي"}, | ||
42 | {a="b", b="ب"}, | ||
43 | {a="t", b="ت"}, | ||
44 | {a="j", b="ج"}, | ||
45 | {a="x", b="خ"}, | ||
46 | {a="d", b="د"}, | ||
47 | {a="r", b="ر"}, | ||
48 | {a="z", b="ز"}, | ||
49 | {a="s", b="س"}, | ||
50 | {a="f", b="ف"}, | ||
51 | {a="`", b="ع"}, | ||
52 | {a="f", b="ف"}, | ||
53 | {a="q", b="ق"}, | ||
54 | {a="k", b="ك"}, | ||
55 | {a="l", b="ل"}, | ||
56 | {a="m", b="م"}, | ||
57 | {a="n", b="ن"}, | ||
58 | {a="h", b="ه"}, | ||
59 | {a="w", b="و"}, | ||
60 | {a="y", b="ي"}, | ||
61 | {a="T", b="ة"}, | ||
62 | {a="u", b="ُ"}, | ||
63 | {a="a", b="َ"}, | ||
64 | {a="i", b="ِ"} | ||
65 | } | ||
66 | |||
67 | hamza = { | ||
68 | -- initial long u | ||
69 | {a="%'%_U", b="أU"}, | ||
70 | -- madda and its historic writing | ||
71 | {a="'A", b="آ"}, | ||
72 | {a="(A)(')", b="aآء"}, | ||
73 | -- initial (needs both ^ and %W patterns) | ||
74 | {a="^(')([ua])", b="أ%2"}, | ||
75 | {a="^(')(i)", b="إ%2"}, | ||
76 | {a="(%W)(')([ua])", b="%1أ%3"}, | ||
77 | {a="(%W)(')(i)", b="%1إ%3"}, | ||
78 | -- final | ||
79 | {a="([^uai])(')([uai]N?)$", b="%1ء%3"}, | ||
80 | {a="([^uai])(')([uai]N?)(%W)", b="%1ء%3%4"}, | ||
81 | {a="([UI])(')([uai])$", b="%1ء%3"}, | ||
82 | {a="([UI])(')([uai])(%W)", b="%1ء%3%4"}, | ||
83 | -- middle | ||
84 | {a="([UI])(')", b="%1ء"}, | ||
85 | {a="([^uai])(')([uU])", b="%1ؤ%3"}, | ||
86 | {a="([^uai])(')([aA])", b="%1أ%3"}, | ||
87 | {a="([^uai])(')([iI])", b="%1ئ%3"}, | ||
88 | {a="(u)(')([uU])", b="%1ؤ%3"}, | ||
89 | {a="(u)(')([aA])", b="%1ؤ%3"}, | ||
90 | {a="(u)(')([iI])", b="%1ئ%3"}, | ||
91 | {a="(a)(')([aA])", b="%1أ%3"}, | ||
92 | {a="(a)(')([uU])", b="%1ؤ%3"}, | ||
93 | {a="(a)(')([iI])", b="%1ئ%3"}, | ||
94 | {a="(i)(')([aA])", b="%1ئ%3"}, | ||
95 | {a="(i)(')([uU])", b="%1ئ%3"}, | ||
96 | {a="(i)(')([iI])", b="%1ئ%3"}, | ||
97 | {a="(a)(')([^uaiUAI])", b="%1أ%3"}, | ||
98 | {a="(u)(')([^uaiUAI])", b="%1ؤ%3"}, | ||
99 | {a="(i)(')([^uaiUAI])", b="%1ئ%3"} | ||
100 | } | ||
101 | |||
102 | trigraphs = { -- trigraphs or more | ||
103 | -- al- + lām | ||
104 | {a="^(a)l%-(l)", b="ا%1ل%2%2"}, | ||
105 | {a="(%s)(a)l%-(l)", b="%1ا%2ل%3%3"}, | ||
106 | -- al- + solar consonant | ||
107 | {a="^(a)l%-([%_%^%.]?[tdrzsn])", b="ا%1ل%2%2"}, | ||
108 | {a="(%s)(a)l%-([%_%^%.]?[tdrzsn])", b="%1ا%2ل%3%3"}, | ||
109 | -- assim. art. + solar consonant | ||
110 | {a="^(a)([%_%^%.]?[tdrzsn])%-", b="ا%1ل%2"}, | ||
111 | {a="(%s)(a)([%_%^%.]?[tdrzsn])%-", b="%1ا%2ل%3"}, | ||
112 | -- al- + initial unstable hamza | ||
113 | {a="^(a)l%-([uai])", b="ا%1لا%2"}, | ||
114 | {a="(%s)(a)l%-([uai])", b="%1ا%2لا%3"}, | ||
115 | -- li- + art. + initial unstable hamza is a special orthography | ||
116 | {a="l(i)%-l%-([uai])", b="ل%1لا%2"}, | ||
117 | -- al- + lunar consonant (i.e. what remains) | ||
118 | {a="^(a)l%-", b="ا%1ل"}, | ||
119 | {a="(%s)(a)l%-", b="%1ا%2ل"}, | ||
120 | -- art. with waṣla + lām | ||
121 | {a="'l%-(l)", b="ال%1%1"}, | ||
122 | -- art. with waṣla + solar consonant | ||
123 | {a="'l%-([%_%^%.]?[tdrzsn])", b="ال%1%1"}, | ||
124 | -- li- + art. + lām | ||
125 | {a="l(i)%-l%-(l)", b="ل%1ل%2%2"}, | ||
126 | -- assim. art. with waṣla + solar consonant | ||
127 | {a="'([%_%^%.]?[tdrzsn])%-", b="ال%1"}, | ||
128 | -- li- + art. + solar consonant is a special orthography | ||
129 | {a="l(i)%-l%-([%_%^%.]?[tdrzsn])", b="ل%1ل%2%2"}, | ||
130 | -- li- + assim. art. + solar consonant is a special orthography | ||
131 | {a="l(i)%-([%_%^%.]?[tdrzsn])%-([%_%^%.]?[tdrzsn])", b="ل%1ل%3%3"}, | ||
132 | -- art. with waṣla + initial unstable hamza | ||
133 | {a="'l%-([uai])", b="الا%1"}, | ||
134 | -- art. with waṣla + lunar consonant (i.e. what remains) | ||
135 | {a="'l%-", b="ال"} | ||
136 | } | ||
137 | |||
138 | tanwin = { | ||
139 | {a="uN", b="ٌ"}, | ||
140 | {a="(aN)(_A)", b="ًى"}, | ||
141 | {a="(aN)(Y)", b="ًى"}, | ||
142 | {a="(T)(aN)", b="%1ً"}, | ||
143 | {a="([^TA])(aN)", b="%1ًا"}, | ||
144 | {a="iN", b="ٍ"} | ||
145 | } | ||
146 | |||
147 | digraphs = { | ||
148 | {a="^([uai])", b="ا%1"}, -- initial alif without hamza | ||
149 | {a="(%s)([uai])", b="%1ا%2"}, -- initial alif without hamza | ||
150 | {a="%-%-", b="ـ"}, | ||
151 | {a="bb", b="بّ"}, | ||
152 | {a="BB", b="ـّ"}, | ||
153 | {a="tt", b="تّ"}, | ||
154 | {a="%_t%_t", b="ثّ"}, | ||
155 | {a="jj", b="جّ"}, | ||
156 | {a="%^g%^g", b="جّ"}, | ||
157 | {a="xx", b="خّ"}, | ||
158 | {a="%_h%_h", b="خّ"}, | ||
159 | {a="dd", b="دّ"}, | ||
160 | {a="%_d%_d", b="ذّ"}, | ||
161 | {a="rr", b="رّ"}, | ||
162 | {a="zz", b="زّ"}, | ||
163 | {a="ss", b="سّ"}, | ||
164 | {a="%^s%^s", b="شّ"}, | ||
165 | {a="%.s%.s", b="صّ"}, | ||
166 | {a="%.d%.d", b="ضّ"}, | ||
167 | {a="%.t%.t", b="طّ"}, | ||
168 | {a="%.z%.z", b="ظّ"}, | ||
169 | {a="%`%`", b="عّ"}, | ||
170 | {a="%.g%.g", b="غّ"}, | ||
171 | {a="ff", b="فّ"}, | ||
172 | {a="qq", b="قّ"}, | ||
173 | {a="kk", b="كّ"}, | ||
174 | {a="ll", b="لّ"}, | ||
175 | {a="mm", b="مّ"}, | ||
176 | {a="nn", b="نّ"}, | ||
177 | {a="hh", b="هّ"}, | ||
178 | {a="ww", b="وّ"}, | ||
179 | {a="yy", b="يّ"}, | ||
180 | {a="_t", b="ث"}, | ||
181 | {a="%^g", b="ج"}, | ||
182 | {a="%.h", b="ح"}, | ||
183 | {a="_h", b="خ"}, | ||
184 | {a="_d", b="ذ"}, | ||
185 | {a="%^s", b="ش"}, | ||
186 | {a="%.s", b="ص"}, | ||
187 | {a="%.d", b="ض"}, | ||
188 | {a="%.t", b="ط"}, | ||
189 | {a="%.z", b="ظ"}, | ||
190 | {a="%.g", b="غ"}, | ||
191 | {a="(U)(A)", b="%1ا"}, | ||
192 | {a="WA", b="وا"}, | ||
193 | {a="(a)W", b="%1وا"}, | ||
194 | {a="_A", b="aى"}, | ||
195 | {a="_u", b="ٗ"}, | ||
196 | {a="_a", b="ٰ"}, | ||
197 | {a="_i", b="ٖ"}, | ||
198 | {a="%.b", b="ٮ"}, | ||
199 | {a="%.f", b="ڡ"}, | ||
200 | {a="%.k", b="ک"}, | ||
201 | {a="%.n", b="ں"} | ||
202 | } | ||
203 | |||
204 | single = { | ||
205 | {a="b", b="ب"}, | ||
206 | {a="t", b="ت"}, | ||
207 | {a="j", b="ج"}, | ||
208 | {a="x", b="خ"}, | ||
209 | {a="d", b="د"}, | ||
210 | {a="r", b="ر"}, | ||
211 | {a="z", b="ز"}, | ||
212 | {a="s", b="س"}, | ||
213 | {a="f", b="ف"}, | ||
214 | {a="`", b="ع"}, | ||
215 | {a="f", b="ف"}, | ||
216 | {a="q", b="ق"}, | ||
217 | {a="k", b="ك"}, | ||
218 | {a="l", b="ل"}, | ||
219 | {a="m", b="م"}, | ||
220 | {a="n", b="ن"}, | ||
221 | {a="h", b="ه"}, | ||
222 | {a="w", b="و"}, | ||
223 | {a="y", b="ي"}, | ||
224 | {a="T", b="ة"}, | ||
225 | {a="Y", b="aى"}, | ||
226 | {a='"', b='ْ'}, | ||
227 | {a="([^0-9])%-([^0-9])", b="%1%2"}, | ||
228 | {a="B", b="ـ"} | ||
229 | } | ||
230 | |||
231 | longv = { | ||
232 | {a="A", b="َا"}, | ||
233 | {a="U", b="ُو"}, | ||
234 | {a="I", b="ِي"} | ||
235 | } | ||
236 | |||
237 | shortv = { | ||
238 | {a="u", b="ُ"}, | ||
239 | {a="a", b="َ"}, | ||
240 | {a="i", b="ِ"} | ||
241 | } | ||
242 | |||
243 | null = { | ||
244 | {a="%|", b=""} | ||
245 | } | ||
246 | |||
247 | -- return { | ||
248 | -- raw = raw, | ||
249 | -- hamza = hamza, | ||
250 | -- trigraphs = trigraphs, | ||
251 | -- tanwin = tanwin, | ||
252 | -- digraphs = digraphs, | ||
253 | -- single = single, | ||
254 | -- longv = longv, | ||
255 | -- shortv = shortv, | ||
256 | -- null =null | ||
257 | -- } | ||
diff --git a/makefile b/makefile new file mode 100644 index 0000000..1875576 --- /dev/null +++ b/makefile | |||
@@ -0,0 +1,32 @@ | |||
1 | pkg=arabluatex | ||
2 | |||
3 | sty: clean | ||
4 | lualatex $(pkg).ins | ||
5 | |||
6 | doc: clean sty | ||
7 | lualatex $(pkg).dtx | ||
8 | makeindex -s gind.ist -o $(pkg).ind $(pkg).idx | ||
9 | makeindex -s gglo.ist -o $(pkg).gls $(pkg).glo | ||
10 | lualatex $(pkg).dtx | ||
11 | lualatex $(pkg).dtx | ||
12 | |||
13 | all: clean sty doc | ||
14 | |||
15 | package: clean sty | ||
16 | cp ~/texmf/tex/lualatex/arabluatex/$(pkg).sty \ | ||
17 | ~/texmf/tex/lualatex/arabluatex/$(pkg).sty-`date +%s` | ||
18 | cp ~/texmf/tex/lualatex/arabluatex/$(pkg).lua \ | ||
19 | ~/texmf/tex/lualatex/arabluatex/$(pkg).lua-`date +%s` | ||
20 | cp ~/texmf/tex/lualatex/arabluatex/$(pkg)_voc.lua \ | ||
21 | ~/texmf/tex/lualatex/arabluatex/$(pkg)_voc.lua-`date +%s` | ||
22 | cp ~/texmf/tex/lualatex/arabluatex/$(pkg)_novoc.lua \ | ||
23 | ~/texmf/tex/lualatex/arabluatex/$(pkg)_novoc.lua-`date +%s` | ||
24 | cp $(pkg)*.{sty,lua} ~/texmf/tex/lualatex/arabluatex | ||
25 | |||
26 | clean: | ||
27 | rm -rf saved/ | ||
28 | mkdir saved | ||
29 | cp *.{lua,ins,dtx} makefile saved | ||
30 | rm *.* | ||
31 | cp saved/* . | ||
32 | rm -rf saved/ | ||