Debian Codegraph @

texmf-dist/tex/lualatex/luainputenc/luainputenc.sty

raw
1 %%
2 %% This is file `luainputenc.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% luainputenc.dtx (with options: `package')
8 %% This is a generated file.
9 %%
10 %% Written in 2009, 2010 by Manuel Pegourie-Gonnard and Elie Roux.
11 %%
12 %% This work is under the CC0 license. As an exception, the files
13 %% luainputenc.sty, lutf8.def and lutf8x.def have more restrictions.
14 %% See these file for more details.
15 %%
16 %% People who helped on this package:
17 %% Javier Bezos
18 %% Will Robertson
19 %% Hans Hagen
20 %% Heiko Oberdiek
21 %% Javier Mugica
22 %%
23 %% This work consists of the main source file luainputenc.dtx
24 %% and the derived files
25 %% luainputenc.sty, luainputenc.lua, lutf8.def, lutf8x.def,
26 %% and luainputenc.pdf
27 %%
28
29 \NeedsTeXFormat{LaTeX2e}
30 \ProvidesPackage{luainputenc}
31 [2010/11/19 v0.973 inputenc package for LuaTeX]
32
33 %% This file was adapted from inputenc.sty, which copyright is:
34 %% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004
35 %% 2005 2006 The LaTeX3 Project.
36 %%
37 %% inputenc.sty is under the lppl version 1.3c or later, and can be
38 %% found in the base LaTeX system.
39 %%
40 %% The lppl can be found at http://www.latex-project.org/lppl.txt
41 %%
42 %% The changes to inputenc.sty are Copyright 2009 Elie Roux, and are
43 %% under the CC0 license.
44 %%
45 %% The changes are LuaTeX support.
46 %%
47 %% This file is distributed under the CC0 license, with clause 6 of the
48 %% lppl as additional restrictions.
49
50
51 \RequirePackage{ifluatex}
52 \RequirePackage{ifxetex}
53
54 \ifxetex
55 \DeclareOption{unactivate}{\PassOptionsToPackage{utf8}{xetex-inputenc}}
56 \DeclareOption{lutf8}{\PassOptionsToPackage{utf8}{xetex-inputenc}}
57 \DeclareOption{lutf8x}{\PassOptionsToPackage{utf8}{xetex-inputenc}}
58 \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{xetex-inputenc}}
59 \ProcessOptions*
60 \RequirePackage{xetex-inputenc}
61 \expandafter\endinput
62 \fi
63
64 \ifluatex\else
65 \DeclareOption{unactivate}{\PassOptionsToPackage{utf8}{inputenc}}
66 \DeclareOption{lutf8}{\PassOptionsToPackage{utf8}{inputenc}}
67 \DeclareOption{lutf8x}{\PassOptionsToPackage{utf8}{inputenc}}
68 \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{inputenc}}
69 \ProcessOptions*
70 \RequirePackage{inputenc}
71 \expandafter\endinput
72 \fi
73
74
75 \RequirePackage{luatexbase}
76 \luatexbase@ensure@primitive{luaescapestring}
77
78 \RequireLuaModule{luainputenc}
79
80
81 \def\DeclareInputMath#1{%
82 \@inpenc@test
83 \bgroup
84 \uccode`\~#1%
85 \uppercase{%
86 \egroup
87 \def~%
88 }%
89 }
90 \def\DeclareInputText#1#2{%
91 \def\reserved@a##1 ${}%
92 \def\reserved@b{#2}%
93 \ifcat_\expandafter\reserved@a\meaning\reserved@b$ $_%
94 \DeclareInputMath{#1}{#2}%
95 \else
96 \DeclareInputMath{#1}{\IeC{#2}}%
97 \fi
98 }
99 \def\IeC{%
100 \ifx\protect\@typeset@protect
101 \expandafter\@firstofone
102 \else
103 \noexpand\IeC
104 \fi
105 }
106
107 \def\inputencoding#1{%
108 \the\inpenc@prehook
109 \gdef\@inpenc@test{\global\let\@inpenc@test\relax}%
110 \edef\@inpenc@undefined{\noexpand\@inpenc@undefined@{#1}}%
111 \edef\inputencodingname{#1}%
112 \@inpenc@loop\^^A\^^H%
113 \@inpenc@loop\^^K\^^K%
114 \@inpenc@loop\^^N\^^_%
115 \xdef\saved@endlinechar{\the\endlinechar }%
116 \endlinechar=-1
117 \xdef\saved@space@catcode{\the\catcode`\ }%
118 \catcode`\ 9\relax
119 \input{#1.def}%
120 \endlinechar=\saved@endlinechar{}%
121 \catcode`\ \saved@space@catcode\relax
122 \ifx\@inpenc@test\relax\else
123 \PackageWarning{inputenc}%
124 {No characters defined\MessageBreak
125 by input encoding change to `#1'\MessageBreak}%
126 \fi
127 \the\inpenc@posthook
128 \luatexbase@directlua{luainputenc.set_option("\luatexluaescapestring{#1}")}
129 }
130 \newtoks\inpenc@prehook
131 \newtoks\inpenc@posthook
132 \def\@inpenc@undefined@#1{\PackageError{inputenc}%
133 {Keyboard character used is undefined\MessageBreak
134 in inputencoding `#1'}%
135 {You need to provide a definition with
136 \noexpand\DeclareInputText\MessageBreak or
137 \noexpand\DeclareInputMath before using this key.}}%
138 \def\@inpenc@loop#1#2{%
139 \@tempcnta`#1\relax
140 \loop
141 \catcode\@tempcnta\active
142 \bgroup
143 \uccode`\~\@tempcnta
144 \uppercase{%
145 \egroup
146 \let~\inpenc@undefined
147 }%
148 \ifnum\@tempcnta<`#2\relax
149 \advance\@tempcnta\@ne
150 \repeat}
151
152
153 \DeclareOption{utf8}{%
154 \inputencoding{lutf8}%
155 }
156
157 \DeclareOption{lutf8}{%
158 \inputencoding{lutf8}%
159 }
160
161 \DeclareOption{utf8x}{%
162 \inputencoding{lutf8}%
163 }
164
165 \DeclareOption{lutf8x}{%
166 \inputencoding{lutf8x}%
167 }
168
169
170 \DeclareOption{unactivate}{%
171 \edef\inputencodingname{unactivate}%
172 \luatexbase@directlua{luainputenc.set_option([[unactivate]])}
173 }
174
175
176 \DeclareOption*{%
177 \lIE@activate %
178 \@inpenc@loop\^^?\^^ff%
179 \inputencoding{\CurrentOption}%
180 }
181
182
183 \ifnum\luatexversion>42
184
185 \newcommand*{\lIE@activate}[0]{%
186 \luatexbase@directlua{luainputenc.register_callbacks()}%
187 }
188
189 \else
190
191
192 \newcommand*\lIE@setstarted[0]{%
193 \ifnum\lIE@activated=1 %
194 \luatexbase@directlua{luainputenc.setstarted()}%
195 \fi %
196 }
197
198 \newcommand*\lIE@setstopped[0]{%
199 \ifnum\lIE@activated=1 %
200 \luatexbase@directlua{luainputenc.setstopped()}%
201 \fi %
202 }
203
204
205 \newcommand*\lIE@SetUtfFile[1]{%
206 \luatexbase@directlua{luainputenc.set_unicode_file("\luatexluaescapestring{#1}")}%
207 }
208
209
210 \newcommand*\lIE@SetNonUtfFile[1]{%
211 \luatexbase@directlua{luainputenc.set_non_unicode_file("\luatexluaescapestring{#1}")}%
212 }
213
214
215 \newcommand*\lIE@UnsetFile[1]{%
216 \luatexbase@directlua{luainputenc.unset_file("\luatexluaescapestring{#1}")}%
217 }
218
219
220 \newcommand*\lIE@SetUtfExt[1]{%
221 \luatexbase@directlua{luainputenc.set_unicode_extention("\luatexluaescapestring{#1}")}%
222 }
223
224
225 \newcommand*\lIE@SetNonUtfExt[1]{
226 \luatexbase@directlua{luainputenc.set_non_unicode_extention("\luatexluaescapestring{#1}")}
227 }
228
229
230 \newcommand*\lIE@InputUtfFile[1]{%
231 \lIE@SetUtfFile{#1}%
232 \input #1%
233 \lIE@UnsetFile{#1}%
234 }
235
236
237 \newcommand*\lIE@InputNonUtfFile[1]{%
238 \lIE@SetNonUtfFile{#1}%
239 \input #1%
240 \lIE@UnsetFile{#1}%
241 }
242
243
244 \newcommand*\InputUtfFile[1]{%
245 \lIE@InputUtfFile{#1}%
246 }
247
248 \newcommand*\InputNonUtfFile[1]{%
249 \lIE@InputNonUtfFile{#1}%
250 }
251
252 \newcount\lIE@activated
253
254 \newcommand*{\lIE@activate}[0]{%
255 \lIE@activated=1 %
256 \lIE@setstarted %
257 }
258
259 \newcommand*{\lIE@FromInputenc}[1]{%
260 \ifnum\lIE@activated=0 %
261 \lIE@activate %
262 \fi%
263 }
264
265 \fi
266
267 \ProcessOptions*
268
269 \endinput
270 %%
271 %% End of file `luainputenc.sty'.