diff options
author | Karl Berry <karl@freefriends.org> | 2020-02-26 22:10:25 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-02-26 22:10:25 +0000 |
commit | 4556d09d2f5c1941ae8691aa0cdb19c674ba350c (patch) | |
tree | 72319f5b0a343352eaf4b2a07d7d2e60533ecf22 | |
parent | a16c89d7793f3f99757220e4becd13e5eea7d37b (diff) |
luacolor (26feb20)
git-svn-id: svn://tug.org/texlive/trunk@53933 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/luacolor/luacolor.pdf | bin | 316983 -> 322070 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/luacolor/luacolor.dtx | 111 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/luacolor/luacolor.lua | 4 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/luacolor/luacolor.sty | 83 |
4 files changed, 175 insertions, 23 deletions
diff --git a/Master/texmf-dist/doc/latex/luacolor/luacolor.pdf b/Master/texmf-dist/doc/latex/luacolor/luacolor.pdf Binary files differindex edcf74c1362..b01a36cc92f 100644 --- a/Master/texmf-dist/doc/latex/luacolor/luacolor.pdf +++ b/Master/texmf-dist/doc/latex/luacolor/luacolor.pdf 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 diff --git a/Master/texmf-dist/tex/latex/luacolor/luacolor.lua b/Master/texmf-dist/tex/latex/luacolor/luacolor.lua index d1075136a73..e95192a2fef 100644 --- a/Master/texmf-dist/tex/latex/luacolor/luacolor.lua +++ b/Master/texmf-dist/tex/latex/luacolor/luacolor.lua @@ -9,7 +9,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 @@ -41,7 +41,7 @@ oberdiek = oberdiek or {} local luacolor = oberdiek.luacolor or {} oberdiek.luacolor = luacolor function luacolor.getversion() - tex.write("2020-02-22 v1.14") + tex.write("2020-02-24 v1.15") end local ifpdf = tonumber(tex.outputmode or tex.pdfoutput) > 0 local prefix diff --git a/Master/texmf-dist/tex/latex/luacolor/luacolor.sty b/Master/texmf-dist/tex/latex/luacolor/luacolor.sty index bad536ceae4..af5de64684d 100644 --- a/Master/texmf-dist/tex/latex/luacolor/luacolor.sty +++ b/Master/texmf-dist/tex/latex/luacolor/luacolor.sty @@ -9,7 +9,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 @@ -89,7 +89,7 @@ \edef\LuaCol@AtEnd{\LuaCol@AtEnd\noexpand\endinput} \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)] \RequirePackage{color} \ifx\directlua\@undefined \PackageError{luacolor}{% @@ -112,7 +112,7 @@ require("luacolor")% } \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 % @@ -183,13 +183,80 @@ \set@color \ifnum\outputmode=\@ne \let\LuaCol@org@pdfxform\saveboxresource - \protected\def\saveboxresource{% + \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}% + } + \def\LuaCol@scan@number{% \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')) + token.put_next(token.new(token.scan_int(), token.command_id'char_given')) }% - }% + } + \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% + } + + \protected\def\saveboxresource{% + \LuaCol@if@keyword{type}{% + \expandafter + \expanded{\unexpanded{\LuaCol@scan@boxresource@i{type }}% + \expandafter\expandafter\expandafter}% + \LuaCol@scan@number + }{% + \LuaCol@scan@boxresource@i{}{}% + }% + } \let\pdfxform\saveboxresource \fi \LuaCol@AtEnd% |