| 1 |
%% |
| 2 |
%% This is file `luamplib.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% luamplib.dtx (with options: `package') |
| 8 |
%% |
| 9 |
%% See source file 'luamplib.dtx' for licencing and contact information. |
| 10 |
%% |
| 11 |
\ifcsname ProvidesPackage\endcsname |
| 12 |
\NeedsTeXFormat{LaTeX2e} |
| 13 |
\ProvidesPackage{luamplib} |
| 14 |
[2026/05/26 v2.41.3 mplib package for LuaTeX] |
| 15 |
\fi |
| 16 |
\ifdefined\newluafunction\else |
| 17 |
\input ltluatex |
| 18 |
\fi |
| 19 |
\ifnum\outputmode=0 |
| 20 |
\ifdefined\AddToHookNext |
| 21 |
\def\luamplibatnextshipout{\AddToHookNext{shipout/background}} |
| 22 |
\def\luamplibatfirstshipout{\AddToHook{shipout/firstpage}} |
| 23 |
\def\luamplibateveryshipout{\AddToHook{shipout/background}} |
| 24 |
\else |
| 25 |
\input atbegshi.sty |
| 26 |
\def\luamplibatnextshipout#1{\AtBeginShipoutNext{\AtBeginShipoutAddToBox{#1}}} |
| 27 |
\let\luamplibatfirstshipout\AtBeginShipoutFirst |
| 28 |
\def\luamplibateveryshipout#1{\AtBeginShipout{\AtBeginShipoutAddToBox{#1}}} |
| 29 |
\fi |
| 30 |
\fi |
| 31 |
\directlua{require("luamplib")} |
| 32 |
\ifx\pdfoutput\undefined |
| 33 |
\let\pdfoutput\outputmode |
| 34 |
\fi |
| 35 |
\ifx\pdfliteral\undefined |
| 36 |
\protected\def\pdfliteral{\pdfextension literal} |
| 37 |
\fi |
| 38 |
\def\mplibsetformat#1{\directlua{luamplib.setformat("#1")}} |
| 39 |
\ifnum\pdfoutput>0 |
| 40 |
\let\mplibtoPDF\pdfliteral |
| 41 |
\else |
| 42 |
\def\mplibtoPDF#1{\special{pdf:literal direct #1}} |
| 43 |
\ifcsname PackageInfo\endcsname |
| 44 |
\PackageInfo{luamplib}{only dvipdfmx is supported currently} |
| 45 |
\else |
| 46 |
\immediate\write-1{luamplib Info: only dvipdfmx is supported currently} |
| 47 |
\fi |
| 48 |
\fi |
| 49 |
\def\mplibforcehmode{\let\prependtomplibbox\leavevmode} |
| 50 |
\def\mplibnoforcehmode{\let\prependtomplibbox\relax} |
| 51 |
\mplibnoforcehmode |
| 52 |
\def\mplibsetupcatcodes{% |
| 53 |
%catcode`\{=12 %catcode`\}=12 |
| 54 |
\catcode`\#=12 \catcode`\^=12 \catcode`\~=12 \catcode`\_=12 |
| 55 |
\catcode`\&=12 \catcode`\$=12 \catcode`\%=12 \catcode`\^^M=12 |
| 56 |
} |
| 57 |
\ifnum\outputmode>0 % |
| 58 |
\def\mplibputtextbox#1#2#3#4{% |
| 59 |
\pdfextension save\relax |
| 60 |
\vbox to 0pt{\vss |
| 61 |
\hbox bdir0 to 0pt{\kern#2bp\pdfextension setmatrix{#4}\raise\dp#1\copy#1\hss}% |
| 62 |
\kern#3bp}% |
| 63 |
\pdfextension restore\relax} |
| 64 |
\else |
| 65 |
\def\mplibputtextbox#1#2#3#4{% |
| 66 |
\special{pdf:btrans matrix #4 #2 #3}% |
| 67 |
\vbox to 0pt{\vss\hbox bdir0 to 0pt{\raise\dp#1\copy#1\hss}}% |
| 68 |
\special{pdf:etrans}} |
| 69 |
\fi |
| 70 |
\protected\def\usemplibgroup#1#{\usemplibgroupmain} |
| 71 |
\def\usemplibgroupmain#1{% |
| 72 |
\prependtomplibbox\hbox dir TLT\bgroup |
| 73 |
\csname luamplib.group.#1\endcsname |
| 74 |
\egroup |
| 75 |
} |
| 76 |
\protected\def\mplibgroup#1{% |
| 77 |
\begingroup |
| 78 |
\def\MPllx{0}\def\MPlly{0}% |
| 79 |
\def\mplibgroupname{#1}% |
| 80 |
\mplibgroupgetnexttok |
| 81 |
} |
| 82 |
\def\mplibgroupgetnexttok{\futurelet\nexttok\mplibgroupbranch} |
| 83 |
\def\mplibgroupskipspace{\afterassignment\mplibgroupgetnexttok\let\nexttok= } |
| 84 |
\def\mplibgroupbranch{% |
| 85 |
\ifx [\nexttok |
| 86 |
\expandafter\mplibgroupopts |
| 87 |
\else |
| 88 |
\ifx\mplibsptoken\nexttok |
| 89 |
\expandafter\expandafter\expandafter\mplibgroupskipspace |
| 90 |
\else |
| 91 |
\let\mplibgroupoptions\empty |
| 92 |
\expandafter\expandafter\expandafter\mplibgroupmain |
| 93 |
\fi |
| 94 |
\fi |
| 95 |
} |
| 96 |
\def\mplibgroupopts[#1]{\def\mplibgroupoptions{#1}\mplibgroupmain} |
| 97 |
\def\mplibgroupmain{\setbox\mplibscratchbox\hbox\bgroup\ignorespaces} |
| 98 |
\protected\def\endmplibgroup{\egroup |
| 99 |
\directlua{ luamplib.registergroup( |
| 100 |
\the\mplibscratchbox, '\mplibgroupname', {\mplibgroupoptions} |
| 101 |
)}% |
| 102 |
\endgroup |
| 103 |
} |
| 104 |
{\def\:{\global\let\mplibsptoken= } \: } |
| 105 |
\protected\def\mppattern#1{% |
| 106 |
\begingroup |
| 107 |
\def\MPllx{0}\def\MPlly{0}% |
| 108 |
\def\mplibpatternname{#1}% |
| 109 |
\mplibpatterngetnexttok |
| 110 |
} |
| 111 |
\def\mplibpatterngetnexttok{\futurelet\nexttok\mplibpatternbranch} |
| 112 |
\def\mplibpatternskipspace{\afterassignment\mplibpatterngetnexttok\let\nexttok= } |
| 113 |
\def\mplibpatternbranch{% |
| 114 |
\ifx [\nexttok |
| 115 |
\expandafter\mplibpatternopts |
| 116 |
\else |
| 117 |
\ifx\mplibsptoken\nexttok |
| 118 |
\expandafter\expandafter\expandafter\mplibpatternskipspace |
| 119 |
\else |
| 120 |
\let\mplibpatternoptions\empty |
| 121 |
\expandafter\expandafter\expandafter\mplibpatternmain |
| 122 |
\fi |
| 123 |
\fi |
| 124 |
} |
| 125 |
\def\mplibpatternopts[#1]{% |
| 126 |
\def\mplibpatternoptions{#1}% |
| 127 |
\mplibpatternmain |
| 128 |
} |
| 129 |
\def\mplibpatternmain{% |
| 130 |
\setbox\mplibscratchbox\hbox\bgroup\ignorespaces |
| 131 |
} |
| 132 |
\protected\def\endmppattern{% |
| 133 |
\egroup |
| 134 |
\directlua{ luamplib.registerpattern( |
| 135 |
\the\mplibscratchbox, '\mplibpatternname', {\mplibpatternoptions} |
| 136 |
)}% |
| 137 |
\endgroup |
| 138 |
} |
| 139 |
\def\mpfiginstancename{@mpfig} |
| 140 |
\protected\def\mpfig{% |
| 141 |
\begingroup |
| 142 |
\futurelet\nexttok\mplibmpfigbranch |
| 143 |
} |
| 144 |
\def\mplibmpfigbranch{% |
| 145 |
\ifx *\nexttok |
| 146 |
\expandafter\mplibprempfig |
| 147 |
\else |
| 148 |
\ifx [\nexttok |
| 149 |
\expandafter\expandafter\expandafter\mplibgobbleoptsmpfig |
| 150 |
\else |
| 151 |
\expandafter\expandafter\expandafter\mplibmainmpfig |
| 152 |
\fi |
| 153 |
\fi |
| 154 |
} |
| 155 |
\def\mplibgobbleoptsmpfig[#1]{\mplibmainmpfig} |
| 156 |
\def\mplibmainmpfig{% |
| 157 |
\begingroup |
| 158 |
\mplibsetupcatcodes |
| 159 |
\mplibdomainmpfig |
| 160 |
} |
| 161 |
\long\def\mplibdomainmpfig#1\endmpfig{% |
| 162 |
\endgroup |
| 163 |
\directlua{ |
| 164 |
local legacy = luamplib.legacyverbatimtex |
| 165 |
local everympfig = luamplib.everymplib["\mpfiginstancename"] or "" |
| 166 |
local everyendmpfig = luamplib.everyendmplib["\mpfiginstancename"] or "" |
| 167 |
luamplib.legacyverbatimtex = false |
| 168 |
luamplib.everymplib["\mpfiginstancename"] = "" |
| 169 |
luamplib.everyendmplib["\mpfiginstancename"] = "" |
| 170 |
luamplib.process_mplibcode( |
| 171 |
"beginfig(0) "..everympfig.." "..[===[\unexpanded{#1}]===].." "..everyendmpfig.." endfig;", |
| 172 |
"\mpfiginstancename") |
| 173 |
luamplib.legacyverbatimtex = legacy |
| 174 |
luamplib.everymplib["\mpfiginstancename"] = everympfig |
| 175 |
luamplib.everyendmplib["\mpfiginstancename"] = everyendmpfig |
| 176 |
}% |
| 177 |
\endgroup |
| 178 |
} |
| 179 |
\def\mplibprempfig#1{% |
| 180 |
\begingroup |
| 181 |
\mplibsetupcatcodes |
| 182 |
\mplibdoprempfig |
| 183 |
} |
| 184 |
\long\def\mplibdoprempfig#1\endmpfig{% |
| 185 |
\endgroup |
| 186 |
\directlua{ |
| 187 |
local legacy = luamplib.legacyverbatimtex |
| 188 |
local everympfig = luamplib.everymplib["\mpfiginstancename"] |
| 189 |
local everyendmpfig = luamplib.everyendmplib["\mpfiginstancename"] |
| 190 |
luamplib.legacyverbatimtex = false |
| 191 |
luamplib.everymplib["\mpfiginstancename"] = "" |
| 192 |
luamplib.everyendmplib["\mpfiginstancename"] = "" |
| 193 |
luamplib.process_mplibcode([===[\unexpanded{#1}]===],"\mpfiginstancename") |
| 194 |
luamplib.legacyverbatimtex = legacy |
| 195 |
luamplib.everymplib["\mpfiginstancename"] = everympfig |
| 196 |
luamplib.everyendmplib["\mpfiginstancename"] = everyendmpfig |
| 197 |
}% |
| 198 |
\endgroup |
| 199 |
} |
| 200 |
\protected\def\endmpfig{endmpfig} |
| 201 |
\unless\ifcsname [email protected]\endcsname |
| 202 |
\def\mplibcodegetinstancename[#1]{\xdef\currentmpinstancename{#1}\mplibcodeindeed} |
| 203 |
\protected\def\mplibcode{% |
| 204 |
\begingroup |
| 205 |
\futurelet\nexttok\mplibcodebranch |
| 206 |
} |
| 207 |
\def\mplibcodebranch{% |
| 208 |
\ifx [\nexttok |
| 209 |
\expandafter\mplibcodegetinstancename |
| 210 |
\else |
| 211 |
\global\let\currentmpinstancename\empty |
| 212 |
\expandafter\mplibcodeindeed |
| 213 |
\fi |
| 214 |
} |
| 215 |
\def\mplibcodeindeed{% |
| 216 |
\begingroup |
| 217 |
\mplibsetupcatcodes |
| 218 |
\mplibdocode |
| 219 |
} |
| 220 |
\long\def\mplibdocode#1\endmplibcode{% |
| 221 |
\endgroup |
| 222 |
\directlua{luamplib.process_mplibcode([===[\unexpanded{#1}]===],"\currentmpinstancename")}% |
| 223 |
\endgroup |
| 224 |
} |
| 225 |
\protected\def\endmplibcode{endmplibcode} |
| 226 |
\else |
| 227 |
\newenvironment{mplibcode}[1][]{% |
| 228 |
\xdef\currentmpinstancename{#1}% |
| 229 |
\mplibtmptoks{}\ltxdomplibcode |
| 230 |
}{} |
| 231 |
\def\ltxdomplibcode{% |
| 232 |
\begingroup |
| 233 |
\mplibsetupcatcodes |
| 234 |
\ltxdomplibcodeindeed |
| 235 |
} |
| 236 |
\def\mplib@mplibcode{mplibcode} |
| 237 |
\long\def\ltxdomplibcodeindeed#1\end#2{% |
| 238 |
\endgroup |
| 239 |
\mplibtmptoks\expandafter{\the\mplibtmptoks#1}% |
| 240 |
\def\mplibtemp@a{#2}% |
| 241 |
\ifx\mplib@mplibcode\mplibtemp@a |
| 242 |
\directlua{luamplib.process_mplibcode([===[\the\mplibtmptoks]===],"\currentmpinstancename")}% |
| 243 |
\end{mplibcode}% |
| 244 |
\else |
| 245 |
\mplibtmptoks\expandafter{\the\mplibtmptoks\end{#2}}% |
| 246 |
\expandafter\ltxdomplibcode |
| 247 |
\fi |
| 248 |
} |
| 249 |
\fi |
| 250 |
\def\mplibshowlog#1{\directlua{ |
| 251 |
local s = string.lower("#1") |
| 252 |
if s == "enable" or s == "true" or s == "yes" then |
| 253 |
luamplib.showlog = true |
| 254 |
else |
| 255 |
luamplib.showlog = false |
| 256 |
end |
| 257 |
}} |
| 258 |
\def\mpliblegacybehavior#1{\directlua{ |
| 259 |
local s = string.lower("#1") |
| 260 |
if s == "enable" or s == "true" or s == "yes" then |
| 261 |
luamplib.legacyverbatimtex = true |
| 262 |
else |
| 263 |
luamplib.legacyverbatimtex = false |
| 264 |
end |
| 265 |
}} |
| 266 |
\def\mplibverbatim#1{\directlua{ |
| 267 |
local s = string.lower("#1") |
| 268 |
if s == "enable" or s == "true" or s == "yes" then |
| 269 |
luamplib.verbatiminput = true |
| 270 |
else |
| 271 |
luamplib.verbatiminput = false |
| 272 |
end |
| 273 |
}} |
| 274 |
\newtoks\mplibtmptoks |
| 275 |
\ifcsname [email protected]\endcsname |
| 276 |
\protected\def\everymplib{% |
| 277 |
\begingroup |
| 278 |
\mplibsetupcatcodes |
| 279 |
\mplibdoeverymplib |
| 280 |
} |
| 281 |
\protected\def\everyendmplib{% |
| 282 |
\begingroup |
| 283 |
\mplibsetupcatcodes |
| 284 |
\mplibdoeveryendmplib |
| 285 |
} |
| 286 |
\newcommand\mplibdoeverymplib[2][]{% |
| 287 |
\endgroup |
| 288 |
\directlua{ |
| 289 |
luamplib.everymplib["#1"] = [===[\unexpanded{#2}]===] |
| 290 |
}% |
| 291 |
} |
| 292 |
\newcommand\mplibdoeveryendmplib[2][]{% |
| 293 |
\endgroup |
| 294 |
\directlua{ |
| 295 |
luamplib.everyendmplib["#1"] = [===[\unexpanded{#2}]===] |
| 296 |
}% |
| 297 |
} |
| 298 |
\else |
| 299 |
\def\mplibgetinstancename[#1]{\def\currentmpinstancename{#1}} |
| 300 |
\protected\def\everymplib#1#{% |
| 301 |
\ifx\empty#1\empty \mplibgetinstancename[]\else \mplibgetinstancename#1\fi |
| 302 |
\begingroup |
| 303 |
\mplibsetupcatcodes |
| 304 |
\mplibdoeverymplib |
| 305 |
} |
| 306 |
\long\def\mplibdoeverymplib#1{% |
| 307 |
\endgroup |
| 308 |
\directlua{ |
| 309 |
luamplib.everymplib["\currentmpinstancename"] = [===[\unexpanded{#1}]===] |
| 310 |
}% |
| 311 |
} |
| 312 |
\protected\def\everyendmplib#1#{% |
| 313 |
\ifx\empty#1\empty \mplibgetinstancename[]\else \mplibgetinstancename#1\fi |
| 314 |
\begingroup |
| 315 |
\mplibsetupcatcodes |
| 316 |
\mplibdoeveryendmplib |
| 317 |
} |
| 318 |
\long\def\mplibdoeveryendmplib#1{% |
| 319 |
\endgroup |
| 320 |
\directlua{ |
| 321 |
luamplib.everyendmplib["\currentmpinstancename"] = [===[\unexpanded{#1}]===] |
| 322 |
}% |
| 323 |
} |
| 324 |
\fi |
| 325 |
\def\mpdim#1{ runscript("luamplibdimen{#1}") } |
| 326 |
\def\mpcolor#1#{\domplibcolor{#1}} |
| 327 |
\def\domplibcolor#1#2{ runscript("luamplibcolor{#1{#2}}") } |
| 328 |
\def\mplibnumbersystem#1{\directlua{ |
| 329 |
local t = "#1" |
| 330 |
if t == "binary" then t = "decimal" end |
| 331 |
luamplib.numbersystem = t |
| 332 |
}} |
| 333 |
\def\mplibmakenocache#1{\mplibdomakenocache #1,\stop,} |
| 334 |
\def\mplibdomakenocache#1,{% |
| 335 |
\ifx\empty#1\empty |
| 336 |
\expandafter\mplibdomakenocache |
| 337 |
\else |
| 338 |
\ifx\stop#1\else |
| 339 |
\directlua{luamplib.noneedtoreplace["#1.mp"]=true}% |
| 340 |
\expandafter\expandafter\expandafter\mplibdomakenocache |
| 341 |
\fi |
| 342 |
\fi |
| 343 |
} |
| 344 |
\def\mplibcancelnocache#1{\mplibdocancelnocache #1,\stop,} |
| 345 |
\def\mplibdocancelnocache#1,{% |
| 346 |
\ifx\empty#1\empty |
| 347 |
\expandafter\mplibdocancelnocache |
| 348 |
\else |
| 349 |
\ifx\stop#1\else |
| 350 |
\directlua{luamplib.noneedtoreplace["#1.mp"]=false}% |
| 351 |
\expandafter\expandafter\expandafter\mplibdocancelnocache |
| 352 |
\fi |
| 353 |
\fi |
| 354 |
} |
| 355 |
\def\mplibcachedir#1{\directlua{luamplib.getcachedir("\unexpanded{#1}")}} |
| 356 |
\def\mplibtextextlabel#1{\directlua{ |
| 357 |
local s = string.lower("#1") |
| 358 |
if s == "enable" or s == "true" or s == "yes" then |
| 359 |
luamplib.textextlabel = true |
| 360 |
else |
| 361 |
luamplib.textextlabel = false |
| 362 |
end |
| 363 |
}} |
| 364 |
\def\mplibcodeinherit#1{\directlua{ |
| 365 |
local s = string.lower("#1") |
| 366 |
if s == "enable" or s == "true" or s == "yes" then |
| 367 |
luamplib.codeinherit = true |
| 368 |
else |
| 369 |
luamplib.codeinherit = false |
| 370 |
end |
| 371 |
}} |
| 372 |
\def\mplibglobaltextext#1{\directlua{ |
| 373 |
local s = string.lower("#1") |
| 374 |
if s == "enable" or s == "true" or s == "yes" then |
| 375 |
luamplib.globaltextext = true |
| 376 |
else |
| 377 |
luamplib.globaltextext = false |
| 378 |
end |
| 379 |
}} |
| 380 |
\ifx\mplibscratchbox\undefined \newbox\mplibscratchbox \fi |
| 381 |
\def\mplibstarttoPDF#1#2#3#4{% |
| 382 |
\prependtomplibbox |
| 383 |
\hbox dir TLT\bgroup |
| 384 |
\xdef\MPllx{#1}\xdef\MPlly{#2}% |
| 385 |
\xdef\MPurx{#3}\xdef\MPury{#4}% |
| 386 |
\xdef\MPwidth{\the\dimexpr#3bp-#1bp\relax}% |
| 387 |
\xdef\MPheight{\the\dimexpr#4bp-#2bp\relax}% |
| 388 |
\parskip0pt% |
| 389 |
\leftskip0pt% |
| 390 |
\parindent0pt% |
| 391 |
\everypar{}% |
| 392 |
\setbox\mplibscratchbox\vbox\bgroup |
| 393 |
\noindent |
| 394 |
} |
| 395 |
\def\mplibstoptoPDF{% |
| 396 |
\par |
| 397 |
\egroup % |
| 398 |
\setbox\mplibscratchbox\hbox % |
| 399 |
{\hskip-\MPllx bp% |
| 400 |
\raise-\MPlly bp% |
| 401 |
\box\mplibscratchbox}% |
| 402 |
\setbox\mplibscratchbox\vbox to \MPheight |
| 403 |
{\vfill |
| 404 |
\hsize\MPwidth |
| 405 |
\wd\mplibscratchbox0pt% |
| 406 |
\ht\mplibscratchbox0pt% |
| 407 |
\dp\mplibscratchbox0pt% |
| 408 |
\box\mplibscratchbox}% |
| 409 |
\wd\mplibscratchbox\MPwidth |
| 410 |
\ht\mplibscratchbox\MPheight |
| 411 |
\box\mplibscratchbox |
| 412 |
\egroup |
| 413 |
} |
| 414 |
\def\mplibtextext#1#2#3#4#5{% |
| 415 |
\begingroup |
| 416 |
\setbox\mplibscratchbox\hbox |
| 417 |
{\font\temp=#1 at #2bp% |
| 418 |
\temp |
| 419 |
#3}% |
| 420 |
\setbox\mplibscratchbox\hbox |
| 421 |
{\hskip#4 bp% |
| 422 |
\raise#5 bp% |
| 423 |
\box\mplibscratchbox}% |
| 424 |
\wd\mplibscratchbox0pt% |
| 425 |
\ht\mplibscratchbox0pt% |
| 426 |
\dp\mplibscratchbox0pt% |
| 427 |
\box\mplibscratchbox |
| 428 |
\endgroup |
| 429 |
} |
| 430 |
\openin0=luamplib.cfg |
| 431 |
\ifeof0 \else |
| 432 |
\closein0 |
| 433 |
\input luamplib.cfg |
| 434 |
\fi |
| 435 |
\def\luamplibtagtextboxset#1#2{#2} |
| 436 |
\let\luamplibnotagtextboxset\luamplibtagtextboxset |
| 437 |
\let\luamplibtagasgroupset\relax |
| 438 |
\let\luamplibtagasgroupput\luamplibtagtextboxset |
| 439 |
\ifcsname SuspendTagging\endcsname\else\endinput\fi |
| 440 |
\ifcsname [email protected]\endcsname \else |
| 441 |
\ExplSyntaxOn |
| 442 |
\keys_define:nn{luamplib/tagging} |
| 443 |
{ |
| 444 |
,alt .code:n = { } |
| 445 |
,actualtext .code:n = { } |
| 446 |
,artifact .code:n = { } |
| 447 |
,text .code:n = { } |
| 448 |
,off .code:n = { } |
| 449 |
,tag .code:n = { } |
| 450 |
,adjust-BBox .code:n = { } |
| 451 |
,tagging-setup .code:n = { } |
| 452 |
,instance .code:n = { \tl_gset:Nn \currentmpinstancename {#1} } |
| 453 |
,instancename .meta:n = { instance = {#1} } |
| 454 |
,unknown .code:n = { \tl_gset:NV \currentmpinstancename \l_keys_key_str } |
| 455 |
} |
| 456 |
\RenewDocumentCommand\mplibcode{O{}} |
| 457 |
{ |
| 458 |
\tl_gclear:N \currentmpinstancename |
| 459 |
\keys_set:ne{luamplib/tagging}{#1} |
| 460 |
\mplibtmptoks{}\ltxdomplibcode |
| 461 |
} |
| 462 |
\cs_set_eq:NN \mplibalttext \use_none:n |
| 463 |
\cs_set_eq:NN \mplibactualtext \use_none:n |
| 464 |
\tl_put_left:Nn \mplibstoptoPDF \@newlistfalse |
| 465 |
\ExplSyntaxOff |
| 466 |
\endinput\fi |
| 467 |
\ExplSyntaxOn |
| 468 |
\tl_new:N \l__luamplib_tag_envname_tl |
| 469 |
\tl_new:N \l__luamplib_tag_alt_tl |
| 470 |
\tl_new:N \l__luamplib_tag_alt_dflt_tl |
| 471 |
\tl_new:N \l__luamplib_tag_actual_tl |
| 472 |
\tl_new:N \l__luamplib_tag_struct_tl |
| 473 |
\tl_set:Nn\l__luamplib_tag_struct_tl {Figure} |
| 474 |
\bool_new:N \l__luamplib_tag_usetext_bool |
| 475 |
\bool_new:N \l__luamplib_tag_bboxcorr_bool |
| 476 |
\seq_new:N \l__luamplib_tag_bboxcorr_seq |
| 477 |
\tl_new:N \l__luamplib_tag_bbox_draw_tl |
| 478 |
\tl_new:N \l__luamplib_BBox_llx_tl |
| 479 |
\tl_new:N \l__luamplib_BBox_lly_tl |
| 480 |
\tl_new:N \l__luamplib_BBox_urx_tl |
| 481 |
\tl_new:N \l__luamplib_BBox_ury_tl |
| 482 |
\msg_new:nnn {luamplib}{figure-text-reuse} |
| 483 |
{ |
| 484 |
tex-text~box~#1~probably~is~incorrectly~tagged.~ |
| 485 |
Reusing~a~box~in~text~mode~is~strongly~discouraged.~ |
| 486 |
Check~the~resulting~PDF. |
| 487 |
} |
| 488 |
\msg_new:nnn {luamplib}{mplibgroup-text-mode} |
| 489 |
{ |
| 490 |
mplibgroup~'#1'~probably~is~incorrectly~tagged.~ |
| 491 |
Using~mplibgroup~with~text~mode~is~not~recommended.~ |
| 492 |
Check~the~resulting~PDF. |
| 493 |
} |
| 494 |
\msg_new:nnn{luamplib}{alt-text-missing} |
| 495 |
{ |
| 496 |
Alternate~text~for~#1~is~missing.~ |
| 497 |
Using~the~default~value~'#2'~instead. |
| 498 |
} |
| 499 |
\socket_new:nn{tagsupport/luamplib/textext/set}{2} |
| 500 |
\socket_new:nn{tagsupport/luamplib/textext/put}{2} |
| 501 |
\socket_new_plug:nnn{tagsupport/luamplib/textext/set}{default} |
| 502 |
{ |
| 503 |
\bool_if:NTF \l__luamplib_tag_usetext_bool |
| 504 |
{ |
| 505 |
\tag_mc_end_push: |
| 506 |
\tag_struct_begin:n{tag=NonStruct, stash, parent-tag=text} |
| 507 |
\cs_gset_nopar:cpe {luamplib.taggedbox.#1} {\tag_get:n{struct_num}} |
| 508 |
\tag_mc_begin:n{tag=text} |
| 509 |
#2 |
| 510 |
\tag_mc_end: |
| 511 |
\tag_struct_end: |
| 512 |
\tag_mc_begin_pop:n{} |
| 513 |
} |
| 514 |
{ |
| 515 |
\tag_suspend:n{\luamplibtagtextboxset} |
| 516 |
#2 |
| 517 |
\tag_resume:n{\luamplibtagtextboxset} |
| 518 |
} |
| 519 |
} |
| 520 |
\socket_new_plug:nnn{tagsupport/luamplib/textext/put}{default} |
| 521 |
{ |
| 522 |
\bool_lazy_and:nnTF |
| 523 |
{ \l__luamplib_tag_usetext_bool } |
| 524 |
{ \cs_if_free_p:c {luamplib.notaggedbox.#1} } |
| 525 |
{ |
| 526 |
\tag_resume:n{\mplibputtextbox} |
| 527 |
\tag_mc_end: |
| 528 |
\cs_if_exist:cTF {luamplib.taggedbox.#1} |
| 529 |
{ |
| 530 |
\exp_args:Nc \tag_struct_use_num:n {luamplib.taggedbox.#1} |
| 531 |
#2 |
| 532 |
\cs_undefine:c {luamplib.taggedbox.#1} |
| 533 |
} |
| 534 |
{ |
| 535 |
\msg_warning:nnn{luamplib}{figure-text-reuse}{#1} |
| 536 |
\tag_mc_begin:n{} |
| 537 |
\int_set:Nn \l_tmpa_int {#1} |
| 538 |
\tag_mc_reset_box:N \l_tmpa_int |
| 539 |
#2 |
| 540 |
\tag_mc_end: |
| 541 |
} |
| 542 |
\tag_mc_begin:n{artifact} |
| 543 |
} |
| 544 |
{ |
| 545 |
\int_set:Nn \l_tmpa_int {#1} |
| 546 |
\tag_mc_reset_box:N \l_tmpa_int |
| 547 |
#2 |
| 548 |
} |
| 549 |
} |
| 550 |
\socket_assign_plug:nn{tagsupport/luamplib/textext/set}{default} |
| 551 |
\socket_assign_plug:nn{tagsupport/luamplib/textext/put}{default} |
| 552 |
\cs_set_nopar:Npn \luamplibtagtextboxset |
| 553 |
{ |
| 554 |
\tag_socket_use:nnn{luamplib/textext/set} |
| 555 |
} |
| 556 |
\cs_set_nopar:Npn \luamplibnotagtextboxset #1 #2 |
| 557 |
{ |
| 558 |
\bool_set_eq:NN \l_tmpa_bool \l__luamplib_tag_usetext_bool |
| 559 |
\bool_set_false:N \l__luamplib_tag_usetext_bool |
| 560 |
\tag_socket_use:nnn{luamplib/textext/set}{#1}{#2} |
| 561 |
\cs_gset_nopar:cpn {luamplib.notaggedbox.#1}{#1} |
| 562 |
\bool_set_eq:NN \l__luamplib_tag_usetext_bool \l_tmpa_bool |
| 563 |
} |
| 564 |
\sys_if_output_pdf:TF |
| 565 |
{ |
| 566 |
\cs_set_nopar:Npn \mplibputtextbox #1 #2 #3 #4 |
| 567 |
{ |
| 568 |
\pdfextension save\relax |
| 569 |
\vbox to 0pt{\vss |
| 570 |
\hbox bdir0 to 0pt{\kern #2bp \pdfextension setmatrix {#4} |
| 571 |
\socket_use:nnn{tagsupport/luamplib/textext/put}{#1}{\raise\dp#1\copy#1}\hss} |
| 572 |
\kern #3bp} |
| 573 |
\pdfextension restore\relax |
| 574 |
} |
| 575 |
} |
| 576 |
{ |
| 577 |
\cs_set_nopar:Npn \mplibputtextbox #1 #2 #3 #4 |
| 578 |
{ |
| 579 |
\special{pdf:btrans~matrix~#4~#2~#3} |
| 580 |
\vbox to 0pt{\vss\hbox bdir0 to 0pt{ |
| 581 |
\socket_use:nnn{tagsupport/luamplib/textext/put}{#1}{\raise\dp#1\copy#1}\hss}} |
| 582 |
\special{pdf:etrans} |
| 583 |
} |
| 584 |
} |
| 585 |
\cs_set_nopar:Npn \luamplibtagasgroupset |
| 586 |
{ |
| 587 |
\bool_set_false:N \l__luamplib_tag_usetext_bool |
| 588 |
} |
| 589 |
\cs_set_nopar:Npn \luamplibtagasgroupput |
| 590 |
{ |
| 591 |
\bool_if:NT \l__luamplib_tag_usetext_bool { \tag_resume:n{\luamplibtagasgroupput} } |
| 592 |
\tag_socket_use:nnn{luamplib/mplibgroup/put} |
| 593 |
} |
| 594 |
\socket_new:nn{tagsupport/luamplib/mplibgroup/put}{2} |
| 595 |
\socket_new_plug:nnn{tagsupport/luamplib/mplibgroup/put}{default} |
| 596 |
{ |
| 597 |
\cs_if_free:cT {luamplib.mplibgroup.text.#1} |
| 598 |
{ |
| 599 |
\msg_warning:nnn {luamplib} {mplibgroup-text-mode} {#1} |
| 600 |
\cs_gset_nopar:cpn {luamplib.mplibgroup.text.#1} {#1} |
| 601 |
} |
| 602 |
\tag_mc_end: |
| 603 |
\tag_mc_begin:n{tag=text} |
| 604 |
#2 |
| 605 |
\tag_mc_end: |
| 606 |
\tag_mc_begin:n{artifact} |
| 607 |
} |
| 608 |
\socket_assign_plug:nn{tagsupport/luamplib/mplibgroup/put}{default} |
| 609 |
\cs_set_nopar:Npn \__luamplib_tag_bbox_attribute:n #1 |
| 610 |
{ |
| 611 |
\tl_set:Ne \l_tmpa_tl {luamplib.BBox.\tag_get:n{struct_num}} |
| 612 |
\tex_savepos:D |
| 613 |
\property_record:ee{\l_tmpa_tl}{xpos,ypos} |
| 614 |
\tl_set:Ne \l__luamplib_BBox_llx_tl |
| 615 |
{ \dim_to_decimal_in_bp:n { \property_ref:een {\l_tmpa_tl}{xpos}{0}sp } } |
| 616 |
\tl_set:Ne \l__luamplib_BBox_lly_tl |
| 617 |
{ \dim_to_decimal_in_bp:n { \property_ref:een {\l_tmpa_tl}{ypos}{0}sp - \dp#1 } } |
| 618 |
\tl_set:Ne \l__luamplib_BBox_urx_tl |
| 619 |
{ \dim_to_decimal_in_bp:n { \l__luamplib_BBox_llx_tl bp + \wd#1 } } |
| 620 |
\tl_set:Ne \l__luamplib_BBox_ury_tl |
| 621 |
{ \dim_to_decimal_in_bp:n { \l__luamplib_BBox_lly_tl bp + \ht#1 + \dp#1 } } |
| 622 |
\bool_if:NT \l__luamplib_tag_bboxcorr_bool |
| 623 |
{ |
| 624 |
\int_zero:N \l_tmpa_int |
| 625 |
\tl_map_inline:nn |
| 626 |
{ |
| 627 |
\l__luamplib_BBox_llx_tl |
| 628 |
\l__luamplib_BBox_lly_tl |
| 629 |
\l__luamplib_BBox_urx_tl |
| 630 |
\l__luamplib_BBox_ury_tl |
| 631 |
} |
| 632 |
{ |
| 633 |
\int_incr:N \l_tmpa_int |
| 634 |
\tl_set:Ne ##1 |
| 635 |
{ |
| 636 |
\fp_eval:n |
| 637 |
{ |
| 638 |
##1 |
| 639 |
+ |
| 640 |
\dim_to_decimal_in_bp:n { \seq_item:NV \l__luamplib_tag_bboxcorr_seq \l_tmpa_int } |
| 641 |
} |
| 642 |
} |
| 643 |
} |
| 644 |
} |
| 645 |
\tag_struct_gput:ene {\tag_get:n{struct_num}} {attribute} |
| 646 |
{ |
| 647 |
/O /Layout /BBox [ |
| 648 |
\l__luamplib_BBox_llx_tl\c_space_tl |
| 649 |
\l__luamplib_BBox_lly_tl\c_space_tl |
| 650 |
\l__luamplib_BBox_urx_tl\c_space_tl |
| 651 |
\l__luamplib_BBox_ury_tl |
| 652 |
] |
| 653 |
} |
| 654 |
\bool_if:NT \l__tag_graphic_debug_bool |
| 655 |
{ |
| 656 |
\iow_log:e |
| 657 |
{ |
| 658 |
luamplib/tagging~debug:~BBox~of~structure~\tag_get:n{struct_num}~is~ |
| 659 |
\l__luamplib_BBox_llx_tl\c_space_tl |
| 660 |
\l__luamplib_BBox_lly_tl\c_space_tl |
| 661 |
\l__luamplib_BBox_urx_tl\c_space_tl |
| 662 |
\l__luamplib_BBox_ury_tl |
| 663 |
} |
| 664 |
\sys_if_output_pdf:TF |
| 665 |
{ |
| 666 |
\tl_set:Ne \l__luamplib_tag_bbox_draw_tl |
| 667 |
{ |
| 668 |
\pdfextension save\relax |
| 669 |
\opacity_select:n{0.5} \color_select:n{red} |
| 670 |
\pdfextension literal~text |
| 671 |
{ |
| 672 |
\l__luamplib_BBox_llx_tl\c_space_tl |
| 673 |
\l__luamplib_BBox_lly_tl\c_space_tl |
| 674 |
\fp_eval:n { \l__luamplib_BBox_urx_tl - \l__luamplib_BBox_llx_tl }~ |
| 675 |
\fp_eval:n { \l__luamplib_BBox_ury_tl - \l__luamplib_BBox_lly_tl }~ |
| 676 |
re~f |
| 677 |
} |
| 678 |
\pdfextension restore\relax |
| 679 |
} |
| 680 |
} |
| 681 |
{ |
| 682 |
\tl_set:Ne \l__luamplib_tag_bbox_draw_tl |
| 683 |
{ |
| 684 |
\special{pdf:bcontent} |
| 685 |
\opacity_select:n{0.5} \color_select:n{red} |
| 686 |
\special{pdf:code~ |
| 687 |
1~0~0~1~ |
| 688 |
-\dim_to_decimal_in_bp:n { \property_ref:een{\l_tmpa_tl}{xpos}{0}sp + \wd#1 }~ |
| 689 |
-\dim_to_decimal_in_bp:n { \property_ref:een{\l_tmpa_tl}{ypos}{0}sp }~ |
| 690 |
cm |
| 691 |
} |
| 692 |
\special{pdf:code~ |
| 693 |
\l__luamplib_BBox_llx_tl\c_space_tl |
| 694 |
\l__luamplib_BBox_lly_tl\c_space_tl |
| 695 |
\fp_eval:n { \l__luamplib_BBox_urx_tl - \l__luamplib_BBox_llx_tl }~ |
| 696 |
\fp_eval:n { \l__luamplib_BBox_ury_tl - \l__luamplib_BBox_lly_tl }~ |
| 697 |
re~f |
| 698 |
} |
| 699 |
\special{pdf:econtent} |
| 700 |
} |
| 701 |
} |
| 702 |
} |
| 703 |
} |
| 704 |
\socket_new:nn{tagsupport/luamplib/figure/begin}{1} |
| 705 |
\socket_new:nn{tagsupport/luamplib/figure/end}{2} |
| 706 |
\socket_new_plug:nnn{tagsupport/luamplib/figure/end}{transparent}{#2} |
| 707 |
\socket_new_plug:nnn{tagsupport/luamplib/figure/begin}{alt} |
| 708 |
{ |
| 709 |
\tag_mc_end_push: |
| 710 |
\tl_if_empty:NT\l__luamplib_tag_alt_tl |
| 711 |
{ |
| 712 |
\tl_if_empty:eTF{#1} |
| 713 |
{ \tl_set:Nn \l__luamplib_tag_alt_tl {metapost~figure} } |
| 714 |
{ \tl_set:Ne \l__luamplib_tag_alt_tl {metapost~figure~\text_purify:n{#1}} } |
| 715 |
\msg_warning:nnVV{luamplib}{alt-text-missing} |
| 716 |
\l__luamplib_tag_envname_tl \l__luamplib_tag_alt_tl |
| 717 |
} |
| 718 |
\tag_struct_begin:n |
| 719 |
{ |
| 720 |
tag=\l__luamplib_tag_struct_tl, |
| 721 |
alt=\l__luamplib_tag_alt_tl, |
| 722 |
} |
| 723 |
\tag_mc_begin:n{} |
| 724 |
} |
| 725 |
\socket_new_plug:nnn{tagsupport/luamplib/figure/end}{alt} |
| 726 |
{ |
| 727 |
\__luamplib_tag_bbox_attribute:n {#1} |
| 728 |
#2 |
| 729 |
\tl_use:N \l__luamplib_tag_bbox_draw_tl |
| 730 |
\tag_mc_end: |
| 731 |
\tag_struct_end: |
| 732 |
\tag_mc_begin_pop:n{} |
| 733 |
} |
| 734 |
\socket_new_plug:nnn{tagsupport/luamplib/figure/begin}{actualtext} |
| 735 |
{ |
| 736 |
\tag_mc_end_push: |
| 737 |
\tag_struct_begin:n |
| 738 |
{ |
| 739 |
tag=Span, |
| 740 |
actualtext=\l__luamplib_tag_actual_tl, |
| 741 |
} |
| 742 |
\tag_mc_begin:n{} |
| 743 |
} |
| 744 |
\socket_new_plug:nnn{tagsupport/luamplib/figure/end}{actualtext} |
| 745 |
{ |
| 746 |
#2 |
| 747 |
\tag_mc_end: |
| 748 |
\tag_struct_end: |
| 749 |
\tag_mc_begin_pop:n{} |
| 750 |
} |
| 751 |
\socket_new_plug:nnn{tagsupport/luamplib/figure/begin}{artifact} |
| 752 |
{ |
| 753 |
\tag_mc_end_push: |
| 754 |
\tag_mc_begin:n{artifact} |
| 755 |
} |
| 756 |
\socket_new_plug:nnn{tagsupport/luamplib/figure/end}{artifact} |
| 757 |
{ |
| 758 |
#2 |
| 759 |
\tag_mc_end: |
| 760 |
\tag_mc_begin_pop:n{} |
| 761 |
} |
| 762 |
\socket_new:nn{tagsupport/luamplib/figure/init}{0} |
| 763 |
\socket_new_plug:nnn{tagsupport/luamplib/figure/init}{alt} |
| 764 |
{ |
| 765 |
\socket_assign_plug:nn{tagsupport/luamplib/figure/begin}{alt} |
| 766 |
\socket_assign_plug:nn{tagsupport/luamplib/figure/end}{alt} |
| 767 |
} |
| 768 |
\socket_new_plug:nnn{tagsupport/luamplib/figure/init}{actualtext} |
| 769 |
{ |
| 770 |
\socket_assign_plug:nn{tagsupport/luamplib/figure/begin}{actualtext} |
| 771 |
\socket_assign_plug:nn{tagsupport/luamplib/figure/end}{actualtext} |
| 772 |
\prependtomplibbox \mplibnoforcehmode |
| 773 |
\mode_if_vertical:T { \noindent \aftergroup\par } |
| 774 |
} |
| 775 |
\socket_new_plug:nnn{tagsupport/luamplib/figure/init}{artifact} |
| 776 |
{ |
| 777 |
\socket_assign_plug:nn{tagsupport/luamplib/figure/begin}{artifact} |
| 778 |
\socket_assign_plug:nn{tagsupport/luamplib/figure/end}{artifact} |
| 779 |
} |
| 780 |
\socket_new_plug:nnn{tagsupport/luamplib/figure/init}{text} |
| 781 |
{ |
| 782 |
\bool_set_true:N \l__luamplib_tag_usetext_bool |
| 783 |
\socket_assign_plug:nn{tagsupport/luamplib/figure/begin}{artifact} |
| 784 |
\socket_assign_plug:nn{tagsupport/luamplib/figure/end}{artifact} |
| 785 |
\prependtomplibbox \mplibnoforcehmode |
| 786 |
\mode_if_vertical:T { \noindent \aftergroup\par } |
| 787 |
} |
| 788 |
\socket_new_plug:nnn{tagsupport/luamplib/figure/init}{off} |
| 789 |
{ |
| 790 |
\socket_assign_plug:nn{tagsupport/luamplib/figure/begin}{noop} |
| 791 |
\socket_assign_plug:nn{tagsupport/luamplib/figure/end}{transparent} |
| 792 |
} |
| 793 |
\socket_assign_plug:nn{tagsupport/luamplib/figure/init}{alt} |
| 794 |
\keys_define:nn{luamplib/tagging} |
| 795 |
{ |
| 796 |
,alt .code:n = |
| 797 |
{ |
| 798 |
\tl_set:Ne\l__luamplib_tag_alt_tl{\text_purify:n{#1}} |
| 799 |
\socket_assign_plug:nn{tagsupport/luamplib/figure/init}{alt} |
| 800 |
} |
| 801 |
,actualtext .code:n = |
| 802 |
{ |
| 803 |
\tl_set:Ne\l__luamplib_tag_actual_tl{\text_purify:n{#1}} |
| 804 |
\socket_assign_plug:nn{tagsupport/luamplib/figure/init}{actualtext} |
| 805 |
} |
| 806 |
,artifact .code:n = { \socket_assign_plug:nn{tagsupport/luamplib/figure/init}{artifact} } |
| 807 |
,text .code:n = { \socket_assign_plug:nn{tagsupport/luamplib/figure/init}{text} } |
| 808 |
,off .code:n = { \socket_assign_plug:nn{tagsupport/luamplib/figure/init}{off} } |
| 809 |
,tag .code:n = |
| 810 |
{ |
| 811 |
\str_case:nnF {#1} |
| 812 |
{ |
| 813 |
{false} { \keys_set:nn {luamplib/tagging} {off} } |
| 814 |
{artifact} { \keys_set:nn {luamplib/tagging} {artifact} } |
| 815 |
} |
| 816 |
{ |
| 817 |
\tl_set:Nn\l__luamplib_tag_struct_tl{#1} |
| 818 |
\socket_assign_plug:nn{tagsupport/luamplib/figure/init}{alt} |
| 819 |
} |
| 820 |
} |
| 821 |
,adjust-BBox .code:n = |
| 822 |
{ |
| 823 |
\bool_set_true:N \l__luamplib_tag_bboxcorr_bool |
| 824 |
\seq_set_split:Nnn \l__luamplib_tag_bboxcorr_seq{~}{#1~0pt~0pt~0pt~0pt} |
| 825 |
} |
| 826 |
,tagging-setup .code:n = { \keys_set_known:nn {luamplib/tagging} {#1} } |
| 827 |
} |
| 828 |
\keys_define:nn {luamplib/instance} |
| 829 |
{ |
| 830 |
,instance .code:n = { \tl_gset:Nn \currentmpinstancename {#1} } |
| 831 |
,instancename .meta:n = { instance = {#1} } |
| 832 |
,unknown .code:n = { \tl_gset:NV \currentmpinstancename \l_keys_key_str } |
| 833 |
} |
| 834 |
\cs_set_nopar:Npn \mplibstarttoPDF #1 #2 #3 #4 |
| 835 |
{ |
| 836 |
\prependtomplibbox |
| 837 |
\hbox dir~TLT\bgroup |
| 838 |
\tag_socket_use:nn{luamplib/figure/begin}\l__luamplib_tag_alt_dflt_tl |
| 839 |
\xdef\MPllx{#1}\xdef\MPlly{#2}% |
| 840 |
\xdef\MPurx{#3}\xdef\MPury{#4}% |
| 841 |
\xdef\MPwidth{\the\dimexpr#3bp-#1bp\relax}% |
| 842 |
\xdef\MPheight{\the\dimexpr#4bp-#2bp\relax}% |
| 843 |
\parskip0pt |
| 844 |
\leftskip0pt |
| 845 |
\parindent0pt |
| 846 |
\everypar{}% |
| 847 |
\setbox\mplibscratchbox\vbox\bgroup |
| 848 |
\tag_suspend:n{\mplibstarttoPDF} |
| 849 |
\noindent |
| 850 |
} |
| 851 |
\cs_set_nopar:Npn \mplibstoptoPDF |
| 852 |
{ |
| 853 |
\par |
| 854 |
\egroup |
| 855 |
\setbox\mplibscratchbox\hbox |
| 856 |
{\hskip-\MPllx bp |
| 857 |
\raise-\MPlly bp |
| 858 |
\box\mplibscratchbox}% |
| 859 |
\setbox\mplibscratchbox\vbox to \MPheight |
| 860 |
{\vfill |
| 861 |
\hsize\MPwidth |
| 862 |
\wd\mplibscratchbox0pt |
| 863 |
\ht\mplibscratchbox0pt |
| 864 |
\dp\mplibscratchbox0pt |
| 865 |
\box\mplibscratchbox}% |
| 866 |
\wd\mplibscratchbox\MPwidth |
| 867 |
\ht\mplibscratchbox\MPheight |
| 868 |
\tag_socket_use:nnn{luamplib/figure/end}{\mplibscratchbox}{\box\mplibscratchbox} |
| 869 |
\egroup |
| 870 |
} |
| 871 |
\RenewDocumentCommand\mplibcode{O{}} |
| 872 |
{ |
| 873 |
\tl_set:Nn \l__luamplib_tag_envname_tl {mplibcode} |
| 874 |
\tl_gclear:N \currentmpinstancename |
| 875 |
\keys_set_known:neN {luamplib/tagging} {#1} \l_tmpa_tl |
| 876 |
\keys_set:nV {luamplib/instance} \l_tmpa_tl |
| 877 |
\tl_set_eq:NN \l__luamplib_tag_alt_dflt_tl \currentmpinstancename |
| 878 |
\tag_socket_use:n{luamplib/figure/init} |
| 879 |
\mplibtmptoks{}\ltxdomplibcode |
| 880 |
} |
| 881 |
\RenewDocumentCommand\mpfig{s O{}} |
| 882 |
{ |
| 883 |
\begingroup |
| 884 |
\tl_set:Nn \l__luamplib_tag_envname_tl {mpfig} |
| 885 |
\keys_set_known:ne {luamplib/tagging} {#2} |
| 886 |
\tl_set_eq:NN \l__luamplib_tag_alt_dflt_tl \mpfiginstancename |
| 887 |
\tag_socket_use:n{luamplib/figure/init} |
| 888 |
\IfBooleanTF{#1} { \mplibprempfig * } |
| 889 |
{ \mplibmainmpfig } |
| 890 |
} |
| 891 |
\RenewDocumentCommand\usemplibgroup{O{} m} |
| 892 |
{ |
| 893 |
\begingroup |
| 894 |
\tl_set:Nn \l__luamplib_tag_envname_tl {usemplibgroup} |
| 895 |
\keys_set_known:ne {luamplib/tagging} {#1} |
| 896 |
\tag_socket_use:n{luamplib/figure/init} |
| 897 |
\prependtomplibbox\hbox dir~TLT\bgroup |
| 898 |
\tag_socket_use:nn{luamplib/figure/begin}{#2} |
| 899 |
\setbox\mplibscratchbox\hbox\bgroup |
| 900 |
\bool_if:NF \l__luamplib_tag_usetext_bool { \tag_suspend:n{\usemplibgroup} } |
| 901 |
\tag_socket_use:nnn{luamplib/mplibgroup/put}{#2}{\csname luamplib.group.#2\endcsname} |
| 902 |
\egroup |
| 903 |
\tag_socket_use:nnn{luamplib/figure/end}{\mplibscratchbox}{\unhbox\mplibscratchbox} |
| 904 |
\egroup |
| 905 |
\endgroup |
| 906 |
} |
| 907 |
\cs_new_nopar:Npn \mplibalttext #1 |
| 908 |
{ |
| 909 |
\tl_set:Ne \l__luamplib_tag_alt_tl {\text_purify:n{#1}} |
| 910 |
} |
| 911 |
\cs_new_nopar:Npn \mplibactualtext #1 |
| 912 |
{ |
| 913 |
\tl_set:Ne \l__luamplib_tag_actual_tl {\text_purify:n{#1}} |
| 914 |
} |
| 915 |
\ExplSyntaxOff |
| 916 |
\endinput |
| 917 |
%% |
| 918 |
%% End of file `luamplib.sty'. |