texlive[57603] Master/texmf-dist: lua-ul (2feb21)

commits+karl at tug.org commits+karl at tug.org
Tue Feb 2 23:20:15 CET 2021


Revision: 57603
          http://tug.org/svn/texlive?view=revision&revision=57603
Author:   karl
Date:     2021-02-02 23:20:14 +0100 (Tue, 02 Feb 2021)
Log Message:
-----------
lua-ul (2feb21)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/lualatex/lua-ul/lua-ul.pdf
    trunk/Master/texmf-dist/source/lualatex/lua-ul/lua-ul.dtx
    trunk/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty
    trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua
    trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty
    trunk/Master/texmf-dist/tex/lualatex/lua-ul/pre_append_to_vlist_filter.lua

Modified: trunk/Master/texmf-dist/doc/lualatex/lua-ul/lua-ul.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/lualatex/lua-ul/lua-ul.dtx
===================================================================
--- trunk/Master/texmf-dist/source/lualatex/lua-ul/lua-ul.dtx	2021-02-02 22:18:05 UTC (rev 57602)
+++ trunk/Master/texmf-dist/source/lualatex/lua-ul/lua-ul.dtx	2021-02-02 22:20:14 UTC (rev 57603)
@@ -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 @@
 % 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 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 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 @@
 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{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 @@
         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 @@
     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 @@
 \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 @@
 \ifluaul at 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 @@
   \def\luaul@@setcolor\xcolor@#1#2{}
   \newcommand\luaul at setcolor[1]{%
     \ifx\XC at getcolor\undefined
-      \def\luaul at highlight@currentcolor{#1}%
+      \def\luaul at currentcolor{#1}%
     \else
       \begingroup
         \XC at getcolor{#1}\luaul at tmpcolor
       \expanded{\endgroup
-        \def\noexpand\luaul at highlight@currentcolor{%
+        \def\noexpand\luaul at currentcolor{%
           \expandafter\luaul@@setcolor\luaul at tmpcolor}}%
     \fi
   }
+  \newcommand\luaul at applycolor{%
+    \ifx\XC at getcolor\undefined
+      \color{\luaul at currentcolor}%
+    \else
+      \expandafter\XC at undeclaredcolor\luaul at currentcolor
+    \fi
+  }
 %    \end{macrocode}
 % Now a user-level command to set the default color.
 %    \begin{macrocode}
@@ -878,27 +910,38 @@
   \edef\luaul at 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 at strikeThrough[\number\dimexpr1ex@%
+                                          \luaul at currentcolor]{%
+    \luaul at applycolor
+    \leaders\vrule height .55ex depth -.45ex
+  }
+  \NewDocumentCommand\strikeThrough{om}{{%
+    \IfValueTF{#1}{%
+      \luaul at setcolor{#1}%
+      \colored at strikeThrough
+    }\@strikeThrough%
+    #2%
+  }}
+
   \newunderlinetype\@highLight[\number\dimexpr1ex@%
-                               \luaul at highlight@currentcolor]%
-    {%
-      \ifx\XC at getcolor\undefined
-        \color{\luaul at highlight@currentcolor}%
-      \else
-        \expandafter\XC at undeclaredcolor\luaul at highlight@currentcolor
-      \fi
-      \leaders\vrule height 1.75ex depth .75ex
-    }
-  \newcommand\highLight[2][\luaul at highlight@color]{{%
+                               \luaul at currentcolor]{%
+    \luaul at applycolor
+    \leaders\vrule height 1.75ex depth .75ex
+  }
+  \NewDocumentCommand\highLight{O{\luaul at highlight@color}m}{{%
     \luaul at setcolor{#1}%
     \@highLight#2%
   }}
@@ -934,6 +977,22 @@
   }
 \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 at 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

Modified: trunk/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty	2021-02-02 22:18:05 UTC (rev 57602)
+++ trunk/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty	2021-02-02 22:20:14 UTC (rev 57603)
@@ -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 at luacode@argscanner#1\directlua{
   tex.sprint(\the\catcodetable at string, "\string\\end{docstrip-luacode}")

Modified: trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua	2021-02-02 22:18:05 UTC (rev 57602)
+++ trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua	2021-02-02 22:20:14 UTC (rev 57603)
@@ -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 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 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 @@
         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 @@
     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)

Modified: trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty	2021-02-02 22:18:05 UTC (rev 57602)
+++ trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty	2021-02-02 22:20:14 UTC (rev 57603)
@@ -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 at setcolor[1]{%
     \ifx\XC at getcolor\undefined
-      \def\luaul at highlight@currentcolor{#1}%
+      \def\luaul at currentcolor{#1}%
     \else
       \begingroup
         \XC at getcolor{#1}\luaul at tmpcolor
       \expanded{\endgroup
-        \def\noexpand\luaul at highlight@currentcolor{%
+        \def\noexpand\luaul at currentcolor{%
           \expandafter\luaul@@setcolor\luaul at tmpcolor}}%
     \fi
   }
+  \newcommand\luaul at applycolor{%
+    \ifx\XC at getcolor\undefined
+      \color{\luaul at currentcolor}%
+    \else
+      \expandafter\XC at undeclaredcolor\luaul at currentcolor
+    \fi
+  }
 \NewDocumentCommand\LuaULSetHighLightColor{om}{%
   \edef\luaul at 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 at strikeThrough[\number\dimexpr1ex@%
+                                          \luaul at currentcolor]{%
+    \luaul at applycolor
+    \leaders\vrule height .55ex depth -.45ex
+  }
+  \NewDocumentCommand\strikeThrough{om}{{%
+    \IfValueTF{#1}{%
+      \luaul at setcolor{#1}%
+      \colored at strikeThrough
+    }\@strikeThrough%
+    #2%
+  }}
+
   \newunderlinetype\@highLight[\number\dimexpr1ex@%
-                               \luaul at highlight@currentcolor]%
-    {%
-      \ifx\XC at getcolor\undefined
-        \color{\luaul at highlight@currentcolor}%
-      \else
-        \expandafter\XC at undeclaredcolor\luaul at highlight@currentcolor
-      \fi
-      \leaders\vrule height 1.75ex depth .75ex
-    }
-  \newcommand\highLight[2][\luaul at highlight@color]{{%
+                               \luaul at currentcolor]{%
+    \luaul at applycolor
+    \leaders\vrule height 1.75ex depth .75ex
+  }
+  \NewDocumentCommand\highLight{O{\luaul at highlight@color}m}{{%
     \luaul at 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'.

Modified: trunk/Master/texmf-dist/tex/lualatex/lua-ul/pre_append_to_vlist_filter.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/lua-ul/pre_append_to_vlist_filter.lua	2021-02-02 22:18:05 UTC (rev 57602)
+++ trunk/Master/texmf-dist/tex/lualatex/lua-ul/pre_append_to_vlist_filter.lua	2021-02-02 22:20:14 UTC (rev 57603)
@@ -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 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



More information about the tex-live-commits mailing list.