aboutsummaryrefslogtreecommitdiff
path: root/arabluatex.dtx
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2016-02-22 10:06:28 +0100
committerRobert Alessi <alessi@robertalessi.net>2016-02-22 10:06:28 +0100
commit041154d5339e42601ed04b6e2a23d53ffaae1022 (patch)
tree972514791a346666c2d77536646e298d7969a393 /arabluatex.dtx
downloadarabluatex-041154d5339e42601ed04b6e2a23d53ffaae1022.tar.gz
initial project version
Diffstat (limited to 'arabluatex.dtx')
-rw-r--r--arabluatex.dtx247
1 files changed, 247 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