texlive[62050] Master/texmf-dist: lua-widow-control (15feb22)
commits+karl at tug.org
commits+karl at tug.org
Wed Feb 16 23:45:21 CET 2022
Revision: 62050
http://tug.org/svn/texlive?view=revision&revision=62050
Author: karl
Date: 2022-02-16 23:45:21 +0100 (Wed, 16 Feb 2022)
Log Message:
-----------
lua-widow-control (15feb22)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/luatex/lua-widow-control/README.md
trunk/Master/texmf-dist/doc/luatex/lua-widow-control/lua-widow-control.pdf
trunk/Master/texmf-dist/source/luatex/lua-widow-control/lwc-documentation.tex
trunk/Master/texmf-dist/source/luatex/lua-widow-control/lwc-sample.tex
trunk/Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl
trunk/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty
trunk/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.lua
trunk/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.tex
Modified: trunk/Master/texmf-dist/doc/luatex/lua-widow-control/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/lua-widow-control/README.md 2022-02-16 22:44:32 UTC (rev 62049)
+++ trunk/Master/texmf-dist/doc/luatex/lua-widow-control/README.md 2022-02-16 22:45:21 UTC (rev 62050)
@@ -42,4 +42,4 @@
Please note that a compiled document is absolutely **not** considered to be an "Executable Form" as defined by the MPL. The use of lua-widow-control in a document does not place **any** obligations on the document's author or distributors. The MPL and CC-BY-SA licenses **only** apply to you if you distribute the lua-widow-control source code or documentation.
---
-_v1.1.4 (2022-02-04)_ <!--%%version %%date-->
+_v1.1.5 (2022-02-15)_ <!--%%version %%date-->
Modified: trunk/Master/texmf-dist/doc/luatex/lua-widow-control/lua-widow-control.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/luatex/lua-widow-control/lwc-documentation.tex
===================================================================
--- trunk/Master/texmf-dist/source/luatex/lua-widow-control/lwc-documentation.tex 2022-02-16 22:44:32 UTC (rev 62049)
+++ trunk/Master/texmf-dist/source/luatex/lua-widow-control/lwc-documentation.tex 2022-02-16 22:45:21 UTC (rev 62050)
@@ -37,7 +37,7 @@
\startdocument[
title=lua-widow-control,
author=Max Chernoff,
- version=1.1.4, %%version
+ version=1.1.5, %%version
github=https://github.com/gucci-on-fleek/lua-widow-control,
ctan=https://www.ctan.org/pkg/lua-widow-control,
]
Modified: trunk/Master/texmf-dist/source/luatex/lua-widow-control/lwc-sample.tex
===================================================================
--- trunk/Master/texmf-dist/source/luatex/lua-widow-control/lwc-sample.tex 2022-02-16 22:44:32 UTC (rev 62049)
+++ trunk/Master/texmf-dist/source/luatex/lua-widow-control/lwc-sample.tex 2022-02-16 22:45:21 UTC (rev 62050)
@@ -34,6 +34,8 @@
\setupalign[hz,hanging,tolerant]
+ \setuplanguage[en][spacing=packed]
+
\starttext
\Lwc/ can remove most widows and orphans from a document, \emph{without} stretching any glue or shortening any pages.
Modified: trunk/Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl
===================================================================
--- trunk/Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl 2022-02-16 22:44:32 UTC (rev 62049)
+++ trunk/Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl 2022-02-16 22:45:21 UTC (rev 62050)
@@ -1,10 +1,10 @@
%D \module
%D [ file=t-lua-widow-control,
-%D version=1.1.4, %%version
+%D version=1.1.5, %%version
%D title=lua-widow-control,
%D subtitle=\ConTeXt module for lua-widow-control,
%D author=Max Chernoff,
-%D date=2022-02-04, %%date
+%D date=2022-02-15, %%date
%D copyright=Max Chernoff,
%D license=MPL-2.0+,
%D url=https://github.com/gucci-on-fleek/lua-widow-control]
Modified: trunk/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty 2022-02-16 22:44:32 UTC (rev 62049)
+++ trunk/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty 2022-02-16 22:45:21 UTC (rev 62050)
@@ -5,8 +5,15 @@
\NeedsTeXFormat{LaTeX2e}[2015/01/01] % Formats built after 2015 include \LuaTeX{}Base
\ProvidesPackage{lua-widow-control}%
- [2022/02/04 v1.1.4] %%version %%date
+ [2022/02/15 v1.1.5] %%version %%date
+\ifdefined\directlua\else
+ \PackageError{lua-widow-control}{%
+ LuaTeX is required for this package.\MessageBreak
+ Make sure to compile with `lualatex'%
+ }{}
+\fi
+
\clubpenalty=1
\widowpenalty=1
\displaywidowpenalty=0
@@ -22,7 +29,15 @@
% Here, we enable font expansion/contraction. It isn't strictly necessary for
% \lwc/'s functionality; however, it is required for the
% lengthened paragraphs to not have terrible spacing.
-\RequirePackage[final]{microtype}
+\RequirePackage{etoolbox}
+\AtEndPreamble{
+ \@ifpackageloaded{microtype}{}{ % Only load if not already loaded
+ \RequirePackage[
+ final,
+ activate={true,nocompatibility}
+ ]{microtype}
+ }
+}
% Define \TeX{} wrappers for Lua functions
\newcommand{\lwcenable}{\directlua{lwc.enable_callbacks()}}
@@ -34,8 +49,6 @@
% Expansion of some parts of the document, such as section headings, is quite
% undesirable, so we'll disable \lwc/ for certain commands.
-\RequirePackage{etoolbox}
-
\newcommand{\lwc at patch@warning}[1]{\PackageWarning{lua-widow-control}{%
Patching the \protect#1 command failed%
}}
Modified: trunk/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.lua 2022-02-16 22:44:32 UTC (rev 62049)
+++ trunk/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.lua 2022-02-16 22:45:21 UTC (rev 62050)
@@ -59,14 +59,16 @@
]]
if lwc.context then
lwc.warning = logs.reporter("module", lwc.name)
+ lwc.info = logs.reporter("module", lwc.name)
lwc.attribute = attributes.public(lwc.name)
lwc.contrib_head = 'contributehead' -- For \LuaMetaTeX{}
lwc.stretch_order = "stretchorder"
+ lwc.pagenum = function () return tex.count["realpageno"] end
elseif lwc.plain or lwc.latex then
luatexbase.provides_module {
name = lwc.name,
- date = "2022/02/04", --%%date
- version = "1.1.4", --%%version
+ date = "2022/02/15", --%%date
+ version = "1.1.5", --%%version
description = [[
This module provides a LuaTeX-based solution to prevent
@@ -76,9 +78,11 @@
]],
}
lwc.warning = function(str) luatexbase.module_warning(lwc.name, str) end
+ lwc.info = function(str) luatexbase.module_info(lwc.name, str) end
lwc.attribute = luatexbase.new_attribute(lwc.name)
lwc.contrib_head = 'contrib_head' -- For \LuaTeX{}
lwc.stretch_order = "stretch_order"
+ lwc.pagenum = function () return tex.count[0] end
else -- uh oh
error [[
Unsupported format.
@@ -222,20 +226,28 @@
---
--- Sometimes the node list can form a loop. Since there is no last element
--- of a looped linked-list, the `last()` function will never terminate. This
---- function provides a "safe" version of the `last()` function that returns
---- `nil` if the list is circular.
+--- function provides a "safe" version of the `last()` function that will break
+--- the loop at the end if the list is circular.
local function safe_last(head)
local ids = {}
+ local prev
while head.next do
local id = node.is_node(head) -- Returns the internal node id
if ids[id] then
- lwc.warning("Circular node list detected!")
- return nil
+ lwc.warning [[Circular node list detected!
+This should never happen. I'll try and recover, but your output may be
+corrupted. As a workaround, disable lua-widow-control for the
+affected paragraph or change the page breaks in your document.]]
+
+ prev.next = nil
+ return prev
end
ids[id] = true
+ head.prev = prev
+ prev = head
head = head.next
end
@@ -265,6 +277,8 @@
return head
end
+ lwc.info("Widow/orphan detected. Attempting to remove.")
+
local head_save = head -- Save the start of the `head` linked-list
--[[
@@ -296,22 +310,15 @@
while head do
-- Insert the start of the replacement paragraph
if has_attribute(head, lwc.attribute, paragraph_index) then
- local current = head
+ safe_last(target_node) -- Remove any loops
+
head.prev.next = target_node
-
- -- Abort if we've created a loop
- if not safe_last(target_node) then
- head.prev.next = current
- lwc.warning("Widow/Orphan NOT removed!")
- break
- end
-
clear_flag = true
end
-- Insert the end of the replacement paragraph
if has_attribute(head, lwc.attribute, -1 * paragraph_index) then
- last(target_node).next = head.next
+ safe_last(target_node).next = head.next
clear_flag = false
end
@@ -324,6 +331,13 @@
last(head).prev.prev.next = nil
-- Move the last line to the next page
tex.lists[lwc.contrib_head] = last_line
+ lwc.info(
+ "Widow/orphan successfully removed at paragraph "
+ .. paragraph_index
+ .. " on page "
+ .. lwc.pagenum()
+ .. "."
+ )
end
if clear_flag then
Modified: trunk/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.tex
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.tex 2022-02-16 22:44:32 UTC (rev 62049)
+++ trunk/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.tex 2022-02-16 22:45:21 UTC (rev 62050)
@@ -3,8 +3,15 @@
% SPDX-License-Identifier: MPL-2.0+
% SPDX-FileCopyrightText: 2021 Max Chernoff
-\wlog{lua-widow-control v1.1.4} %%version
+\wlog{lua-widow-control v1.1.5} %%version
+\ifx\directlua\undefined
+ \errmessage{%
+ LuaTeX is required for this package.
+ Make sure to compile with `luatex'%
+ }
+\fi
+
\input ltluatex % \LuaTeX{}Base
\clubpenalty=1
More information about the tex-live-commits
mailing list.