texlive[59186] Master/texmf-dist: lua-ul, and etex-answer-y to handle

commits+karl at tug.org commits+karl at tug.org
Thu May 13 23:29:14 CEST 2021


Revision: 59186
          http://tug.org/svn/texlive?view=revision&revision=59186
Author:   karl
Date:     2021-05-13 23:29:14 +0200 (Thu, 13 May 2021)
Log Message:
-----------
lua-ul, and etex-answer-y to handle spurious latex interaction (13may21)

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

Added Paths:
-----------
    trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul-patches-preserve-attr.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-05-13 21:28:57 UTC (rev 59185)
+++ trunk/Master/texmf-dist/source/lualatex/lua-ul/lua-ul.dtx	2021-05-13 21:29:14 UTC (rev 59186)
@@ -20,7 +20,6 @@
 %</gobble>
 \input docstrip.tex
 \keepsilent
-\askforoverwritefalse
 \let\MetaPrefix\relax
 \preamble
 \endpreamble
@@ -30,6 +29,7 @@
 \generate{%
   \file{lua-ul.lua}{\from{lua-ul.dtx}{luacode}}%
   \file{pre_append_to_vlist_filter.lua}{\from{lua-ul.dtx}{callback}}%
+  \file{lua-ul-patches-preserve-attr.lua}{\from{lua-ul.dtx}{preserve-attr}}%
 }
 \let\MetaPrefix\DoubleperCent
 \generate{\file{lua-ul.sty}{\from{lua-ul.dtx}{package}}}
@@ -278,6 +278,98 @@
 \end{docstrip-luacode}
 %</gobble>
 % \fi
+%
+% \changes{0.1.4}{2021-05-12}{Add \texttt{lua-ul-patches-preserve-attr}}
+% \changes{0.1.4}{2021-05-12}{Patch \texttt{\protect\string\protect\sw at slant}}
+% Additionally we have a module \verb+lua-ul-patches-preserve-attr+ for patches of
+% external code to make it more compatible with attribute usage.
+%
+% Currently this only caontains redefinitions of kernel commands.
+% \iffalse
+%<*gobble>
+\begin{docstrip-luacode}{lua-ul-patches-preserve-attr}
+%</gobble>
+%<*preserve-attr>
+% \fi
+% First some local definitions
+%    \begin{macrocode}
+local getfont = font.getfont
+
+local direct = node.direct
+
+local getattr = direct.getattributelist
+local getid = direct.getid
+local getpenalty = direct.getpenalty
+local getprev = direct.getprev
+local getwidth = direct.getwidth
+
+local setattr = direct.setattributelist
+local setkern = direct.setkern
+
+local insert_after = direct.insert_after
+local is_glyph = direct.is_glyph
+local newnode = direct.new
+local todirect = direct.todirect
+local tonode = direct.tonode
+
+local glue_id = node.id'glue'
+local kern_t = node.id'kern'
+local penalty_id = node.id'penalty'
+
+local italcorr_sub
+for i, n in next, node.subtypes'kern' do
+  if n == 'italiccorrection' then italcorr_sub = i break end
+end
+assert(italcorr_sub)
+
+local nests = tex.nest
+
+%    \end{macrocode}
+%
+% Now we come to the interesting part: We redefine \verb+\sw at slant+ from the
+% \LaTeX\ kernel. The original definition uses \verb+\unskip+ and
+% \verb+\unpenalty+ to remove glue and penalties and then inserts italic
+% correction before them. Then it inserts the removed penalty and skip again.
+% This looses the right subtype, attributes and properties of the removed
+% nodes, so we insert the italic correction kern directly at the right position
+% instead. When the character does not exists we still add a 0pt italic
+% correction to stay as compatible as possible with the \verb+\/+ primitive
+% used in the original implementation.
+%    \begin{macrocode}
+local funcid = luatexbase.new_luafunction'sw at slant'
+token.set_lua('sw at slant', funcid, 'protected')
+lua.get_functions_table()[funcid] = function()
+  local nest = nests.top
+  local tail, after = todirect(nest.tail), nil
+  local id = getid(tail)
+  if id == glue_id then
+    if getwidth(tail) == 0 then return end
+    tail, after = getprev(tail), tail
+    id = getid(tail)
+  end
+  if id == penalty_id then
+    if getpenalty(tail) == 0 then return end
+    tail, after = getprev(tail), tail
+  end
+  local cid, fontid = is_glyph(tail)
+  if not cid then return end
+  local fontdir = getfont(fontid)
+  local characters = fontdir and fontdir.characters
+  local char = characters and characters[cid]
+  local kern = newnode(kern_t, italcorr_sub)
+  setkern(kern, char and char.italic or 0)
+  setattr(kern, getattr(tail))
+% We lie about the head and ignore the return value since tail is never nil
+  insert_after(tail, tail, kern)
+  if not after then nest.tail = tonode(kern) end
+end
+%    \end{macrocode}
+% \iffalse
+%</preserve-attr>
+%<*gobble>
+\end{docstrip-luacode}
+%</gobble>
+% \fi
 % \subsection{Lua module}
 % Now we can define our main Lua module:
 % \iffalse
