summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/luahyphenrules
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/luatex/latex/luahyphenrules
Initial commit
Diffstat (limited to 'macros/luatex/latex/luahyphenrules')
-rw-r--r--macros/luatex/latex/luahyphenrules/README.md15
-rw-r--r--macros/luatex/latex/luahyphenrules/luahyphenrules.pdfbin0 -> 37590 bytes
-rw-r--r--macros/luatex/latex/luahyphenrules/luahyphenrules.sty161
-rw-r--r--macros/luatex/latex/luahyphenrules/luahyphenrules.tex114
4 files changed, 290 insertions, 0 deletions
diff --git a/macros/luatex/latex/luahyphenrules/README.md b/macros/luatex/latex/luahyphenrules/README.md
new file mode 100644
index 0000000000..a73222e514
--- /dev/null
+++ b/macros/luatex/latex/luahyphenrules/README.md
@@ -0,0 +1,15 @@
+luahyphenrules
+==============
+
+Preloading hyphenation patterns (or “hyphen rules”) into the format is
+not required in LuaTeX and recent releases of `babel` don't do it.
+This package is addressed to those who just want to select the
+language and load their patterns by means of `language.dat` without
+loading `babel`.
+
+* Javier Bezos
+* 2016-12-07
+* Released under the LaTeX Project Public License v1.3c or later
+ See http://www.latex-project.org/lppl.txt
+* It requires LuaLaTeX
+
diff --git a/macros/luatex/latex/luahyphenrules/luahyphenrules.pdf b/macros/luatex/latex/luahyphenrules/luahyphenrules.pdf
new file mode 100644
index 0000000000..9f0c9c39ac
--- /dev/null
+++ b/macros/luatex/latex/luahyphenrules/luahyphenrules.pdf
Binary files differ
diff --git a/macros/luatex/latex/luahyphenrules/luahyphenrules.sty b/macros/luatex/latex/luahyphenrules/luahyphenrules.sty
new file mode 100644
index 0000000000..244bf903c8
--- /dev/null
+++ b/macros/luatex/latex/luahyphenrules/luahyphenrules.sty
@@ -0,0 +1,161 @@
+% +--------------------------------------------------------+
+% | Typeset luahyphenrules.tex to get the documentation. |
+% +--------------------------------------------------------+
+%
+%% Copyright (C) 2016 Javier Bezos
+%% All Rights Reserved
+%% http://www.texnia.com
+%%
+%% This work may be distributed and/or modified under the conditions
+%% of the LaTeX Project Public License, either version 1.3 of this
+%% license or (at your option) any later version. The latest version
+%% of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% This Current Maintainer of this work is Javier Bezos.
+%%
+%% This work consists of the files luahyphenrules.tex and
+%% luahyphenrules.sty.
+\ProvidesPackage{luahyphenrules}
+ [2016/12/07 v1.0 language.dat reader lualatex]
+
+% The code below is essentially the same as in babel.dtx, with a few
+% minor changes. See the latter for further info.
+
+\begingroup
+ \toks@{}
+ \count@\z@ % 0=start, 1=0th, 2=normal
+ \def\bbl@process@line#1#2 #3 #4 {%
+ \ifx=#1%
+ \bbl@process@synonym{#2}%
+ \else
+ \bbl@process@language{#1#2}{#3}{#4}%
+ \fi
+ \ignorespaces}
+ \def\bbl@manylang{%
+ \ifnum\bbl@last>\@ne
+ \bbl@info{Non-standard hyphenation setup}%
+ \fi
+ \let\bbl@manylang\relax}
+ \def\bbl@process@language#1#2#3{%
+ \ifcase\count@
+ \@ifundefined{zth@#1}{\count@\tw@}{\count@\@ne}%
+ \or
+ \count@\tw@
+ \fi
+ \ifnum\count@=\tw@
+ \expandafter\addlanguage\csname l@#1\endcsname
+ \language\allocationnumber
+ \chardef\bbl@last\allocationnumber
+ \bbl@manylang
+ \let\bbl@elt\relax
+ \xdef\bbl@languages{%
+ \bbl@languages\bbl@elt{#1}{\the\language}{#2}{#3}}%
+ \fi
+ \the\toks@
+ \toks@{}}
+ \def\bbl@process@synonym@aux#1#2{%
+ \global\expandafter\chardef\csname l@#1\endcsname#2\relax
+ \let\bbl@elt\relax
+ \xdef\bbl@languages{%
+ \bbl@languages\bbl@elt{#1}{#2}{}{}}}%
+ \def\bbl@process@synonym#1{%
+ \ifcase\count@
+ \toks@\expandafter{\the\toks@\relax\bbl@process@synonym{#1}}%
+ \or
+ \@ifundefined{zth@#1}{\bbl@process@synonym@aux{#1}{0}}{}%
+ \else
+ \bbl@process@synonym@aux{#1}{\the\bbl@last}%
+ \fi}
+ \ifx\bbl@languages\@undefined % Just a (sensible?) guess
+ \chardef\l@english\z@
+ \chardef\l@USenglish\z@
+ \chardef\bbl@last\z@
+ \global\@namedef{bbl@hyphendata@0}{{hyphen.tex}{}}
+ \gdef\bbl@languages{%
+ \bbl@elt{english}{0}{hyphen.tex}{}%
+ \bbl@elt{USenglish}{0}{}{}}
+ \else
+ \def\bbl@elt#1#2#3#4{% Remove all except language 0
+ \ifnum#2>\z@\else
+ \noexpand\bbl@elt{#1}{#2}{#3}{#4}%
+ \fi}%
+ \xdef\bbl@languages{\bbl@languages}%
+ \fi
+ \def\bbl@elt#1#2#3#4{\@namedef{zth@#1}{}} % Define flags
+ \bbl@languages
+ \openin1=language.dat
+ \ifeof1
+ \PackageWarning{luahyphenrules}%
+ {I couldn't find language.dat. No additional\MessageBreak
+ patterns loaded. Reported}%
+ \else
+ \loop
+ \endlinechar\m@ne
+ \read1 to \bbl@line
+ \endlinechar`\^^M
+ \if T\ifeof1F\fi T\relax
+ \ifx\bbl@line\@empty\else
+ \edef\bbl@line{\bbl@line\space\space\space}%
+ \expandafter\bbl@process@line\bbl@line\relax
+ \fi
+ \repeat
+ \fi
+\endgroup
+
+\def\bbl@get@enc#1:#2:#3\@@@{\def\bbl@hyph@enc{#2}}
+
+\newcatcodetable\bbl@tempcattbl
+
+\def\bbl@luapatterns#1#2{%
+ \bbl@get@enc#1::\@@@
+ \setbox\z@\hbox\bgroup
+ \begingroup
+ \savecatcodetable\bbl@tempcattbl
+ \catcodetable\catcodetable@latex
+ \input #1\relax
+ \catcodetable\bbl@tempcattbl
+ \endgroup
+ \def\bbl@tempa{#2}%
+ \ifx\bbl@tempa\@empty\else
+ \input #2\relax
+ \fi
+ \egroup}%
+
+\newcommand\HyphenRules[1]{%
+ \language=\expandafter\ifx\csname l@#1:\f@encoding\endcsname\relax
+ \@ifundefined{l@#1}%
+ {\z@
+ \PackageError{luahyphenrules}%
+ {Unknown language `#1'. Either you have\MessageBreak
+ misspelled its name or language.dat doesn't define\MessageBreak
+ it. Words in this language won't be hyphenated.}%
+ {You may proceed, but expect wrong results}}%
+ {\csname l@#1\endcsname
+ \edef\bbl@tempa{#1}}%
+ \else
+ \csname l@#1:\f@encoding\endcsname
+ \edef\bbl@tempa{#1:\f@encoding}%
+ \fi\relax
+ \@ifundefined{bbl@hyphendata@\the\language}%
+ {\def\bbl@elt##1##2##3##4{% 1:name, 2:num, 3:pat-file, 4:exc-file
+ \ifnum##2=\csname l@\bbl@tempa\endcsname % tempa=spanish,dutch:OT1...
+ \def\bbl@tempb{##3}%
+ \ifx\bbl@tempb\@empty\else % if not a synonymous (if pat-file)
+ \def\bbl@tempc{{##3}{##4}}%
+ \fi
+ \expandafter\xdef\csname bbl@hyphendata@##2\endcsname{\bbl@tempc}%
+ \fi}%
+ \bbl@languages
+ \@ifundefined{bbl@hyphendata@\the\language}%
+ {\PackageInfo{luahyphenrules}%
+ {No hyphenation patterns were set for\MessageBreak
+ language ‘\bbl@tempa’. Reported}}%
+ {\expandafter\expandafter\expandafter\bbl@luapatterns
+ \csname bbl@hyphendata@\the\language\endcsname}}{}}
+
+\endinput \ No newline at end of file
diff --git a/macros/luatex/latex/luahyphenrules/luahyphenrules.tex b/macros/luatex/latex/luahyphenrules/luahyphenrules.tex
new file mode 100644
index 0000000000..d249d9d9ac
--- /dev/null
+++ b/macros/luatex/latex/luahyphenrules/luahyphenrules.tex
@@ -0,0 +1,114 @@
+% +--------------------------------------------------+
+% | Typeset this file to get the documentation. |
+% +--------------------------------------------------+
+%
+%% Copyright (C) 2016 Javier Bezos
+%% All Rights Reserved
+%% http://www.texnia.com
+%%
+%% This work may be distributed and/or modified under the conditions
+%% of the LaTeX Project Public License, either version 1.3 of this
+%% license or (at your option) any later version. The latest version
+%% of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% This Current Maintainer of this work is Javier Bezos.
+%%
+%% This work consists of the files luahyphenrules.tex and
+%% luahyphenrules.sty.
+\documentclass[a4paper]{ltxguide}
+
+\title{\textsf{luahyphenrules}\\\large Version 1.0}
+
+\author{Javier Bezos\\\texttt{http://www.texnia.com}}
+
+\date{2016-12-07}
+
+\raggedright
+\parskip=.8ex
+\advance\oddsidemargin-.7cm
+\advance\textwidth2cm
+\addtolength{\textheight}{3.5cm}
+\addtolength{\topmargin}{-2cm}
+
+\usepackage{xcolor,bera}
+
+\definecolor{notes}{rgb}{.75, .3, .3}%
+
+\makeatletter
+\def\@begintheorem#1#2{%
+ \list{}{}%
+ \global\advance\@listdepth\m@ne
+ \item[{\sffamily\bfseries\color{notes}\MakeUppercase{#1}}]}%
+\makeatother
+\newtheorem{warning}{Warning}
+\newtheorem{note}{Note}
+\newtheorem{example}{Example}
+
+\begin{document}
+
+\vspace*{1cm}
+{\fontsize{48}{48}\selectfont \color{notes}{luahyphenrules}\par}
+{\LARGE Loading patterns in \textsf{lualatex} with
+\texttt{language.dat}\par}
+\vspace*{1ex}
+Version 1.0 (2016-12-07)\par
+Javier Bezos (\texttt{http://www.texnia.com})
+
+\vspace*{6ex}
+
+Preloading hyphenation patterns (or ``hyphen rules'') into the format
+is not required in Lua\TeX. On the contrary, it is even discouraged
+and accordingly recent releases of \textsf{babel} don't do it. This file is
+addressed to those who just want to select the language and load their
+patterns without loading at all the \textsf{babel} package with
+|\usepackage|.
+
+When \textsf{luahyphenrules} is loaded, it reads |language.dat| and
+stores its data. Then, you can use the following command to select the
+language.
+
+\begin{decl}
+|\HyphenRules{<language-name>}|
+\end{decl}
+
+Here |<language-name>| is the name in |language.dat|. It select the
+language, if exists, and loads its hyphenations patterns if not done
+before. If the language does not exist or there are no patterns, it
+raises and error.
+
+\begin{note}
+ If you are using \textsf{babel} you do not need this package.
+\end{note}
+
+\begin{note}
+ Actually, loading hypenations patterns in Lua\TeX{} is so simple as
+ inputting the corresponding file with the correct catcode regime
+ when the language is active (which in turn may be created with
+ |\newlanguage|). This package is mostly about reading and
+ parsing |language.dat| at runtime.
+\end{note}
+
+\begin{note}
+ The internal variable |\bbl@languages|, containing the list of
+ languages in |language.dat|, is also set by this package. See the
+ \textsf{babel} manual for further info.
+\end{note}
+
+\begin{warning}
+ This package only works with Lua\LaTeX.
+\end{warning}
+
+
+\end{document}
+
+
+
+
+
+
+