Debian Codegraph @

texmf-dist/tex/latex/luacolor/luacolor.sty

raw
1 %%
2 %% This is file `luacolor.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% luacolor.dtx (with options: `package')
8 %%
9 %% This is a generated file.
10 %%
11 %% Project: luacolor
12 %% Version: 2023-08-18 v1.18
13 %%
14 %% Copyright (C)
15 %% 2007, 2009-2011 Heiko Oberdiek
16 %% 2016-2023 Oberdiek Package Support Group
17 %%
18 %% This work may be distributed and/or modified under the
19 %% conditions of the LaTeX Project Public License, either
20 %% version 1.3c of this license or (at your option) any later
21 %% version. This version of this license is in
22 %% https://www.latex-project.org/lppl/lppl-1-3c.txt
23 %% and the latest version of this license is in
24 %% https://www.latex-project.org/lppl.txt
25 %% and version 1.3 or later is part of all distributions of
26 %% LaTeX version 2005/12/01 or later.
27 %%
28 %% This work has the LPPL maintenance status "maintained".
29 %%
30 %% The Current Maintainers of this work are
31 %% Heiko Oberdiek and the Oberdiek Package Support Group
32 %% https://github.com/ho-tex/luacolor/issues
33 %%
34 %% This work consists of the main source file luacolor.dtx
35 %% and the derived files
36 %% luacolor.sty, luacolor.pdf, luacolor.ins, luacolor.drv,
37 %% luacolor.lua,
38 %%
39 \begingroup\catcode61\catcode48\catcode32=10\relax%
40 \catcode13=5 % ^^M
41 \endlinechar=13 %
42 \catcode123=1 % {
43 \catcode125=2 % }
44 \catcode64=11 % @
45 \def\x{\endgroup
46 \expandafter\edef\csname LuaCol@AtEnd\endcsname{%
47 \endlinechar=\the\endlinechar\relax
48 \catcode13=\the\catcode13\relax
49 \catcode32=\the\catcode32\relax
50 \catcode35=\the\catcode35\relax
51 \catcode61=\the\catcode61\relax
52 \catcode64=\the\catcode64\relax
53 \catcode123=\the\catcode123\relax
54 \catcode125=\the\catcode125\relax
55 }%
56 }%
57 \x\catcode61\catcode48\catcode32=10\relax%
58 \catcode13=5 % ^^M
59 \endlinechar=13 %
60 \catcode35=6 % #
61 \catcode64=11 % @
62 \catcode123=1 % {
63 \catcode125=2 % }
64 \def\TMP@EnsureCode#1#2{%
65 \edef\LuaCol@AtEnd{%
66 \LuaCol@AtEnd
67 \catcode#1=\the\catcode#1\relax
68 }%
69 \catcode#1=#2\relax
70 }
71 \TMP@EnsureCode{34}{12}% "
72 \TMP@EnsureCode{39}{12}% '
73 \TMP@EnsureCode{40}{12}% (
74 \TMP@EnsureCode{41}{12}% )
75 \TMP@EnsureCode{42}{12}% *
76 \TMP@EnsureCode{43}{12}% +
77 \TMP@EnsureCode{44}{12}% ,
78 \TMP@EnsureCode{45}{12}% -
79 \TMP@EnsureCode{46}{12}% .
80 \TMP@EnsureCode{47}{12}% /
81 \TMP@EnsureCode{58}{12}% :
82 \TMP@EnsureCode{60}{12}% <
83 \TMP@EnsureCode{62}{12}% >
84 \TMP@EnsureCode{91}{12}% [
85 \TMP@EnsureCode{93}{12}% ]
86 \TMP@EnsureCode{95}{12}% _ (other!)
87 \TMP@EnsureCode{96}{12}% `
88 \edef\LuaCol@AtEnd{\LuaCol@AtEnd\noexpand\endinput}
89 \NeedsTeXFormat{LaTeX2e}
90 \ProvidesPackage{luacolor}%
91 [2023-08-18 v1.18 Color support via LuaTeX's attributes (HO)]
92 \RequirePackage{color}
93 \ifx\directlua\@undefined
94 \PackageError{luacolor}{%
95 This package may only be run using LuaTeX%
96 }\@ehc
97 \expandafter\LuaCol@AtEnd
98 \fi%
99 \ifcolors@
100 \else
101 \PackageWarningNoLine{luacolor}{%
102 Colors are disabled by option `monochrome'%
103 }%
104 \def\set@color{}%
105 \def\reset@color{}%
106 \def\set@page@color{}%
107 \def\define@color#1#2{}%
108 \expandafter\LuaCol@AtEnd
109 \fi%
110 \directlua{%
111 require("luacolor")%
112 }
113 \begingroup
114 \edef\x{\directlua{tex.write("2023-08-18 v1.18")}}%
115 \edef\y{%
116 \directlua{%
117 if oberdiek.luacolor.getversion then %
118 oberdiek.luacolor.getversion()%
119 end%
120 }%
121 }%
122 \ifx\x\y
123 \else
124 \PackageError{luacolor}{%
125 Wrong version of lua module.\MessageBreak
126 Package version: \x\MessageBreak
127 Lua module: \y
128 }\@ehc
129 \fi
130 \endgroup
131 \ifnum\outputmode=\@ne
132 \else
133 \begingroup
134 \def\current@color{}%
135 \def\reset@color{}%
136 \setbox\z@=\hbox{%
137 \begingroup
138 \set@color
139 \endgroup
140 }%
141 \edef\reserved@a{%
142 \directlua{%
143 oberdiek.luacolor.dvidetect()%
144 }%
145 }%
146 \ifx\reserved@a\@empty
147 \PackageError{luacolor}{%
148 DVI driver detection failed because of\MessageBreak
149 unrecognized color \string\special
150 }\@ehc
151 \endgroup
152 \expandafter\expandafter\expandafter\LuaCol@AtEnd
153 \else
154 \PackageInfo{luacolor}{%
155 Type of color \string\special: \reserved@a
156 \@gobble}%
157 \fi%
158 \endgroup
159 \fi
160 \newattribute\LuaCol@Attribute
161 \let\LuaCol@setattribute\setattribute
162 \directlua{%
163 oberdiek.luacolor.setattribute(\number\allocationnumber)%
164 }
165 \protected\def\set@color{%
166 \LuaCol@setattribute\LuaCol@Attribute{%
167 \directlua{%
168 oberdiek.luacolor.get("\luaescapestring{\current@color}")%
169 }%
170 }%
171 \aftergroup\reset@color
172 }
173 \def\reset@color{}
174 \def\luacolorProcessBox#1{%
175 \directlua{%
176 oberdiek.luacolor.process(\number#1)%
177 }%
178 }
179 \directlua{%
180 if luatexbase.callbacktypes.pre_shipout_filter then
181 token.get_next()
182 end
183 }\@secondoftwo\@gobble{
184 \RequirePackage{atbegshi}[2011/01/30]
185 \AtBeginShipout{%
186 \luacolorProcessBox\AtBeginShipoutBox
187 }
188 }
189 \set@color
190 \ifnum\outputmode=\@ne
191 \let\LuaCol@org@pdfxform\saveboxresource
192 \def\LuaCol@iii@i@ii#1#2#3{#3{#1}{#2}}
193 \def\LuaCol@ii@i#1#2{{#2#1}}
194 \def\LuaCol@if@keyword#1#2#3{%
195 \expanded{\unexpanded{\LuaCol@iii@i@ii{#2}{#3}}\expandafter}%
196 \directlua{%
197 token.put_next(token.create(token.scan_keyword(token.scan_string())
198 and '@firstoftwo'
199 or '@secondoftwo'))
200 }{#1}%
201 }
202 \def\LuaCol@scan@number{%
203 \directlua{
204 token.put_next(token.new(token.scan_int(), token.command_id'char_given'))
205 }%
206 }
207 \def\LuaCol@scan@tobrace{%
208 \directlua{
209 local relax, space = token.command_id'relax', token.command_id'spacer'
210 local t
211 repeat
212 t = token.scan_token()
213 until not (t.command == relax or t.command == space)
214 token.put_next(t)
215 }%
216 }
217 \def\LuaCol@scan@boxresource@i#1#2{%
218 \LuaCol@if@keyword{attr}{%
219 \expanded{\unexpanded{\LuaCol@scan@boxresource@iI{#1#2attr}}%
220 \expandafter\expandafter\expandafter}%
221 \LuaCol@scan@tobrace
222 }{%
223 \LuaCol@scan@boxresource@ii{#1#2}%
224 }%
225 }
226 \def\LuaCol@scan@boxresource@iI#1#2{\LuaCol@scan@boxresource@ii{#1{#2}}}
227 \def\LuaCol@scan@boxresource@ii#1{%
228 \LuaCol@if@keyword{resources}{%
229 \expanded{\unexpanded{\LuaCol@scan@boxresource@iiI{#1resources}}%
230 \expandafter\expandafter\expandafter}%
231 \LuaCol@scan@tobrace
232 }{%
233 \LuaCol@scan@boxresource@iii{#1}%
234 }%
235 }
236 \def\LuaCol@scan@boxresource@iiI#1#2{\LuaCol@scan@boxresource@iii{#1{#2}}}
237 \def\LuaCol@scan@boxresource@iii#1{%
238 \LuaCol@if@keyword{margin}{%
239 \expanded{\unexpanded{\LuaCol@scan@boxresource@iv{#1margin }}%
240 \expandafter\expandafter\expandafter}%
241 \LuaCol@scan@number
242 }{%
243 \LuaCol@scan@boxresource@iv{#1}{}%
244 }%
245 }
246 \def\LuaCol@scan@boxresource@iv#1#2{%
247 \expanded{\unexpanded{\LuaCol@scan@boxresource@v{#1#2}}%
248 \expandafter\expandafter\expandafter}%
249 \LuaCol@scan@number
250 }
251 \def\LuaCol@scan@boxresource@v#1#2{%
252 \luacolorProcessBox{#2}%
253 \LuaCol@org@pdfxform#1#2%
254 }
255
256 \protected\def\saveboxresource{%
257 \LuaCol@if@keyword{type}{%
258 \expandafter
259 \expanded{\unexpanded{\LuaCol@scan@boxresource@i{type }}%
260 \expandafter\expandafter\expandafter}%
261 \LuaCol@scan@number
262 }{%
263 \LuaCol@scan@boxresource@i{}{}%
264 }%
265 }
266 \let\pdfxform\saveboxresource
267 \fi
268 \LuaCol@AtEnd%
269 \endinput
270 %%
271 %% End of file `luacolor.sty'.