@@ -819,6 +911,11 @@
       return tonode(head)
     end, 'add underlines to list')
 %    \end{macrocode}
+% \changes{0.1.4}{2021-05-12}{Load \texttt{lua-ul-patches-preserve-attr}}
+% Finally load \texttt{lua-ul-patches-preserve-attr}.
+%    \begin{macrocode}
+require'lua-ul-patches-preserve-attr'
+%    \end{macrocode}
 % \iffalse
 %</luacode>
 %<*gobble>
@@ -832,7 +929,7 @@
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage
   {lua-ul}
-  [2021/04/25 v0.1.3 Underlining and related functionality for LuaTeX]
+  [2021/05/12 v0.1.4 Underlining and related functionality for LuaTeX]
 
 % \fi
 % Only \LuaLaTeX{} is supported.

Modified: trunk/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty	2021-05-13 21:28:57 UTC (rev 59185)
+++ trunk/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty	2021-05-13 21:29:14 UTC (rev 59186)
@@ -13,7 +13,7 @@
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage
   {docstrip-luacode}
-  [2021/04/25 v0.1.3 Directly execute Lua code from DocStrip files]
+  [2021/05/12 v0.1.4 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}")

Added: trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul-patches-preserve-attr.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul-patches-preserve-attr.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul-patches-preserve-attr.lua	2021-05-13 21:29:14 UTC (rev 59186)
@@ -0,0 +1,79 @@
+--
+-- This is file `lua-ul-patches-preserve-attr.lua',
+-- generated with the docstrip utility.
+--
+-- The original source files were:
+--
+-- lua-ul.dtx  (with options: `preserve-attr')
+-- 
+-- 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
+-- version 1.3c of this license or (at your option) any later
+-- version. The latest version of this license is in:
+--
+-- http://www.latex-project.org/lppl.txt
+--
+-- and version 1.3 or later is part of all distributions of
+-- LaTeX version 2005/12/01 or later.
+local getfont = font.getfont
+
+local direct = node.direct
+
+local getattr = direct.getattributelist
+local getid = direct.getid
+local getpenalty = direct.getpenalty
+local getprev = direct.getprev
+local getwidth = direct.getwidth
+
+local setattr = direct.setattributelist
+local setkern = direct.setkern
+
+local insert_after = direct.insert_after
+local is_glyph = direct.is_glyph
+local newnode = direct.new
+local todirect = direct.todirect
+local tonode = direct.tonode
+
+local glue_id = node.id'glue'
+local kern_t = node.id'kern'
+local penalty_id = node.id'penalty'
+
+local italcorr_sub
+for i, n in next, node.subtypes'kern' do
+  if n == 'italiccorrection' then italcorr_sub = i break end
+end
+assert(italcorr_sub)
+
+local nests = tex.nest
+
+local funcid = luatexbase.new_luafunction'sw at slant'
+token.set_lua('sw at slant', funcid, 'protected')
+lua.get_functions_table()[funcid] = function()
+  local nest = nests.top
+  local tail, after = todirect(nest.tail), nil
+  local id = getid(tail)
+  if id == glue_id then
+    if getwidth(tail) == 0 then return end
+    tail, after = getprev(tail), tail
+    id = getid(tail)
+  end
+  if id == penalty_id then
+    if getpenalty(tail) == 0 then return end
+    tail, after = getprev(tail), tail
+  end
+  local cid, fontid = is_glyph(tail)
+  if not cid then return end
+  local fontdir = getfont(fontid)
+  local characters = fontdir and fontdir.characters
+  local char = characters and characters[cid]
+  local kern = newnode(kern_t, italcorr_sub)
+  setkern(kern, char and char.italic or 0)
+  setattr(kern, getattr(tail))
+  insert_after(tail, tail, kern)
+  if not after then nest.tail = tonode(kern) end
+end
+-- 
+--
+-- End of file `lua-ul-patches-preserve-attr.lua'.


Property changes on: trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul-patches-preserve-attr.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua	2021-05-13 21:28:57 UTC (rev 59185)
+++ trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua	2021-05-13 21:29:14 UTC (rev 59186)
@@ -487,6 +487,7 @@
       end
       return tonode(head)
     end, 'add underlines to list')
+require'lua-ul-patches-preserve-attr'
 -- 
 --
 -- End of file `lua-ul.lua'.

Modified: trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty	2021-05-13 21:28:57 UTC (rev 59185)
+++ trunk/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty	2021-05-13 21:29:14 UTC (rev 59186)
@@ -20,7 +20,7 @@
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage
   {lua-ul}
-  [2021/04/25 v0.1.3 Underlining and related functionality for LuaTeX]
+  [2021/05/12 v0.1.4 Underlining and related functionality for LuaTeX]
 
 \ifx\directlua\undefined
   \PackageError{lua-ul}{LuaLaTeX required}%



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