summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-02-02 22:20:14 +0000
committerKarl Berry <karl@freefriends.org>2021-02-02 22:20:14 +0000
commitafb7e3ea263187a5245b6c5b98b1dec025c5f430 (patch)
treef4612371d1efa9a681d14a3eb477c0b6bc0a715a /Master
parent5c12acf0947b473d80cb557104835967e39e640b (diff)
lua-ul (2feb21)
git-svn-id: svn://tug.org/texlive/trunk@57603 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/lualatex/lua-ul/lua-ul.pdfbin95868 -> 99609 bytes
-rw-r--r--Master/texmf-dist/source/lualatex/lua-ul/lua-ul.dtx123
-rw-r--r--Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty4
-rw-r--r--Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua6
-rw-r--r--Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty61
-rw-r--r--Master/texmf-dist/tex/lualatex/lua-ul/pre_append_to_vlist_filter.lua4
6 files changed, 141 insertions, 57 deletions
diff --git a/Master/texmf-dist/doc/lualatex/lua-ul/lua-ul.pdf b/Master/texmf-dist/doc/lualatex/lua-ul/lua-ul.pdf
index 326d8a612c6..a868e5e6ef8 100644
--- a/Master/texmf-dist/doc/lualatex/lua-ul/lua-ul.pdf
+++ b/Master/texmf-dist/doc/lualatex/lua-ul/lua-ul.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/lualatex/lua-ul/lua-ul.dtx b/Master/texmf-dist/source/lualatex/lua-ul/lua-ul.dtx
index 8c734e52529..ad57f41b679 100644
--- a/Master/texmf-dist/source/lualatex/lua-ul/lua-ul.dtx
+++ b/Master/texmf-dist/source/lualatex/lua-ul/lua-ul.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-%% Copyright (C) 2020 by Marcel Krueger
+%% Copyright (C) 2020-2021 by Marcel Krueger
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
@@ -20,7 +20,6 @@
%</gobble>
\input docstrip.tex
\keepsilent
-\askforoverwritefalse
\let\MetaPrefix\relax
\preamble
\endpreamble
@@ -63,7 +62,7 @@
% \duck
% \end{tikzpicture}§
% }}
-% \newcommand\underDuck[1]{{\beginUnderDuck#1}}
+% \NewDocumentCommand\underDuck{m}{{\beginUnderDuck#1}}
% \newunderlinetype\beginUnderWavy[\number\dimexpr1ex]{\cleaders\hbox{§
% \setlength\unitlength{.3ex}§
% \begin{picture}(4,0)(0,1)
@@ -73,11 +72,11 @@
% \qbezier(2,0)(3,-1)(4,0)
% \end{picture}§
% }}
-% \newcommand\underWavy[1]{{\beginUnderWavy#1}}
+% \NewDocumentCommand\underWavy{m}{{\beginUnderWavy#1}}
% \newunderlinetype\beginStrikeThough{\leaders\hbox{§
% \normalfont\bfseries/§
% }}
-% \newcommand\StrikeThough[1]{{\beginStrikeThough#1}}
+% \NewDocumentCommand\StrikeThough{m}{{\beginStrikeThough#1}}
%
% \newcommand\Luaul{Lua-UL}
% \newcommand\luaul{Lua-UL}
@@ -161,7 +160,7 @@
% you will have to define this manually.)
% The optional argument provides a \enquote{context}: This \enquote{context} has to expand to a string
% (something that can appear in a csname) which changes if the leaders box should be recalculated.
-% The leader will be chached and reused whenever the context evaluates to the same string.
+% The leader will be cached and reused whenever the context evaluates to the same string.
% So if your leaders should depend on the fontsize,
% the expansion of the context should contain the font size. If you leaders contain text in the current font,
% your context should include \verb+\fontname+. The default context includes the current size of \texttt{1ex}
@@ -169,7 +168,7 @@
%
% The final argument contains the actual leader command. You should omit the final glue normally passed to \verb+\leaders+,
% so e.g.\ write \verb+\leaders\hbox{ . }+ without appending \verb+\hfill+ or \verb+\hskip1pt+ etc.
-% In most cases, the height and depth of your underlines is passed on to TeX to ensure that a deep underline does not interept other lines.
+% In most cases, the height and depth of your underlines is passed on to TeX to ensure that a deep underline does not intercept other lines.
% On the other hand, running dimensions work fine if you use a rule.
%
% For example, the special underline commands demonstrated above are implemented as
@@ -181,7 +180,7 @@
% \duck
% \end{tikzpicture}%
% }}
-% \newcommand\underDuck[1]{{\beginUnderDuck#1}}
+% \NewDocumentCommand\underDuck{m}{{\beginUnderDuck#1}}
% \newunderlinetype\beginUnderWavy[\number\dimexpr1ex]{\cleaders\hbox{%
% \setlength\unitlength{.3ex}%
% \begin{picture}(4,0)(0,1)
@@ -191,11 +190,11 @@
% \qbezier(2,0)(3,-1)(4,0)
% \end{picture}%
% }}
-% \newcommand\underWavy[1]{{\beginUnderWavy#1}}
+% \NewDocumentCommand\underWavy{m}{{\beginUnderWavy#1}}
% \newunderlinetype\beginStrikeThough{\leaders\hbox{%
% \normalfont\bfseries/%
% }}
-% \newcommand\StrikeThough[1]{{\beginStrikeThough#1}}
+% \NewDocumentCommand\StrikeThough{m}{{\beginStrikeThough#1}}
% \end{verbatim}
%
% Here \verb+\underWavy+ uses a custom context because it doesn't change depending on the current font color.
@@ -235,7 +234,7 @@ local callback_define
% so we use the debug library to get the ``real'' \verb+callback.define+:
% \begin{macrocode}
for i=1,5 do
- local name, func = debug.getupvalue(luatexbase.disable_callback, i)
+local name, func = require'debug'.getupvalue(luatexbase.disable_callback, i)
if name == 'callback_register' then
callback_define = func
break
@@ -299,6 +298,7 @@ local has_attribute = node.direct.has_attribute
local set_attribute = node.direct.set_attribute
local dimensions = node.direct.dimensions
local flush_node = node.direct.flush_node
+local getattr = node.direct.getattributelist
local getboth = node.direct.getboth
local getfield = node.direct.getfield
local getglue = node.direct.getglue
@@ -319,6 +319,7 @@ local setlink = node.direct.setlink
local hpack = node.direct.hpack
local setfield = node.direct.setfield
local slide = node.direct.slide
+local setattr = node.direct.setattributelist
local setglue = node.direct.setglue
local setnext = node.direct.setnext
local setshift = node.direct.setshift
@@ -359,7 +360,7 @@ end
local texnest = tex.nest
% \end{macrocode}
-% \changes{0.1.0}{2020-07-13}{Ensure that \texttt{\string\everyhbox} doesn't interfere with hlist scanning}
+% \changes{0.1.0}{2020-07-13}{Ensure that \texttt{\protect\string\protect\everyhbox} doesn't interfere with hlist scanning}
% To avoid influence from \texttt{\string\everyhbox} we reset \texttt{\string\everyhbox} to an empty token list directly before scanning.
% As an added complication, we need to use a name which is guaranteed to be the primitive tokenlist and we
% might have to restore it before reading the actual argument (There might be a reason why \texttt{\string\everyhbox} was sat after all.
@@ -560,7 +561,7 @@ end
% \end{macrocode}
% \changes{0.0.3}{2020-03-17}{Make streight lines over hboxes}
% \changes{0.0.4}{2020-03-31}{Consistently respect height and depth}
-% Now the actual undelining
+% Now the actual underlining
% \begin{macrocode}
local add_underline_hlist, add_underline_hbox, add_underline_vbox
local function add_underline_vlist(head, attr, outervalue)
@@ -659,11 +660,33 @@ function add_underline_hlist(head, attr, outervalue)
stretch_order, shrink_order = fil_levels(head)
end
if last_value then
+% \end{macrocode}
+% \changes{0.1.1}{2022-02-02}{Set attributes for negative glue node}
+% If the value changed and the old one wasn't \texttt{nil}, then we reached
+% the end of the previous underlined segment and therefore know it's length.
+% Therefore we can finally insert the underline.
+%
+% Currently both the underline and the corresponding negative glue inherit
+% the attributes from when the underline was defined. This makes sure that
+% these nodes get consistent attributes (avoiding e.g. that only one of the
+% nodes being picked up in a later pass and therefore interfering with the
+% underlining) and that these are as much as possible under use control.
+%
+% We can't really predict what the most sensible value for attributes we
+% don't control is, but by using this way any issues should be fixable with
+% by adjusting the context argument.
+%
+% Currently this block gets duplicated a few lines down for the end of the
+% list. This should get refactored into it's own function, but I have to be
+% careful to handle all the special cases there.
+%
+% \begin{macrocode}
local glue = new_glue_neg_dimensions(first, n,
stretch_order, shrink_order)
local w, st, sh = getglue(glue)
local lead = nodecopy(underline_types[last_value])
setglue(lead, -w, -st, -sh, stretch_order, shrink_order)
+ setattr(glue, getattr(lead))
if underline_over_flag[last_value] then
head = insert_before(head, n, glue)
insert_after(head, glue, lead)
@@ -691,6 +714,7 @@ function add_underline_hlist(head, attr, outervalue)
local w, st, sh = getglue(glue)
local lead = nodecopy(underline_types[last_value])
setglue(lead, -w, -st, -sh, stretch_order, shrink_order)
+ setattr(glue, getattr(lead))
if underline_over_flag[last_value] then
insert_before(head, nil, glue)
insert_after(head, glue, lead)
@@ -792,7 +816,7 @@ luatexbase.add_to_callback('vpack_filter',
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage
{lua-ul}
- [2020/07/13 v0.1.0 Underlining and related functionality for LuaTeX]
+ [2021/02/02 v0.1.1 Underlining and related functionality for LuaTeX]
% \fi
% Only \LuaLaTeX{} is supported.
@@ -852,6 +876,7 @@ luatexbase.add_to_callback('vpack_filter',
\ifluaul@predefined
% \end{macrocode}
% \changes{0.0.2}{2020-03-15}{Allow \texttt{\protect\string\protect\highLight} color customization}
+% \changes{0.1.1}{2022-02-02}{Make color mechanism more generic}
% For \verb+\highLight+, the color should be customizable.
% There are two cases: If \verb+xcolor+ is not loaded, we just accept
% a simple color name. Otherwise, we accept color as documented in
@@ -862,15 +887,22 @@ luatexbase.add_to_callback('vpack_filter',
\def\luaul@@setcolor\xcolor@#1#2{}
\newcommand\luaul@setcolor[1]{%
\ifx\XC@getcolor\undefined
- \def\luaul@highlight@currentcolor{#1}%
+ \def\luaul@currentcolor{#1}%
\else
\begingroup
\XC@getcolor{#1}\luaul@tmpcolor
\expanded{\endgroup
- \def\noexpand\luaul@highlight@currentcolor{%
+ \def\noexpand\luaul@currentcolor{%
\expandafter\luaul@@setcolor\luaul@tmpcolor}}%
\fi
}
+ \newcommand\luaul@applycolor{%
+ \ifx\XC@getcolor\undefined
+ \color{\luaul@currentcolor}%
+ \else
+ \expandafter\XC@undeclaredcolor\luaul@currentcolor
+ \fi
+ }
% \end{macrocode}
% Now a user-level command to set the default color.
% \begin{macrocode}
@@ -878,27 +910,38 @@ luatexbase.add_to_callback('vpack_filter',
\edef\luaul@highlight@color{\IfValueTF{#1}{[#1]{#2}}{#2}}%
}
% \end{macrocode}
+% \changes{0.1.1}{2020-03-15}{Use \texttt{xparse} for all user commands}
+% \changes{0.1.1}{2021-02-02}{Optionally color \texttt{\protect\string\protect\strikeThrough}}
% The sizes for the predefined commands are stolen from the \enquote{soul}
% default values.
% \begin{macrocode}
- \newunderlinetype\@underLine%
- {\leaders\vrule height -.65ex depth .75ex}
- \newcommand\underLine[1]{{\@underLine#1}}
- \newunderlinetype\@strikeThrough%
- {\leaders\vrule height .55ex depth -.45ex}
- \newcommand\strikeThrough[1]{{\@strikeThrough#1}}
+ \newunderlinetype\@underLine{%
+ \leaders\vrule height -.65ex depth .75ex
+ }
+ \NewDocumentCommand\underLine{m}{{\@underLine#1}}
+
+ \newunderlinetype\@strikeThrough{%
+ \leaders\vrule height .55ex depth -.45ex
+ }
+ \newunderlinetype\colored@strikeThrough[\number\dimexpr1ex@%
+ \luaul@currentcolor]{%
+ \luaul@applycolor
+ \leaders\vrule height .55ex depth -.45ex
+ }
+ \NewDocumentCommand\strikeThrough{om}{{%
+ \IfValueTF{#1}{%
+ \luaul@setcolor{#1}%
+ \colored@strikeThrough
+ }\@strikeThrough%
+ #2%
+ }}
\newunderlinetype\@highLight[\number\dimexpr1ex@%
- \luaul@highlight@currentcolor]%
- {%
- \ifx\XC@getcolor\undefined
- \color{\luaul@highlight@currentcolor}%
- \else
- \expandafter\XC@undeclaredcolor\luaul@highlight@currentcolor
- \fi
- \leaders\vrule height 1.75ex depth .75ex
- }
- \newcommand\highLight[2][\luaul@highlight@color]{{%
+ \luaul@currentcolor]{%
+ \luaul@applycolor
+ \leaders\vrule height 1.75ex depth .75ex
+ }
+ \NewDocumentCommand\highLight{O{\luaul@highlight@color}m}{{%
\luaul@setcolor{#1}%
\@highLight#2%
}}
@@ -934,6 +977,22 @@ luatexbase.add_to_callback('vpack_filter',
}
\fi
% \end{macrocode}
+% \changes{0.1.1}{2021-02-02}{Patch \texttt{\protect\string\protect\output}}
+% In the output routine, the page box is repacked before \verb+\reset@font+ is
+% called, so we have to ensure to reset the attributes before that. This will
+% use some awesome output routine hook as soon as that's in the kernel, until
+% then manual patching it is.
+%
+% At the time I am writing this the remaining code of the package contains
+% exactly ten times \verb+\expandafter+. Interestingly, that's also exactly
+% the number of \verb+\expandafter+s we use here.
+% \begin{macrocode}
+\output\expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter\LuaULResetUnderline
+ \expandafter\expandafter\expandafter*%
+ \expandafter\@firstofone\the\output%
+}
+% \end{macrocode}
% \iffalse
%</package>
% \fi
diff --git a/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty b/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty
index 944fcdc25e6..29f055258f4 100644
--- a/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty
+++ b/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty
@@ -1,4 +1,4 @@
-%% Copyright (C) 2020 by Marcel Krueger
+%% Copyright (C) 2020-2021 by Marcel Krueger
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
@@ -13,7 +13,7 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage
{docstrip-luacode}
- [2020/03/07 v0.1.0 Directly execute Lua code from DocStrip files]
+ [2021/02/02 v0.1.1 Directly execute Lua code from DocStrip files]
\expanded{%
\def\noexpand\docstrip@luacode@argscanner#1\directlua{
tex.sprint(\the\catcodetable@string, "\string\\end{docstrip-luacode}")
diff --git a/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua b/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua
index 13185d92877..45518e83542 100644
--- a/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua
+++ b/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua
@@ -6,7 +6,7 @@
--
-- lua-ul.dtx (with options: `luacode')
--
--- Copyright (C) 2020 by Marcel Krueger
+-- Copyright (C) 2020-2021 by Marcel Krueger
--
-- This file may be distributed and/or modified under the
-- conditions of the LaTeX Project Public License, either
@@ -29,6 +29,7 @@ local has_attribute = node.direct.has_attribute
local set_attribute = node.direct.set_attribute
local dimensions = node.direct.dimensions
local flush_node = node.direct.flush_node
+local getattr = node.direct.getattributelist
local getboth = node.direct.getboth
local getfield = node.direct.getfield
local getglue = node.direct.getglue
@@ -49,6 +50,7 @@ local setlink = node.direct.setlink
local hpack = node.direct.hpack
local setfield = node.direct.setfield
local slide = node.direct.slide
+local setattr = node.direct.setattributelist
local setglue = node.direct.setglue
local setnext = node.direct.setnext
local setshift = node.direct.setshift
@@ -366,6 +368,7 @@ function add_underline_hlist(head, attr, outervalue)
local w, st, sh = getglue(glue)
local lead = nodecopy(underline_types[last_value])
setglue(lead, -w, -st, -sh, stretch_order, shrink_order)
+ setattr(glue, getattr(lead))
if underline_over_flag[last_value] then
head = insert_before(head, n, glue)
insert_after(head, glue, lead)
@@ -393,6 +396,7 @@ function add_underline_hlist(head, attr, outervalue)
local w, st, sh = getglue(glue)
local lead = nodecopy(underline_types[last_value])
setglue(lead, -w, -st, -sh, stretch_order, shrink_order)
+ setattr(glue, getattr(lead))
if underline_over_flag[last_value] then
insert_before(head, nil, glue)
insert_after(head, glue, lead)
diff --git a/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty b/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty
index 531d03eb448..f432fb068cb 100644
--- a/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty
+++ b/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty
@@ -6,7 +6,7 @@
%%
%% lua-ul.dtx (with options: `package')
%%
-%% Copyright (C) 2020 by Marcel Krueger
+%% Copyright (C) 2020-2021 by Marcel Krueger
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
@@ -20,7 +20,7 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage
{lua-ul}
- [2020/07/13 v0.1.0 Underlining and related functionality for LuaTeX]
+ [2021/02/02 v0.1.1 Underlining and related functionality for LuaTeX]
\ifx\directlua\undefined
\PackageError{lua-ul}{LuaLaTeX required}%
@@ -62,36 +62,52 @@
\def\luaul@@setcolor\xcolor@#1#2{}
\newcommand\luaul@setcolor[1]{%
\ifx\XC@getcolor\undefined
- \def\luaul@highlight@currentcolor{#1}%
+ \def\luaul@currentcolor{#1}%
\else
\begingroup
\XC@getcolor{#1}\luaul@tmpcolor
\expanded{\endgroup
- \def\noexpand\luaul@highlight@currentcolor{%
+ \def\noexpand\luaul@currentcolor{%
\expandafter\luaul@@setcolor\luaul@tmpcolor}}%
\fi
}
+ \newcommand\luaul@applycolor{%
+ \ifx\XC@getcolor\undefined
+ \color{\luaul@currentcolor}%
+ \else
+ \expandafter\XC@undeclaredcolor\luaul@currentcolor
+ \fi
+ }
\NewDocumentCommand\LuaULSetHighLightColor{om}{%
\edef\luaul@highlight@color{\IfValueTF{#1}{[#1]{#2}}{#2}}%
}
- \newunderlinetype\@underLine%
- {\leaders\vrule height -.65ex depth .75ex}
- \newcommand\underLine[1]{{\@underLine#1}}
- \newunderlinetype\@strikeThrough%
- {\leaders\vrule height .55ex depth -.45ex}
- \newcommand\strikeThrough[1]{{\@strikeThrough#1}}
+ \newunderlinetype\@underLine{%
+ \leaders\vrule height -.65ex depth .75ex
+ }
+ \NewDocumentCommand\underLine{m}{{\@underLine#1}}
+
+ \newunderlinetype\@strikeThrough{%
+ \leaders\vrule height .55ex depth -.45ex
+ }
+ \newunderlinetype\colored@strikeThrough[\number\dimexpr1ex@%
+ \luaul@currentcolor]{%
+ \luaul@applycolor
+ \leaders\vrule height .55ex depth -.45ex
+ }
+ \NewDocumentCommand\strikeThrough{om}{{%
+ \IfValueTF{#1}{%
+ \luaul@setcolor{#1}%
+ \colored@strikeThrough
+ }\@strikeThrough%
+ #2%
+ }}
\newunderlinetype\@highLight[\number\dimexpr1ex@%
- \luaul@highlight@currentcolor]%
- {%
- \ifx\XC@getcolor\undefined
- \color{\luaul@highlight@currentcolor}%
- \else
- \expandafter\XC@undeclaredcolor\luaul@highlight@currentcolor
- \fi
- \leaders\vrule height 1.75ex depth .75ex
- }
- \newcommand\highLight[2][\luaul@highlight@color]{{%
+ \luaul@currentcolor]{%
+ \luaul@applycolor
+ \leaders\vrule height 1.75ex depth .75ex
+ }
+ \NewDocumentCommand\highLight{O{\luaul@highlight@color}m}{{%
\luaul@setcolor{#1}%
\@highLight#2%
}}
@@ -121,6 +137,11 @@
\LuaULResetUnderline*%
}
\fi
+\output\expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter\LuaULResetUnderline
+ \expandafter\expandafter\expandafter*%
+ \expandafter\@firstofone\the\output%
+}
%%
%%
%% End of file `lua-ul.sty'.
diff --git a/Master/texmf-dist/tex/lualatex/lua-ul/pre_append_to_vlist_filter.lua b/Master/texmf-dist/tex/lualatex/lua-ul/pre_append_to_vlist_filter.lua
index 2ab110e8297..810247ddfea 100644
--- a/Master/texmf-dist/tex/lualatex/lua-ul/pre_append_to_vlist_filter.lua
+++ b/Master/texmf-dist/tex/lualatex/lua-ul/pre_append_to_vlist_filter.lua
@@ -6,7 +6,7 @@
--
-- lua-ul.dtx (with options: `callback')
--
--- Copyright (C) 2020 by Marcel Krueger
+-- Copyright (C) 2020-2021 by Marcel Krueger
--
-- This file may be distributed and/or modified under the
-- conditions of the LaTeX Project Public License, either
@@ -27,7 +27,7 @@ local prepend_prevdepth = node.prepend_prevdepth
local callback_define
for i=1,5 do
- local name, func = debug.getupvalue(luatexbase.disable_callback, i)
+local name, func = require'debug'.getupvalue(luatexbase.disable_callback, i)
if name == 'callback_register' then
callback_define = func
break