summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-05-20 21:38:27 +0000
committerKarl Berry <karl@freefriends.org>2022-05-20 21:38:27 +0000
commitfc716f318871295dd96471dd48dd08c117faab50 (patch)
treef6bb74a345d0b69af810207c2c4883717d997f6f /Master/texmf-dist/tex
parent59514af7db4b65b7f3a143dfbad7c80896dc7d1c (diff)
lua-widow-control (20may22)
git-svn-id: svn://tug.org/texlive/trunk@63345 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkiv105
-rw-r--r--Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl4
-rw-r--r--Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control-2022-02-22.sty4
-rw-r--r--Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty8
-rw-r--r--Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.lua28
-rw-r--r--Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.tex2
-rw-r--r--Master/texmf-dist/tex/optex/lua-widow-control/lua-widow-control.opm2
7 files changed, 36 insertions, 117 deletions
diff --git a/Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkiv b/Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkiv
index 090ff5aa809..5f277c2b144 100644
--- a/Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkiv
+++ b/Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkiv
@@ -1,104 +1 @@
-%D \module
-%D [ file=t-lua-widow-control,
-%D version=2.1.0, %%version
-%D title=lua-widow-control,
-%D subtitle=\ConTeXt module for lua-widow-control,
-%D author=Max Chernoff,
-%D date=2022-05-14, %%dashdate
-%D copyright=Max Chernoff,
-%D license=MPL-2.0+,
-%D url=https://github.com/gucci-on-fleek/lua-widow-control]
-\startmodule[lua-widow-control]
-\unprotect
-
-\installnamespace{lwc}
-
-\installcommandhandler \????lwc {lwc} \????lwc
-
-\newdimen\lwc_emergency_stretch
-\newcount\lwc_max_cost
-\appendtoks
- \lwc_emergency_stretch=\lwcparameter{emergencystretch}
-
- \doifelse{\lwcparameter{\c!state}}\v!start{
- \lwc_enable
- }{
- \lwc_disable
- }
-
- \lwc_debug{\lwcparameter{debug}}
-
- \lwc_nobreak{\lwcparameter{nobreak}}
-
- \lwc_max_cost=\lwcparameter{maxcost}
-
- % We can't just set the penalties because they will be reset automatically
- % at \\starttext.
- \startsetups[*default]
- \directsetup{*reset}
-
- \clubpenalty=\lwcparameter{orphanpenalty}
- \widowpenalty=\lwcparameter{widowpenalty}
- \displaywidowpenalty=\lwcparameter{widowpenalty}
- \brokenpenalty=\lwcparameter{brokenpenalty}
- \stopsetups
-
- \startsetups[grid][*default]
- \directsetup{*reset}
-
- \clubpenalty=\lwcparameter{orphanpenalty}
- \widowpenalty=\lwcparameter{widowpenalty}
- \displaywidowpenalty=\lwcparameter{widowpenalty}
- \brokenpenalty=\lwcparameter{brokenpenalty}
- \stopsetups
-
- \setups[*default]
-\to\everysetuplwc
-
-\ctxloadluafile{lua-widow-control}
-
-\setuplwc[
- emergencystretch=3em,
- \c!state=\v!start,
- debug=\v!stop,
- orphanpenalty=1,
- widowpenalty=1,
- brokenpenalty=1,
- nobreak=keep,
- maxcost=2147483647,
-]
-
-
-% 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.
-\definefontfeature[default][default][expansion=quality]
-\setupalign[hz]
-
-% Expansion of some parts of the document, such as section headings, is quite
-% undesirable, so we'll disable \lwc/ for certain commands.
-% We should only reenable \lwc/ at the end if it was already enabled.
-\newcount\lwc_disable_count
-
-\define\lwc_patch_pre{%
- \lwc_if_enabled%
- \advance\lwc_disable_count by 1%
- \setuplwc[\c!state=\v!stop]%
- \fi%
-}
-
-\define\lwc_patch_post{
- \ifnum\lwc_disable_count>0\relax%
- \setuplwc[\c!state=\v!start]%
- \advance\lwc_disable_count by -1%
- \fi%
-}
-
-\prependtoks\lwc_patch_pre\to\everybeforesectionheadhandle % Sectioning
-\prependtoks\lwc_patch_post\to\everyaftersectionheadhandle
-
-% Make the commands public
-\let\iflwc=\lwc_if_enabled
-
-\protect
-\stopmodule
+\input t-lua-widow-control.mkxl
diff --git a/Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl b/Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl
index 090ff5aa809..13637756ae4 100644
--- a/Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl
+++ b/Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl
@@ -1,10 +1,10 @@
%D \module
%D [ file=t-lua-widow-control,
-%D version=2.1.0, %%version
+%D version=2.1.1, %%version
%D title=lua-widow-control,
%D subtitle=\ConTeXt module for lua-widow-control,
%D author=Max Chernoff,
-%D date=2022-05-14, %%dashdate
+%D date=2022-05-20, %%dashdate
%D copyright=Max Chernoff,
%D license=MPL-2.0+,
%D url=https://github.com/gucci-on-fleek/lua-widow-control]
diff --git a/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control-2022-02-22.sty b/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control-2022-02-22.sty
index d67c68d2fd3..16f01966ee9 100644
--- a/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control-2022-02-22.sty
+++ b/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control-2022-02-22.sty
@@ -12,8 +12,8 @@
% report a real version number here for debugging.
\PackageInfo{lua-widow-control}{%
Real version:
- 2022/05/14 %%dashdate
- v2.1.0 %%version
+ 2022/05/20 %%dashdate
+ v2.1.1 %%version
}
\PackageWarning{lua-widow-control}{%
diff --git a/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty b/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty
index e7179e6a9e5..0e3462d22b3 100644
--- a/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty
+++ b/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty
@@ -13,7 +13,7 @@
\DeclareRelease{}{0000-00-00}{lua-widow-control-2022-02-22.sty}
\DeclareRelease{v1.1.6}{2022-02-22}{lua-widow-control-2022-02-22.sty}
-\DeclareCurrentRelease{v2.1.0}{2022-05-14} %%version %%dashdate
+\DeclareCurrentRelease{v2.1.1}{2022-05-20} %%version %%dashdate
% If this version of LaTeX doesn't support command hooks, then we load
% the last v1.1.X version of the package.
@@ -24,7 +24,7 @@
\ProvidesExplPackage
{lua-widow-control}
{2022/05/14} %%dashdate
- {v2.1.0} %%version
+ {v2.1.1} %%version
{Use Lua to remove widows and orphans}
% Unconditional Package Loads
@@ -121,8 +121,8 @@
% 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.
-\bool_if:NT \g__lwc_use_microtype_bool {
- \hook_gput_code:nnn { begindocument / before } { \c__lwc_name_str } {
+\hook_gput_code:nnn { begindocument / before } { \c__lwc_name_str } {
+ \bool_if:NT \g__lwc_use_microtype_bool {
\@ifpackageloaded { microtype } {} {
\RequirePackage[
final,
diff --git a/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.lua b/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.lua
index 45360db2092..2af55757994 100644
--- a/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.lua
+++ b/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.lua
@@ -62,9 +62,9 @@ if format:find("cont") then -- cont-en, cont-fr, cont-nl, ...
end
elseif format:find("latex") then -- lualatex, lualatex-dev, ...
latex = true
-elseif format == "luatex" then -- Plain
+elseif format == "luatex" or format == "luahbtex" then -- Plain
plain = true
-elseif format == "optex" then -- OpTeX
+elseif format:find("optex") then -- OpTeX
optex = true
end
@@ -83,6 +83,7 @@ local par_id = node.id("par") or node.id("local_par")
local penalty_id = node.id("penalty")
-- Local versions of globals
+local abs = math.abs
local copy = node.copy_list or node.copylist
local find_attribute = node.find_attribute or node.findattribute
local flush_list = node.flush_list or node.flushlist
@@ -96,6 +97,7 @@ local set_attribute = node.set_attribute or node.setattribute
local string_char = string.char
local traverse = node.traverse
local traverseid = node.traverse_id or node.traverseid
+local vpack = node.vpack
-- Misc. Constants
local iffalse = token.create("iffalse")
@@ -160,7 +162,7 @@ elseif plain or latex or optex then
luatexbase.provides_module {
name = lwc.name,
date = "2022/05/14", --%%dashdate
- version = "2.1.0", --%%version
+ version = "2.1.1", --%%version
description = [[
This module provides a LuaTeX-based solution to prevent
@@ -502,6 +504,9 @@ function lwc.remove_widows(head)
info("Widow/orphan/broken hyphen detected. Attempting to remove")
+ local vsize = tex.dimen.vsize
+ local orig_height_diff = vpack(head).height - vsize
+
--[[
Find the paragraph on the page with the least cost.
]]
@@ -698,6 +703,23 @@ function lwc.remove_widows(head)
end
end
+ local new_height_diff = vpack(head_save).height - vsize
+ -- We need the original height discrepancy in case there are \\vfill's
+ local net_height_diff = orig_height_diff - new_height_diff
+
+ --[[ The final \\box255 needs to be exactly \\vsize tall to avoid
+ over/underfull box warnings, so we correct any discrepancies
+ here.
+ ]]
+ if abs(net_height_diff) > 0 and
+ -- A difference larger than 0.25\\baselineskip is probably not from \lwc/
+ abs(net_height_diff) < tex.skip.baselineskip.width / 4
+ then
+ local bottom_glue = new_node("glue")
+ bottom_glue.width = net_height_diff
+ last(head_save).next = bottom_glue
+ end
+
info(
"Widow/orphan/broken hyphen successfully removed at paragraph "
.. paragraph_index
diff --git a/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.tex b/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.tex
index 78385ad698d..5c2c93662f8 100644
--- a/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.tex
+++ b/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.tex
@@ -3,7 +3,7 @@
% SPDX-License-Identifier: MPL-2.0+
% SPDX-FileCopyrightText: 2022 Max Chernoff
-\wlog{lua-widow-control v2.1.0} %%version
+\wlog{lua-widow-control v2.1.1} %%version
\ifx\directlua\undefined
\errmessage{%
diff --git a/Master/texmf-dist/tex/optex/lua-widow-control/lua-widow-control.opm b/Master/texmf-dist/tex/optex/lua-widow-control/lua-widow-control.opm
index cb6f4c06f97..a9edffc77c5 100644
--- a/Master/texmf-dist/tex/optex/lua-widow-control/lua-widow-control.opm
+++ b/Master/texmf-dist/tex/optex/lua-widow-control/lua-widow-control.opm
@@ -3,7 +3,7 @@
% SPDX-License-Identifier: MPL-2.0+
% SPDX-FileCopyrightText: 2022 Max Chernoff
-\_codedecl\lwcenable{lua-widow-control <v2.1.0>} %%version
+\_codedecl\lwcenable{lua-widow-control <v2.1.1>} %%version
\_namespace{lwc}
\_clubpenalty=1