From 041154d5339e42601ed04b6e2a23d53ffaae1022 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Mon, 22 Feb 2016 10:06:28 +0100 Subject: initial project version --- arabluatex.dtx | 247 +++++++++++++++++++++++++++++++++++++++++++++++++ arabluatex.ins | 74 +++++++++++++++ arabluatex.lua | 195 ++++++++++++++++++++++++++++++++++++++ arabluatex_novoc.lua | 55 +++++++++++ arabluatex_voc.lua | 257 +++++++++++++++++++++++++++++++++++++++++++++++++++ makefile | 32 +++++++ 6 files changed, 860 insertions(+) create mode 100644 arabluatex.dtx create mode 100644 arabluatex.ins create mode 100644 arabluatex.lua create mode 100644 arabluatex_novoc.lua create mode 100644 arabluatex_voc.lua create mode 100644 makefile diff --git a/arabluatex.dtx b/arabluatex.dtx new file mode 100644 index 0000000..96261bc --- /dev/null +++ b/arabluatex.dtx @@ -0,0 +1,247 @@ +% \iffalse meta-comment +% copyright (C) 2016 Robert Alessi +% +% Please send error reports and suggestions for improvements to +% Robert Alessi +% +% This program is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License +% as published by the Free Software Foundation; either version 2 +% of the License, or (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +% 02111-1307, USA. +% \fi +% +% \iffalse +%<*driver> +\ProvidesFile{arabluatex.dtx} +% +%\NeedsTeXFormat{LaTeX2e}[1999/12/01] +%\ProvidesPackage{arabluatex} +%<*package-info> + [2016/01/26 v1.0 This is ArabTeX for LuaLaTeX] +% +% +%<*driver> +\documentclass{ltxdoc} +\usepackage[english]{babel} +\usepackage{fontspec,luatextra,realscripts} +\defaultfontfeatures{RawFeature={+liga}} +\setmainfont{Libertinus Serif} +\setsansfont{Libertinus Sans} +\setmonofont[Scale=.9]{Libertinus Mono} +\usepackage{arabluatex}[2016/01/26] +\usepackage{hypdoc} +\hypersetup{colorlinks, allcolors=blue} +\usepackage{multicol} +\newcommand{\package}[1]{\textsf{#1}} +\usepackage{paralist} +\setdefaultitem{\textendash}{\textendash}{\textendash}{\textendash} +\usepackage{tikz} +\usepackage[skins]{tcolorbox} +\usepackage{csquotes} +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\begin{document} + \DocInput{arabluatex.dtx} + \PrintChanges + \PrintIndex +\end{document} +% +% \fi +% +% \CheckSum{0} +% +% \CharacterTable +% {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 +% 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 +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% +% \changes{1.0}{2016/01/26}{Converted to DTX file} +% +% \DoNotIndex{\newcommand,\newenvironment,\renewcommand} +% +% \providecommand*{\url}{\texttt} +% \GetFileInfo{arabluatex.dtx} +% +% \title{\tcbox[enhanced, tikznode, drop lifted shadow, colback=white, +% boxrule=.25mm]% +% {The \textsf{arabluatex} package\\ +% \fileversion~from \filedate}} +% +% \newcommand*{\NEWfeature}[1]{% +% \hskip 1sp \marginpar{\small\sffamily\raggedright +% New feature\\#1}} +% +% \author{Robert Alessi \\ \url{alessi@robertalessi.net}} +% \date{} +% +% \maketitle +% +% \begin{multicols}{2} +% \footnotesize +% \tableofcontents +% \end{multicols} +% +% \begin{abstract} +% This package provides for \LuaLaTeX\ an Arab{\TeX}-like interface +% to generate Arabic writing from an \textsc{ascii} +% transliteration. It is particularly well-suited for complex +% documents such as technical documents or critical editions where a +% lot of left-to-right commands intertwine with Arabic +% writing. \package{arabluatex} is able to process any Arab\TeX\ +% input notation. Its output can be set in the same modes of +% vocalization as Arab\TeX\ ones, or in different roman +% transliterations. It further allows some typographical +% refinements. +% \end{abstract} +% +% \section*{License and disclamer} +% \addcontentsline{toc}{section}{License and disclamer} +% Please send error reports and suggestions for improvements to +% Robert Alessi <\url{alessi@robertalessi.net}> +% +% This program is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License +% as published by the Free Software Foundation; either version 2 +% of the License, or (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +% 02111-1307, USA. +% +% \section{Introduction} +% In comparison to Prof. Lagally's outstanding Arab\TeX,\footnote{See +% \url{http://ctan.org/pkg/arabtex}} Arab\LuaTeX\ is at present +% nothing more than a modest piece of software. Hopefully---if I may +% say so---it will eventually provide all of its valuable qualities to +% the \LuaLaTeX\ users. +% +% \section{Usage} +% +% Usage goes here. +% +% \StopEventually{} +% +% \section{Implementation} +% +% \iffalse +%<*package> +% \fi +% +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{arabluatex}% +[2016/01/26 v1.0 ArabTeX-like interface for LuaLaTeX] +\RequirePackage{ifluatex} +% \end{macrocode} +% \package{arabluatex} requires \LuaLaTeX\ of course. +% \begin{macrocode} +\ifluatex\else + \PackageError{arabluatex}{lualatex needed}{% + Package `arabluatex' needs LuaTeX.\MessageBreak + So you should use `lualatex' to process you document!\MessageBreak + See documentation of `arabluatex' for further information.}% + \expandafter\expandafter\expandafter\csname endinput\endcsname +\fi +% \end{macrocode} +% \begin{macrocode} +\DeclareOption{voc}{\def\al@mode{voc}} +\DeclareOption{novoc}{\def\al@mode{novoc}} +\ExecuteOptions{voc} +\ProcessOptions\relax +\def\al@mode@voc{voc} +\def\al@mode@novoc{novoc} +% \newif\ifal@mode@defined +\RequirePackage{amsmath} +\RequirePackage{etoolbox} +\RequirePackage{luacode} +\RequirePackage{xparse} +\RequirePackage{environ} +\luadirect{dofile(kpse.find_file("arabluatex.lua"))} +% \end{macrocode} +% This is needed by the current version of \package{luabidi}. +% \begin{macrocode} +\luadirect{tex.enableprimitives("luatex",tex.extraprimitives("omega"))} +% \end{macrocode} +% \package{luabidi} provides a \cs{Footnote} command. Use it for now. +% \begin{macrocode} +\RequirePackage{luabidi} +% \end{macrocode} +% \begin{macrocode} +\AtBeginDocument{\ifdefined\arabicfont\relax\else +\PackageWarning{arabluatex}{\string\arabicfont\ is not defined!^^JI + will try to load Amiri}% +\newfontfamily\arabicfont[Script=Arabic]{Amiri}\fi}% +\DeclareDocumentCommand{\LR}{+m}{\bgroup\textdir TLT\rmfamily#1\egroup} +\DeclareDocumentCommand{\txarb}{+m}{\bgroup\textdir TRT\arabicfont#1\egroup} +\DeclareDocumentCommand{\arb}{O{\al@mode} +m}% +{\edef\@tempa{#1}% + \ifx\@tempa\al@mode@voc% + \bgroup\textdir TRT\arabicfont% + \luadirect{tex.sprint(processvoc("\luaescapestring{#2}"))}\egroup% + \else% + \ifx\@tempa\al@mode@novoc% + \bgroup\textdir TRT\arabicfont% + \luadirect{tex.sprint(processnovoc("\luaescapestring{#2}"))}\egroup% + \else% + \fi\fi} +\DeclareDocumentCommand{\aemph}{m}{$\overline{\text{#1}}$} +\NewEnviron{arab}[1][\al@mode]% +{\par\edef\@tempa{#1}% + \ifx\@tempa\al@mode@voc% + \bgroup\pardir TRT\textdir TRT\arabicfont% + \luadirect{tex.sprint(processvoc("\luaescapestring{\BODY}"))}\egroup% + \else% + \ifx\@tempa\al@mode@novoc% + \bgroup\pardir TRT\textdir TRT\arabicfont% + \luadirect{tex.sprint(processnovoc("\luaescapestring{\BODY}"))}\egroup% + \else + \BODY% + \fi\fi}[\par] +\robustify{\textbf} +\robustify{\emph} +\robustify{\footnote} +\robustify{\marginpar} +\DeclareDocumentCommand{\Marginpar}{m}{\marginpar{\textdir TLT #1}} +\RenewDocumentCommand{\thefootnote}{}{\bgroup\textdir + TLT\arabic{footnote}\egroup} +\AtBeginDocument{\ifdef{\abjad}{\robustify{\abjad}}{}} +\AtBeginDocument{\ifdef{\Footnote}{\robustify{\Footnote}}{}} +\endinput +% \end{macrocode} + +% +% \iffalse +% +% \fi +% +% \Finale +\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 @@ +%% copyright (C) 2016 Robert Alessi +%% +%% Please send error reports and suggestions for improvements to +%% Robert Alessi +%% +%% This program is free software; you can redistribute it and/or +%% modify it under the terms of the GNU General Public License +%% as published by the Free Software Foundation; either version 2 +%% of the License, or (at your option) any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program; if not, write to the Free Software +%% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +%% + +\input docstrip.tex +\keepsilent + +\usedir{tex/lualatex/arabluatex} + +\preamble + +This is a generated file. + +copyright (C) 2016 Robert Alessi + +Please send error reports and suggestions for improvements to +Robert Alessi + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +USA. + +\endpreamble + +\generate{\file{arabluatex.sty}{\from{arabluatex.dtx}{package}}} + +\Msg{***********************************************************} +\Msg{*} +\Msg{* To finish the installation you have to move the following} +\Msg{* file(s) into a directory searched by LaTeX. See the FAQ on} +\Msg{* CTAN at /help/uk-tex-faq for more on this.} +\Msg{*} +\Msg{* \space\space arabluatex.sty} +\Msg{* \space\space arabluatex.lua} +\Msg{*} +\Msg{* To produce the documentation run the files ending with} +\Msg{* `.dtx' through LuaLaTeX.} +\Msg{*} +\Msg{* For an index, do:} +\Msg{* \space makeindex -s gind.ist -o arabluatex.ind arabluatex.idx} +\Msg{* For a list of changes, do:} +\Msg{* \space makeindex -s gglo.ist -o arabluatex.gls arabluatex.glo} +\Msg{*} +\Msg{* Happy TeXing!} +\Msg{***********************************************************} + +\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 @@ +--[[ +This file is part of the `arabluatex' package + +copyright (C) 2016 Robert Alessi + +Please send error reports and suggestions for improvements to +Robert Alessi + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. +--]] + +require("arabluatex_voc") +require("arabluatex_novoc") + +local function protectarb(str) + str = string.gsub(str, "(\\arb.?)(%[.-%])(%b{})", "\\@arb%2%3") + str = string.gsub(str, "\\par", "\\p@r{}") + str = string.gsub(str, "\\@@par", "\\p@r{}") +return str +end + +local function unprotectarb(str) + str = string.gsub(str, "(\\@arb)(%[.-%])(%b{})", "\\arb%2%3") + str = string.gsub(str, "\\p@r{}", "\\par") +return str +end + +local function breakcmd(str) + -- \LR + str = string.gsub(str, "\\(LR.-)(%b{})", + function(tag, body) + body = string.sub(body, 2, -2) + return string.format("}\\%s{%s}\\arb{", tag, body) + end) + -- Footnote + str = string.gsub(str, "\\(Footnote.-)(%b{})", + function(tag, body) + body = string.sub(body, 2, -2) + return string.format("}\\%s{%s}\\arb{", tag, body) + end) + -- Marginpar + str = string.gsub(str, "\\(Marginpar.-)(%b{})", + function(tag, body) + body = string.sub(body, 2, -2) + return string.format("}\\%s{%s}\\arb{", tag, body) + end) + -- Abjad (Needs polyglossia) + str = string.gsub(str, "\\(abjad.-)(%b{})", + function(tag, body) + body = string.sub(body, 2, -2) + return string.format("}\\aemph{\\txarb{\\%s{%s}}}\\arb{", tag, body) + end) + return str +end + +local function holdcmd(str) + str = string.gsub(str, "\\(arb)(%b{})", function(tag, body) + body = string.sub(body, 2, -2) + body = string.gsub(body, "\\(.-)(%b{})", function(btag, bbody) + bbody = string.sub(bbody, 2, -2) + if string.find(btag, "@") then + return holdcmd(string.format("}\\%s{%s}\\arb{", btag, bbody)) + else + return holdcmd(string.format("}\\%s{\\arb{%s}}\\arb{", btag, bbody)) + end + end) + return string.format("\\%s{%s}", tag, body) + end) + str = string.gsub(str, "\\arb{}", "") +return str +end + +local function arbnum(str) + str = string.gsub(str, "([0-9%,%-%/]+)", function(num) + return string.reverse(num) + end) + return str +end + +local function indnum(str) + str = string.gsub(str, "([0-9%,%-%/]+)", function(num) + return string.reverse(num) + end) + for i = 1,#numbers do + str = string.gsub(str, numbers[i].a, numbers[i].b) + end + return str +end + +local function voc(str) + str = string.gsub(str, "\\arb(%b{})", function(inside) + inside = string.sub(inside, 2, -2) + for i = 1,#hamza do + inside = string.gsub(inside, hamza[i].a, hamza[i].b) + end + for i = 1,#tanwin do + inside = string.gsub(inside, tanwin[i].a, tanwin[i].b) + end + for i = 1,#trigraphs do + inside = string.gsub(inside, trigraphs[i].a, trigraphs[i].b) + end + for i = 1,#digraphs do + inside = string.gsub(inside, digraphs[i].a, digraphs[i].b) + end + for i = 1,#single do + inside = string.gsub(inside, single[i].a, single[i].b) + end + for i = 1,#longv do + inside = string.gsub(inside, longv[i].a, longv[i].b) + end + for i = 1,#shortv do + inside = string.gsub(inside, shortv[i].a, shortv[i].b) + end + for i = 1,#null do + inside = string.gsub(inside, null[i].a, null[i].b) + end + inside = indnum(inside) + return string.format("\\txarb{%s}", inside) + end) +return str +end + +local function novoc(str) + str = string.gsub(str, "\\arb(%b{})", function(inside) + inside = string.sub(inside, 2, -2) + for i = 1,#hamza do + inside = string.gsub(inside, hamza[i].a, hamza[i].b) + end + for i = 1,#tanwinnovoc do + inside = string.gsub(inside, tanwinnovoc[i].a, tanwinnovoc[i].b) + end + for i = 1,#trigraphs do + inside = string.gsub(inside, trigraphs[i].a, trigraphs[i].b) + end + for i = 1,#digraphs do + inside = string.gsub(inside, digraphs[i].a, digraphs[i].b) + end + for i = 1,#single do + inside = string.gsub(inside, single[i].a, single[i].b) + end + for i = 1,#longvnovoc do + inside = string.gsub(inside, longvnovoc[i].a, longvnovoc[i].b) + end + for i = 1,#shortvnovoc do + inside = string.gsub(inside, shortvnovoc[i].a, shortvnovoc[i].b) + end + for i = 1,#null do + inside = string.gsub(inside, null[i].a, null[i].b) + end + inside = indnum(inside) + return string.format("\\txarb{%s}", inside) + end) +return str +end + +function processvoc(str) + str = "\\arb{".. str.."}" + str = protectarb(str) + str = breakcmd(str) + str = holdcmd(str) + str = voc(str) + str = unprotectarb(str) +return str +end + +function processnovoc(str) + str = "\\arb{".. str.."}" + str = protectarb(str) + str = breakcmd(str) + str = holdcmd(str) + str = novoc(str) + str = unprotectarb(str) +return str +end + +--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")) +--print(arbnum("bop 0123456789")) +--print(processvoc("daxala \\arb[novoc]{mubtasimaN}")) +--print(processvoc("\\emph{daxala} \\arb[novoc]{mufakkiruN}\\Footnote{\\arb{kataba \\arb[novoc]{mubtasimaN}} Je pense que c'est bien \\arb{kataba}} faqa.t")) +--print(processvoc("daxala \\abjad{45} mubtasimaN")) +--print(process("daxala\\Footnote{Et là c'est toujours \\arb{mubtasimaN}?")) +--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 @@ +--[[ +This file is part of the `arabluatex' package + +copyright (C) 2016 Robert Alessi + +Please send error reports and suggestions for improvements to +Robert Alessi + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. +--]] + +tanwinnovoc = { + {a="uN", b=""}, + {a="(aN)(_A)", b="ى"}, + {a="(T)(aN)", b="%1"}, + {a="([^TA])(aN)", b="%1ا"}, + {a="iN", b=""} +} + +longvnovoc = { + {a="A", b="ا"}, + {a="U", b="و"}, + {a="I", b="ي"} +} + +shortvnovoc = { + {a="u", b=""}, + {a="a", b=""}, + {a="i", b=""} +} + +-- return { +-- raw = raw, +-- hamza = hamza, +-- trigraphs = trigraphs, +-- tanwin = tanwin, +-- digraphs = digraphs, +-- single = single, +-- longv = longv, +-- shortv = shortv, +-- null =null +-- } 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 @@ +--[[ +This file is part of the `arabluatex' package + +copyright (C) 2016 Robert Alessi + +Please send error reports and suggestions for improvements to +Robert Alessi + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. +--]] + +numbers = { + {a="0", b="٠"}, + {a="1", b="١"}, + {a="2", b="٢"}, + {a="3", b="٣"}, + {a="4", b="٤"}, + {a="5", b="٥"}, + {a="6", b="٦"}, + {a="7", b="٧"}, + {a="8", b="٨"}, + {a="9", b="٩"} +} + +raw = { + {a="A", b="َا"}, + {a="U", b="ُو"}, + {a="I", b="ِي"}, + {a="b", b="ب"}, + {a="t", b="ت"}, + {a="j", b="ج"}, + {a="x", b="خ"}, + {a="d", b="د"}, + {a="r", b="ر"}, + {a="z", b="ز"}, + {a="s", b="س"}, + {a="f", b="ف"}, + {a="`", b="ع"}, + {a="f", b="ف"}, + {a="q", b="ق"}, + {a="k", b="ك"}, + {a="l", b="ل"}, + {a="m", b="م"}, + {a="n", b="ن"}, + {a="h", b="ه"}, + {a="w", b="و"}, + {a="y", b="ي"}, + {a="T", b="ة"}, + {a="u", b="ُ"}, + {a="a", b="َ"}, + {a="i", b="ِ"} +} + +hamza = { + -- initial long u + {a="%'%_U", b="أU"}, + -- madda and its historic writing + {a="'A", b="آ"}, + {a="(A)(')", b="aآء"}, + -- initial (needs both ^ and %W patterns) + {a="^(')([ua])", b="أ%2"}, + {a="^(')(i)", b="إ%2"}, + {a="(%W)(')([ua])", b="%1أ%3"}, + {a="(%W)(')(i)", b="%1إ%3"}, + -- final + {a="([^uai])(')([uai]N?)$", b="%1ء%3"}, + {a="([^uai])(')([uai]N?)(%W)", b="%1ء%3%4"}, + {a="([UI])(')([uai])$", b="%1ء%3"}, + {a="([UI])(')([uai])(%W)", b="%1ء%3%4"}, + -- middle + {a="([UI])(')", b="%1ء"}, + {a="([^uai])(')([uU])", b="%1ؤ%3"}, + {a="([^uai])(')([aA])", b="%1أ%3"}, + {a="([^uai])(')([iI])", b="%1ئ%3"}, + {a="(u)(')([uU])", b="%1ؤ%3"}, + {a="(u)(')([aA])", b="%1ؤ%3"}, + {a="(u)(')([iI])", b="%1ئ%3"}, + {a="(a)(')([aA])", b="%1أ%3"}, + {a="(a)(')([uU])", b="%1ؤ%3"}, + {a="(a)(')([iI])", b="%1ئ%3"}, + {a="(i)(')([aA])", b="%1ئ%3"}, + {a="(i)(')([uU])", b="%1ئ%3"}, + {a="(i)(')([iI])", b="%1ئ%3"}, + {a="(a)(')([^uaiUAI])", b="%1أ%3"}, + {a="(u)(')([^uaiUAI])", b="%1ؤ%3"}, + {a="(i)(')([^uaiUAI])", b="%1ئ%3"} +} + +trigraphs = { -- trigraphs or more + -- al- + lām + {a="^(a)l%-(l)", b="ا%1ل%2%2"}, + {a="(%s)(a)l%-(l)", b="%1ا%2ل%3%3"}, + -- al- + solar consonant + {a="^(a)l%-([%_%^%.]?[tdrzsn])", b="ا%1ل%2%2"}, + {a="(%s)(a)l%-([%_%^%.]?[tdrzsn])", b="%1ا%2ل%3%3"}, + -- assim. art. + solar consonant + {a="^(a)([%_%^%.]?[tdrzsn])%-", b="ا%1ل%2"}, + {a="(%s)(a)([%_%^%.]?[tdrzsn])%-", b="%1ا%2ل%3"}, + -- al- + initial unstable hamza + {a="^(a)l%-([uai])", b="ا%1لا%2"}, + {a="(%s)(a)l%-([uai])", b="%1ا%2لا%3"}, + -- li- + art. + initial unstable hamza is a special orthography + {a="l(i)%-l%-([uai])", b="ل%1لا%2"}, + -- al- + lunar consonant (i.e. what remains) + {a="^(a)l%-", b="ا%1ل"}, + {a="(%s)(a)l%-", b="%1ا%2ل"}, + -- art. with waṣla + lām + {a="'l%-(l)", b="ال%1%1"}, + -- art. with waṣla + solar consonant + {a="'l%-([%_%^%.]?[tdrzsn])", b="ال%1%1"}, + -- li- + art. + lām + {a="l(i)%-l%-(l)", b="ل%1ل%2%2"}, + -- assim. art. with waṣla + solar consonant + {a="'([%_%^%.]?[tdrzsn])%-", b="ال%1"}, + -- li- + art. + solar consonant is a special orthography + {a="l(i)%-l%-([%_%^%.]?[tdrzsn])", b="ل%1ل%2%2"}, + -- li- + assim. art. + solar consonant is a special orthography + {a="l(i)%-([%_%^%.]?[tdrzsn])%-([%_%^%.]?[tdrzsn])", b="ل%1ل%3%3"}, + -- art. with waṣla + initial unstable hamza + {a="'l%-([uai])", b="الا%1"}, + -- art. with waṣla + lunar consonant (i.e. what remains) + {a="'l%-", b="ال"} +} + +tanwin = { + {a="uN", b="ٌ"}, + {a="(aN)(_A)", b="ًى"}, + {a="(aN)(Y)", b="ًى"}, + {a="(T)(aN)", b="%1ً"}, + {a="([^TA])(aN)", b="%1ًا"}, + {a="iN", b="ٍ"} +} + +digraphs = { + {a="^([uai])", b="ا%1"}, -- initial alif without hamza + {a="(%s)([uai])", b="%1ا%2"}, -- initial alif without hamza + {a="%-%-", b="ـ"}, + {a="bb", b="بّ"}, + {a="BB", b="ـّ"}, + {a="tt", b="تّ"}, + {a="%_t%_t", b="ثّ"}, + {a="jj", b="جّ"}, + {a="%^g%^g", b="جّ"}, + {a="xx", b="خّ"}, + {a="%_h%_h", b="خّ"}, + {a="dd", b="دّ"}, + {a="%_d%_d", b="ذّ"}, + {a="rr", b="رّ"}, + {a="zz", b="زّ"}, + {a="ss", b="سّ"}, + {a="%^s%^s", b="شّ"}, + {a="%.s%.s", b="صّ"}, + {a="%.d%.d", b="ضّ"}, + {a="%.t%.t", b="طّ"}, + {a="%.z%.z", b="ظّ"}, + {a="%`%`", b="عّ"}, + {a="%.g%.g", b="غّ"}, + {a="ff", b="فّ"}, + {a="qq", b="قّ"}, + {a="kk", b="كّ"}, + {a="ll", b="لّ"}, + {a="mm", b="مّ"}, + {a="nn", b="نّ"}, + {a="hh", b="هّ"}, + {a="ww", b="وّ"}, + {a="yy", b="يّ"}, + {a="_t", b="ث"}, + {a="%^g", b="ج"}, + {a="%.h", b="ح"}, + {a="_h", b="خ"}, + {a="_d", b="ذ"}, + {a="%^s", b="ش"}, + {a="%.s", b="ص"}, + {a="%.d", b="ض"}, + {a="%.t", b="ط"}, + {a="%.z", b="ظ"}, + {a="%.g", b="غ"}, + {a="(U)(A)", b="%1ا"}, + {a="WA", b="وا"}, + {a="(a)W", b="%1وا"}, + {a="_A", b="aى"}, + {a="_u", b="ٗ"}, + {a="_a", b="ٰ"}, + {a="_i", b="ٖ"}, + {a="%.b", b="ٮ"}, + {a="%.f", b="ڡ"}, + {a="%.k", b="ک"}, + {a="%.n", b="ں"} +} + +single = { + {a="b", b="ب"}, + {a="t", b="ت"}, + {a="j", b="ج"}, + {a="x", b="خ"}, + {a="d", b="د"}, + {a="r", b="ر"}, + {a="z", b="ز"}, + {a="s", b="س"}, + {a="f", b="ف"}, + {a="`", b="ع"}, + {a="f", b="ف"}, + {a="q", b="ق"}, + {a="k", b="ك"}, + {a="l", b="ل"}, + {a="m", b="م"}, + {a="n", b="ن"}, + {a="h", b="ه"}, + {a="w", b="و"}, + {a="y", b="ي"}, + {a="T", b="ة"}, + {a="Y", b="aى"}, + {a='"', b='ْ'}, + {a="([^0-9])%-([^0-9])", b="%1%2"}, + {a="B", b="ـ"} +} + +longv = { + {a="A", b="َا"}, + {a="U", b="ُو"}, + {a="I", b="ِي"} +} + +shortv = { + {a="u", b="ُ"}, + {a="a", b="َ"}, + {a="i", b="ِ"} +} + +null = { + {a="%|", b=""} +} + +-- return { +-- raw = raw, +-- hamza = hamza, +-- trigraphs = trigraphs, +-- tanwin = tanwin, +-- digraphs = digraphs, +-- single = single, +-- longv = longv, +-- shortv = shortv, +-- null =null +-- } diff --git a/makefile b/makefile new file mode 100644 index 0000000..1875576 --- /dev/null +++ b/makefile @@ -0,0 +1,32 @@ +pkg=arabluatex + +sty: clean + lualatex $(pkg).ins + +doc: clean sty + lualatex $(pkg).dtx + makeindex -s gind.ist -o $(pkg).ind $(pkg).idx + makeindex -s gglo.ist -o $(pkg).gls $(pkg).glo + lualatex $(pkg).dtx + lualatex $(pkg).dtx + +all: clean sty doc + +package: clean sty + cp ~/texmf/tex/lualatex/arabluatex/$(pkg).sty \ + ~/texmf/tex/lualatex/arabluatex/$(pkg).sty-`date +%s` + cp ~/texmf/tex/lualatex/arabluatex/$(pkg).lua \ + ~/texmf/tex/lualatex/arabluatex/$(pkg).lua-`date +%s` + cp ~/texmf/tex/lualatex/arabluatex/$(pkg)_voc.lua \ + ~/texmf/tex/lualatex/arabluatex/$(pkg)_voc.lua-`date +%s` + cp ~/texmf/tex/lualatex/arabluatex/$(pkg)_novoc.lua \ + ~/texmf/tex/lualatex/arabluatex/$(pkg)_novoc.lua-`date +%s` + cp $(pkg)*.{sty,lua} ~/texmf/tex/lualatex/arabluatex + +clean: + rm -rf saved/ + mkdir saved + cp *.{lua,ins,dtx} makefile saved + rm *.* + cp saved/* . + rm -rf saved/ -- cgit v1.2.3