summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/babel/bbunicode.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-02-09 22:23:21 +0000
committerKarl Berry <karl@freefriends.org>2016-02-09 22:23:21 +0000
commit986747ca8579ba0d0c3fb8167f943b89563234bc (patch)
tree7e2d3cefb2c0d417e6c9ec5189e12880f3643288 /Master/texmf-dist/source/latex/babel/bbunicode.dtx
parent4d30a4ce33e5b019dcdbdbfd4be5897406d7e7fa (diff)
babel (9feb16)
git-svn-id: svn://tug.org/texlive/trunk@39646 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/babel/bbunicode.dtx')
-rw-r--r--Master/texmf-dist/source/latex/babel/bbunicode.dtx130
1 files changed, 34 insertions, 96 deletions
diff --git a/Master/texmf-dist/source/latex/babel/bbunicode.dtx b/Master/texmf-dist/source/latex/babel/bbunicode.dtx
index e4365b9c1e6..02265c3108e 100644
--- a/Master/texmf-dist/source/latex/babel/bbunicode.dtx
+++ b/Master/texmf-dist/source/latex/babel/bbunicode.dtx
@@ -31,12 +31,12 @@
% \iffalse
%<*dtx>
\ProvidesFile{bbunicode.dtx}
- [2016/02/01 v1.1a Babel hooks for Unicode engines]
+ [2016/01/05 v1.0f Babel hooks for Unicode engines]
%</dtx>
%
%% File `bbunicode.dtx'
%% Babel package for LaTeX version 2e
-%% Copyright (C) 2103-2016
+%% Copyright (C) 2103-2014
%% by Javier Bezos
%
%<*filedriver>
@@ -179,15 +179,9 @@
% \end{macrocode}
% \subsection{LuaTeX}
%
-% The new loader for luatex is based solely on |language.dat|, which is
-% read on the fly. The code shouldn't be executed when the format is
-% build, so we check if |\bbl@get@enc| is defined. Then comes a
-% simplified version of the loader in |hyphen.cfg| (without the
-% hyphenmins stuff, which is under the direct control of \babel). A
-% language has been loaded if |bbl@hyphendata@<num>| exists. The names
-% |\l@<language>| are defined and take some value from the beginning
-% because all ldf files assume this for the corresponding language to be
-% considered valid. Of course, there is room for improvements.
+% This part relies on the |lua| stripts in \pkg{luatex-hyphen} by Khaled
+% Hosny, \'{E}lie Roux, and Manuel
+% P\'{e}gouri\'{e}-Gonnard. \'{E}lie also improved the code below.
% \changes{bbunicode~1.0b}{2013/04/22}{luatex-hyphen is loaded
% with require. Changes supplied by \'{E}lie Roux.}
% \changes{bbunicode~1.0c}{2014/03/10}{Defined hook for
@@ -199,81 +193,16 @@
% \cs{luaescapestring}}
% \changes{bbunicode~1.0e}{2015/07/26}{Added function addpatterns and
% modified the patterns hook.}
-% \changes{bbunicode~1.1a}{2016/01/26}{New hyphenation loader for luatex.}
%
% \begin{macrocode}
%<*luatex>
-\ifx\bbl@get@enc\@undefined
- \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@process@language#1#2#3{%
- \@ifundefined{l@#1}%
- {\expandafter\addlanguage\csname l@#1\endcsname
- \expandafter\language\csname l@#1\endcsname
- \let\bbl@elt\relax
- \edef\bbl@languages{%
- \bbl@languages\bbl@elt{#1}{\the\language}{#2}{#3}}}%
- {}}
- \def\bbl@process@synonym#1{%
- \@ifundefined{l@#1}%
- {\expandafter\chardef\csname l@#1\endcsname\last@language
- \let\bbl@elt\relax
- \edef\bbl@languages{%
- \bbl@languages\bbl@elt{#1}{\the\last@language}{}{}}}%
- {}}
- \ifnum\last@language>\z@
- \bbl@warning{Wrong or old hyphenation setup. Please, rebuild\\%
- the format. I'll try to fix it for this run.\\%
- Reported}%
- \def\bbl@elt#1#2#3#4{%
- \ifnum#2>\z@\else
- \noexpand\bbl@elt{#1}{#2}{#3}{#4}%
- \fi}%
- \edef\bbl@languages{\bbl@languages}%
- \fi
- \ifnum\l@english=\z@\else
- \bbl@warning{Wrong hyphenation setup. The 0th language must\\%
- be `english'. Reported}%
- \fi
- \@namedef{bbl@hyphendata@0}{{hyphen.tex}{}}%
- \openin1=language.dat
- \ifeof1
- \bbl@warning{I couldn't find language.dat. No additional\\%
- 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
- \def\bbl@get@enc#1:#2:#3\@@@{\def\bbl@hyph@enc{#2}}
- \def\bbl@luapatterns#1#2{%
- \bbl@get@enc#1::\@@@
- \begingroup
- \input #1\relax
- \endgroup
- \def\bbl@tempa{#2}%
- \ifx\bbl@tempa\@empty\else
- \input #2\relax
- \fi}%
-\fi
\begingroup
\catcode`\%=12
\catcode`\'=12
\catcode`\"=12
\catcode`\:=12
\directlua{
+ require("luatex-hyphen")
Babel = {}
function Babel.bytes(line)
return line:gsub("(.)",
@@ -335,23 +264,12 @@
\luabbl@stop
\let\luabbl@stop\relax}
\AddBabelHook{luatex}{patterns}{%
- \@ifundefined{bbl@hyphendata@\the\language}%
- {\def\bbl@elt##1##2##3##4{%
- \def\bbl@tempa{##1}%
- \def\bbl@tempb{##3}%
- \ifx\bbl@tempb\@empty\else % if not synonymous
- \def\bbl@tempc{{##3}{##4}}%
- \fi
- \def\bbl@tempb{#2}% eg, spanish, dutch:OT1, etc.
- \ifx\bbl@tempa\bbl@tempb
- \bbl@csarg\edef{hyphendata@##2}{\bbl@tempc}%
- \fi}%
- \bbl@languages
- \@ifundefined{bbl@hyphendata@\the\language}%
- {\bbl@info{No hyphenation patterns were set for\\%
- language ‘#2’. Reported}}%
- {\expandafter\expandafter\expandafter\bbl@luapatterns
- \csname bbl@hyphendata@\the\language\endcsname}}{}%
+ \ifcsname lu@texhyphen@loaded@\the\language\endcsname \else
+ \global\@namedef{lu@texhyphen@loaded@\the\language}{}%
+ \directlua{
+ luatexhyphen.loadlanguage([[\string#1]],
+ '\the\language')}%
+ \fi
\@ifundefined{bbl@patterns@}{}{%
\begingroup
\@expandtwoargs\in@{,\number\language,}{,\bbl@pttnlist}%
@@ -368,9 +286,29 @@
\xdef\bbl@pttnlist{\bbl@pttnlist\number\language,}%
\fi
\endgroup}}
+\AddBabelHook{luatex}{adddialect}{%
+ \ifx\directlua\relax\else
+ \directlua{
+ luatexhyphen.adddialect([[\string#1]],
+ [[\string#2]])
+ }%
+ \fi}
\AddBabelHook{luatex}{everylanguage}{%
- \def\process@language##1##2##3{%
- \def\process@line####1####2 ####3 ####4 {}}}
+ \directlua{
+ processnow = (tex.language == 0) or
+ (luatexhyphen.lookupname([[\string#1]]) == nil)}%
+ \ifnum0=\directlua{tex.sprint(processnow and "0" or "1")}\relax
+ \global\@namedef{lu@texhyphen@loaded@\the\language}{}%
+ \fi}
+\AddBabelHook{luatex}{loadpatterns}{%
+ \ifnum0=\directlua{tex.sprint(processnow and "0" or "1")}\relax
+ \input #1\relax
+ \fi}
+\AddBabelHook{luatex}{loadexceptions}{%
+ \ifnum0=\directlua{tex.sprint(processnow and "0" or "1")}\relax
+ \input #1\relax
+ \fi
+ \directlua{processnow = nil}}
% \end{macrocode}
%
% \begin{macro}{\babelpatterns}