| 1 |
% +--------------------------------------------------------+ |
| 2 |
% | Typeset luahyphenrules.tex to get the documentation. | |
| 3 |
% +--------------------------------------------------------+ |
| 4 |
% |
| 5 |
%% Copyright (C) 2016-2020 Javier Bezos |
| 6 |
%% All Rights Reserved |
| 7 |
%% http://www.texnia.com |
| 8 |
%% |
| 9 |
%% This work may be distributed and/or modified under the conditions |
| 10 |
%% of the LaTeX Project Public License, either version 1.3 of this |
| 11 |
%% license or (at your option) any later version. The latest version |
| 12 |
%% of this license is in |
| 13 |
%% http://www.latex-project.org/lppl.txt |
| 14 |
%% and version 1.3 or later is part of all distributions of LaTeX |
| 15 |
%% version 2003/12/01 or later. |
| 16 |
%% |
| 17 |
%% This work has the LPPL maintenance status "maintained". |
| 18 |
%% |
| 19 |
%% This Current Maintainer of this work is Javier Bezos. |
| 20 |
%% |
| 21 |
%% This work consists of the files luahyphenrules.tex and |
| 22 |
%% luahyphenrules.sty. |
| 23 |
\ProvidesPackage{luahyphenrules} |
| 24 |
[2020/08/28 v1.1 language.dat reader lualatex] |
| 25 |
|
| 26 |
% The code below is essentially the same as in babel.dtx, with a few |
| 27 |
% minor changes. See the latter for further info. |
| 28 |
|
| 29 |
\begingroup |
| 30 |
\toks@{} |
| 31 |
\count@\z@ % 0=start, 1=0th, 2=normal |
| 32 |
\def\bbl@process@line#1#2 #3 #4 {% |
| 33 |
\ifx=#1% |
| 34 |
\bbl@process@synonym{#2}% |
| 35 |
\else |
| 36 |
\bbl@process@language{#1#2}{#3}{#4}% |
| 37 |
\fi |
| 38 |
\ignorespaces} |
| 39 |
\def\bbl@manylang{% |
| 40 |
\ifnum\bbl@last>\@ne |
| 41 |
\PackageInfo{luahyphenrules}{Non-standard hyphenation setup}% |
| 42 |
\fi |
| 43 |
\let\bbl@manylang\relax} |
| 44 |
\def\bbl@process@language#1#2#3{% |
| 45 |
\ifcase\count@ |
| 46 |
\@ifundefined{zth@#1}{\count@\tw@}{\count@\@ne}% |
| 47 |
\or |
| 48 |
\count@\tw@ |
| 49 |
\fi |
| 50 |
\ifnum\count@=\tw@ |
| 51 |
\expandafter\addlanguage\csname l@#1\endcsname |
| 52 |
\language\allocationnumber |
| 53 |
\chardef\bbl@last\allocationnumber |
| 54 |
\bbl@manylang |
| 55 |
\let\bbl@elt\relax |
| 56 |
\xdef\bbl@languages{% |
| 57 |
\bbl@languages\bbl@elt{#1}{\the\language}{#2}{#3}}% |
| 58 |
\fi |
| 59 |
\the\toks@ |
| 60 |
\toks@{}} |
| 61 |
\def\bbl@process@synonym@aux#1#2{% |
| 62 |
\global\expandafter\chardef\csname l@#1\endcsname#2\relax |
| 63 |
\let\bbl@elt\relax |
| 64 |
\xdef\bbl@languages{% |
| 65 |
\bbl@languages\bbl@elt{#1}{#2}{}{}}}% |
| 66 |
\def\bbl@process@synonym#1{% |
| 67 |
\ifcase\count@ |
| 68 |
\toks@\expandafter{\the\toks@\relax\bbl@process@synonym{#1}}% |
| 69 |
\or |
| 70 |
\@ifundefined{zth@#1}{\bbl@process@synonym@aux{#1}{0}}{}% |
| 71 |
\else |
| 72 |
\bbl@process@synonym@aux{#1}{\the\bbl@last}% |
| 73 |
\fi} |
| 74 |
\ifx\bbl@languages\@undefined % Just a (sensible?) guess |
| 75 |
\chardef\l@english\z@ |
| 76 |
\chardef\l@USenglish\z@ |
| 77 |
\chardef\bbl@last\z@ |
| 78 |
\global\@namedef{bbl@hyphendata@0}{{hyphen.tex}{}} |
| 79 |
\gdef\bbl@languages{% |
| 80 |
\bbl@elt{english}{0}{hyphen.tex}{}% |
| 81 |
\bbl@elt{USenglish}{0}{}{}} |
| 82 |
\else |
| 83 |
\def\bbl@elt#1#2#3#4{% Remove all except language 0 |
| 84 |
\ifnum#2>\z@\else |
| 85 |
\noexpand\bbl@elt{#1}{#2}{#3}{#4}% |
| 86 |
\fi}% |
| 87 |
\xdef\bbl@languages{\bbl@languages}% |
| 88 |
\fi |
| 89 |
\def\bbl@elt#1#2#3#4{\@namedef{zth@#1}{}} % Define flags |
| 90 |
\bbl@languages |
| 91 |
\openin1=language.dat |
| 92 |
\ifeof1 |
| 93 |
\PackageWarning{luahyphenrules}% |
| 94 |
{I couldn't find language.dat. No additional\MessageBreak |
| 95 |
patterns loaded. Reported}% |
| 96 |
\else |
| 97 |
\loop |
| 98 |
\endlinechar\m@ne |
| 99 |
\read1 to \bbl@line |
| 100 |
\endlinechar`\^^M |
| 101 |
\if T\ifeof1F\fi T\relax |
| 102 |
\ifx\bbl@line\@empty\else |
| 103 |
\edef\bbl@line{\bbl@line\space\space\space}% |
| 104 |
\expandafter\bbl@process@line\bbl@line\relax |
| 105 |
\fi |
| 106 |
\repeat |
| 107 |
\fi |
| 108 |
\endgroup |
| 109 |
|
| 110 |
\def\bbl@get@enc#1:#2:#3\@@@{\def\bbl@hyph@enc{#2}} |
| 111 |
|
| 112 |
\newcatcodetable\bbl@tempcattbl |
| 113 |
|
| 114 |
\def\bbl@luapatterns#1#2{% |
| 115 |
\bbl@get@enc#1::\@@@ |
| 116 |
\setbox\z@\hbox\bgroup |
| 117 |
\begingroup |
| 118 |
\savecatcodetable\bbl@tempcattbl |
| 119 |
\catcodetable\catcodetable@latex |
| 120 |
\input #1\relax |
| 121 |
\catcodetable\bbl@tempcattbl |
| 122 |
\endgroup |
| 123 |
\def\bbl@tempa{#2}% |
| 124 |
\ifx\bbl@tempa\@empty\else |
| 125 |
\input #2\relax |
| 126 |
\fi |
| 127 |
\egroup}% |
| 128 |
|
| 129 |
\newcommand\HyphenRules[1]{% |
| 130 |
\language=\expandafter\ifx\csname l@#1:\f@encoding\endcsname\relax |
| 131 |
\@ifundefined{l@#1}% |
| 132 |
{\z@ |
| 133 |
\PackageError{luahyphenrules}% |
| 134 |
{Unknown language `#1'. Either you have\MessageBreak |
| 135 |
misspelled its name or language.dat doesn't define\MessageBreak |
| 136 |
it. Words in this language won't be hyphenated.}% |
| 137 |
{You may proceed, but expect wrong results}}% |
| 138 |
{\csname l@#1\endcsname |
| 139 |
\edef\bbl@tempa{#1}}% |
| 140 |
\else |
| 141 |
\csname l@#1:\f@encoding\endcsname |
| 142 |
\edef\bbl@tempa{#1:\f@encoding}% |
| 143 |
\fi\relax |
| 144 |
\@ifundefined{bbl@hyphendata@\the\language}% |
| 145 |
{\def\bbl@elt##1##2##3##4{% 1:name, 2:num, 3:pat-file, 4:exc-file |
| 146 |
\ifnum##2=\csname l@\bbl@tempa\endcsname % tempa=spanish,dutch:OT1... |
| 147 |
\def\bbl@tempb{##3}% |
| 148 |
\ifx\bbl@tempb\@empty\else % if not a synonymous (if pat-file) |
| 149 |
\def\bbl@tempc{{##3}{##4}}% |
| 150 |
\fi |
| 151 |
\expandafter\xdef\csname bbl@hyphendata@##2\endcsname{\bbl@tempc}% |
| 152 |
\fi}% |
| 153 |
\bbl@languages |
| 154 |
\@ifundefined{bbl@hyphendata@\the\language}% |
| 155 |
{\PackageInfo{luahyphenrules}% |
| 156 |
{No hyphenation patterns were set for\MessageBreak |
| 157 |
language ‘\bbl@tempa’. Reported}}% |
| 158 |
{\expandafter\expandafter\expandafter\bbl@luapatterns |
| 159 |
\csname bbl@hyphendata@\the\language\endcsname}}{}} |
| 160 |
|
| 161 |
\endinput |