From 4556d09d2f5c1941ae8691aa0cdb19c674ba350c Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 26 Feb 2020 22:10:25 +0000 Subject: luacolor (26feb20) git-svn-id: svn://tug.org/texlive/trunk@53933 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/source/latex/luacolor/luacolor.dtx | 111 ++++++++++++++++++--- 1 file changed, 98 insertions(+), 13 deletions(-) (limited to 'Master/texmf-dist/source/latex/luacolor') diff --git a/Master/texmf-dist/source/latex/luacolor/luacolor.dtx b/Master/texmf-dist/source/latex/luacolor/luacolor.dtx index 3073f2be034..68c92f056aa 100644 --- a/Master/texmf-dist/source/latex/luacolor/luacolor.dtx +++ b/Master/texmf-dist/source/latex/luacolor/luacolor.dtx @@ -1,7 +1,7 @@ % \iffalse meta-comment % % File: luacolor.dtx -% Version: 2020-02-22 v1.14 +% Version: 2020-02-24 v1.15 % Info: Color support via LuaTeX's attributes % % Copyright (C) @@ -80,7 +80,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: luacolor 2020-02-22 v1.14 Color support via LuaTeX's attributes (HO)} +\Msg{* Package: luacolor 2020-02-24 v1.15 Color support via LuaTeX's attributes (HO)} \Msg{************************************************************************} \keepsilent @@ -92,7 +92,7 @@ This is a generated file. Project: luacolor -Version: 2020-02-22 v1.14 +Version: 2020-02-24 v1.15 Copyright (C) 2007, 2009-2011 Heiko Oberdiek @@ -169,7 +169,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{luacolor.drv}% - [2020-02-22 v1.14 Color support via LuaTeX's attributes (HO)]% + [2020-02-24 v1.15 Color support via LuaTeX's attributes (HO)]% \documentclass{ltxdoc} \usepackage{holtxdoc}[2011/11/22] \usepackage{paralist} @@ -189,7 +189,7 @@ and the derived files % \GetFileInfo{luacolor.drv} % % \title{The \xpackage{luacolor} package} -% \date{2020-02-22 v1.14} +% \date{2020-02-24 v1.15} % \author{Heiko Oberdiek\thanks % {Please report any issues at \url{https://github.com/ho-tex/luacolor/issues}}} % @@ -332,7 +332,7 @@ and the derived files % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luacolor}% - [2020-02-22 v1.14 Color support via LuaTeX's attributes (HO)] + [2020-02-24 v1.15 Color support via LuaTeX's attributes (HO)] % \end{macrocode} % % \subsection{Check for \LuaTeX} @@ -376,7 +376,7 @@ and the derived files % \end{macrocode} % \begin{macrocode} \begingroup - \edef\x{\directlua{tex.write("2020-02-22 v1.14")}}% + \edef\x{\directlua{tex.write("2020-02-24 v1.15")}}% \edef\y{% \directlua{% if oberdiek.luacolor.getversion then % @@ -488,16 +488,98 @@ and the derived files \ifnum\outputmode=\@ne \let\LuaCol@org@pdfxform\saveboxresource % \end{macrocode} +% First we need some helpers to allow expandable code to parse keyword style arguments: +% \begin{macrocode} + \def\LuaCol@iii@i@ii#1#2#3{#3{#1}{#2}} + \def\LuaCol@ii@i#1#2{{#2#1}} + \def\LuaCol@if@keyword#1#2#3{% + \expanded{\unexpanded{\LuaCol@iii@i@ii{#2}{#3}}\expandafter}% + \directlua{% + token.put_next(token.create(token.scan_keyword(token.scan_string()) + and '@firstoftwo' + or '@secondoftwo')) + }{#1}% + } +% \end{macrocode} +% The following macro scans a integer and expands to a token equivalent to a chardef +% whose value corresponds to the scanned integer. This allows the integer to be passed +% around as a undelimited argument. +% \begin{macrocode} + \def\LuaCol@scan@number{% + \directlua{ + token.put_next(token.new(token.scan_int(), token.command_id'char_given')) + }% + } +% \end{macrocode} +% \TeX\ primitives like \cs{saveboxresource} read braced arguments in a special way. +% Especially they expand everything until they find a left brace. To simulate this, we +% use Lua to expand everything else: +% \begin{macrocode} + \def\LuaCol@scan@tobrace{% + \directlua{ + local relax, space = token.command_id'relax', token.command_id'spacer' + local t + repeat + t = token.scan_token() + until not (t.command == relax or t.command == space) + token.put_next(t) + }% + } + \def\LuaCol@scan@boxresource@i#1#2{% + \LuaCol@if@keyword{attr}{% + \expanded{\unexpanded{\LuaCol@scan@boxresource@iI{#1#2attr}}% + \expandafter\expandafter\expandafter}% + \LuaCol@scan@tobrace + }{% + \LuaCol@scan@boxresource@ii{#1#2}% + }% + } + \def\LuaCol@scan@boxresource@iI#1#2{\LuaCol@scan@boxresource@ii{#1{#2}}} + \def\LuaCol@scan@boxresource@ii#1{% + \LuaCol@if@keyword{resources}{% + \expanded{\unexpanded{\LuaCol@scan@boxresource@iiI{#1resources}}% + \expandafter\expandafter\expandafter}% + \LuaCol@scan@tobrace + }{% + \LuaCol@scan@boxresource@iii{#1}% + }% + } + \def\LuaCol@scan@boxresource@iiI#1#2{\LuaCol@scan@boxresource@iii{#1{#2}}} + \def\LuaCol@scan@boxresource@iii#1{% + \LuaCol@if@keyword{margin}{% + \expanded{\unexpanded{\LuaCol@scan@boxresource@iv{#1margin }}% + \expandafter\expandafter\expandafter}% + \LuaCol@scan@number + }{% + \LuaCol@scan@boxresource@iv{#1}{}% + }% + } + \def\LuaCol@scan@boxresource@iv#1#2{% + \expanded{\unexpanded{\LuaCol@scan@boxresource@v{#1#2}}% + \expandafter\expandafter\expandafter}% + \LuaCol@scan@number + } + \def\LuaCol@scan@boxresource@v#1#2{% + \luacolorProcessBox{#2}% + \LuaCol@org@pdfxform#1#2% + } + +% \end{macrocode} +% This could be written in Lua, but at least upto Lua\TeX~1.11, feeding back too many tokens +% from Lua to \TeX\ triggers a segmentation fault. % This is written in Lua so the integer setting is expandable and does not interfere with % a preceding \verb|\immediate|. % \begin{macrocode} \protected\def\saveboxresource{% - \directlua{ - local c = token.scan_int() - oberdiek.luacolor.process(c) - token.put_next(token.create'LuaCol@org@pdfxform', token.new(c, token.command_id'char_given')) + \LuaCol@if@keyword{type}{% + \expandafter + \expanded{\unexpanded{\LuaCol@scan@boxresource@i{type }}% + \expandafter\expandafter\expandafter}% + \LuaCol@scan@number + }{% + \LuaCol@scan@boxresource@i{}{}% }% - }% + } % \end{macrocode} % Legacy alias. % \begin{macrocode} @@ -526,7 +608,7 @@ oberdiek.luacolor = luacolor % \begin{macro}{getversion()} % \begin{macrocode} function luacolor.getversion() - tex.write("2020-02-22 v1.14") + tex.write("2020-02-24 v1.15") end % \end{macrocode} % \end{macro} @@ -1044,6 +1126,9 @@ end % \verb|\saveboxresource|\slash \verb|\pdfxform|. % \item Added handler for the color feature of luaotfload % \end{Version} +% \begin{Version}{2020-02-24 v1.15} +% \item Grab all possible arguments for \verb|\saveboxresource|\slash \verb|\pdfxform| +% \end{Version} % \end{History} % % \PrintIndex -- cgit v1.2.3