summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/lua-widow-control
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/generic/lua-widow-control')
-rw-r--r--macros/luatex/generic/lua-widow-control/README.md2
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.lua58
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.opm2
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.pdfbin385607 -> 385495 bytes
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.sty21
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.tex2
-rw-r--r--macros/luatex/generic/lua-widow-control/lwc-documentation.tex2
-rw-r--r--macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkiv4
-rw-r--r--macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl4
9 files changed, 44 insertions, 51 deletions
diff --git a/macros/luatex/generic/lua-widow-control/README.md b/macros/luatex/generic/lua-widow-control/README.md
index 6d61094c46..77dd7734da 100644
--- a/macros/luatex/generic/lua-widow-control/README.md
+++ b/macros/luatex/generic/lua-widow-control/README.md
@@ -48,4 +48,4 @@ Lua-widow-control is licensed under the [_Mozilla Public License_, version 2.0](
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.
---
-_v2.0.5 (2022-04-13)_ <!--%%version %%dashdate-->
+_v2.0.6 (2022-04-23)_ <!--%%version %%dashdate-->
diff --git a/macros/luatex/generic/lua-widow-control/lua-widow-control.lua b/macros/luatex/generic/lua-widow-control/lua-widow-control.lua
index 041b32b465..94dd85e145 100644
--- a/macros/luatex/generic/lua-widow-control/lua-widow-control.lua
+++ b/macros/luatex/generic/lua-widow-control/lua-widow-control.lua
@@ -23,7 +23,6 @@ local function debug_print(title, text)
end
end
-
--[[
\lwc/ is intended to be format-agonistic. It only runs on Lua\TeX{},
but there are still some slight differences between formats. Here, we
@@ -50,7 +49,7 @@ end
This is probably a useless micro-optimization, but it can't hurt.
]]
local last = node.slide
-local copy = node.copy_list
+local copy = node.copy_list or node.copylist
local par_id = node.id("par") or node.id("local_par")
local glue_id = node.id("glue")
local glyph_id = node.id("glyph")
@@ -61,19 +60,13 @@ local set_attribute = node.set_attribute or node.setattribute
local find_attribute = node.find_attribute or node.findattribute
local flush_list = node.flush_list or node.flushlist
local free = node.free
+local node_id = node.is_node or node.isnode
local min_col_width = tex.sp("250pt")
--[[
Package/module initialization
]]
-local warning,
- info,
- attribute,
- contrib_head,
- stretch_order,
- pagenum,
- emergencystretch,
- max_cost
+local warning, info, attribute, contrib_head, stretch_order, pagenum, emergencystretch, max_cost
if lmtx then
debug_print("LMTX")
@@ -107,8 +100,8 @@ elseif plain or latex or optex then
debug_print("Plain/LaTeX")
luatexbase.provides_module {
name = lwc.name,
- date = "2022/04/13", --%%slashdate
- version = "2.0.5", --%%version
+ date = "2022/04/23", --%%slashdate
+ version = "2.0.6", --%%version
description = [[
This module provides a LuaTeX-based solution to prevent
@@ -137,7 +130,6 @@ local function get_location()
return "At " .. pagenum() .. "/" .. #paragraphs
end
-
--[[
Function definitions
]]
@@ -223,12 +215,10 @@ local function get_chars(head)
debug_print(get_location(), chars)
end
-
function lwc.paragraph_cost(demerits, lines)
return demerits / math.sqrt(lines)
end
-
--- Saves each paragraph, but lengthened by 1 line
function lwc.save_paragraphs(head)
-- Ensure that we were actually given a par (only under \ConTeXt{} for some reason)
@@ -241,7 +231,7 @@ function lwc.save_paragraphs(head)
-- Prevent the "underfull hbox" warnings when we store a potential paragraph
local renable_box_warnings
if (context or optex) or
- #luatexbase.callback_descriptions("hpack_quality") == 0
+ #luatexbase.callback_descriptions("hpack_quality") == 0
then -- See #18 and michal-h21/linebreaker#3
renable_box_warnings = true
lwc.callbacks.disable_box_warnings.enable()
@@ -302,7 +292,6 @@ function lwc.save_paragraphs(head)
return head
end
-
local last_paragraph = 0
--- Tags the beginning and the end of each paragraph as it is added to the page.
---
@@ -330,7 +319,7 @@ local function safe_last(head)
local prev
while head.next do
- local id = node.is_node(head) -- Returns the internal node id
+ local id = node_id(head)
if ids[id] then
warning [[Circular node list detected!
@@ -377,19 +366,19 @@ function lwc.remove_widows(head)
The list of penalties is from:
https://tug.org/TUGboat/tb39-3/tb123mitt-widows-code.pdf#subsection.0.2.1
]]
- if penalty ~= 0 and
- penalty < 10000 and
- (penalty == widowpenalty or
- penalty == displaywidowpenalty or
- penalty == clubpenalty or
- penalty == clubpenalty + widowpenalty or
- penalty == clubpenalty + displaywidowpenalty or
- penalty == brokenpenalty or
- penalty == brokenpenalty + widowpenalty or
- penalty == brokenpenalty + displaywidowpenalty or
- penalty == brokenpenalty + clubpenalty or
- penalty == brokenpenalty + clubpenalty + widowpenalty or
- penalty == brokenpenalty + clubpenalty + displaywidowpenalty) and
+ if penalty ~= 0 and
+ penalty < 10000 and
+ (penalty == widowpenalty or
+ penalty == displaywidowpenalty or
+ penalty == clubpenalty or
+ penalty == clubpenalty + widowpenalty or
+ penalty == clubpenalty + displaywidowpenalty or
+ penalty == brokenpenalty or
+ penalty == brokenpenalty + widowpenalty or
+ penalty == brokenpenalty + displaywidowpenalty or
+ penalty == brokenpenalty + clubpenalty or
+ penalty == brokenpenalty + clubpenalty + widowpenalty or
+ penalty == brokenpenalty + clubpenalty + displaywidowpenalty) and
#paragraphs >= 1 then
else
paragraphs = {}
@@ -407,7 +396,7 @@ function lwc.remove_widows(head)
-- We find the current "best" replacement, then free the unused ones
for i, paragraph in pairs(paragraphs) do
if paragraph.cost < best_cost and
- i ~= last_paragraph
+ i ~= last_paragraph
then
-- Clear the old best paragraph
flush_list(paragraphs[paragraph_index].node)
@@ -432,7 +421,7 @@ function lwc.remove_widows(head)
)
if best_cost > tex.getcount(max_cost) or
- paragraph_index == last_paragraph
+ paragraph_index == last_paragraph
then
-- If the best replacement is too bad, we can't do anything
warning("Widow/Orphan NOT removed on page " .. pagenum())
@@ -523,7 +512,7 @@ function lwc.remove_widows(head)
end
info(
- "Widow/orphan successfully removed at paragraph "
+ "Widow/orphan successfully removed at paragraph "
.. paragraph_index
.. " on page "
.. pagenum()
@@ -642,7 +631,6 @@ local function silence_luatexbase()
end
end
-
-- Activate \lwc/
if plain or latex then
silence_luatexbase()
diff --git a/macros/luatex/generic/lua-widow-control/lua-widow-control.opm b/macros/luatex/generic/lua-widow-control/lua-widow-control.opm
index d96bab6c02..afae1aa6a6 100644
--- a/macros/luatex/generic/lua-widow-control/lua-widow-control.opm
+++ b/macros/luatex/generic/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.0.5>} %%version
+\_codedecl\lwcenable{lua-widow-control <v2.0.6>} %%version
\_namespace{lwc}
\_clubpenalty=1
diff --git a/macros/luatex/generic/lua-widow-control/lua-widow-control.pdf b/macros/luatex/generic/lua-widow-control/lua-widow-control.pdf
index 09fee6bcf3..3ab6e51886 100644
--- a/macros/luatex/generic/lua-widow-control/lua-widow-control.pdf
+++ b/macros/luatex/generic/lua-widow-control/lua-widow-control.pdf
Binary files differ
diff --git a/macros/luatex/generic/lua-widow-control/lua-widow-control.sty b/macros/luatex/generic/lua-widow-control/lua-widow-control.sty
index 62090c061b..a44b5af1da 100644
--- a/macros/luatex/generic/lua-widow-control/lua-widow-control.sty
+++ b/macros/luatex/generic/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.0.5}{2022-04-13} %%version %%dashdate
+\DeclareCurrentRelease{v2.0.6}{2022-04-23} %%version %%dashdate
% If this version of LaTeX doesn't support command hooks, then we load
% the last v1.1.X version of the package.
@@ -23,8 +23,8 @@
\ProvidesExplPackage
{lua-widow-control}
- {2022/04/13} %%slashdate
- {v2.0.5} %%version
+ {2022/04/23} %%slashdate
+ {v2.0.6} %%version
{Use Lua to remove widows and orphans}
% Unconditional Package Loads
@@ -72,7 +72,9 @@
}
% Define (most of) the keys
-\keys_define:nn { \c__lwc_name_str } {
+\cs_generate_variant:Nn \keys_define:nn { Vn }
+
+\keys_define:Vn { \c__lwc_name_str } {
emergencystretch .dim_gset:N = \g__lwc_emergencystretch_dim,
emergencystretch .value_required:n = true,
emergencystretch .initial:x = \dim_max:nn { 3em } { 30pt },
@@ -213,10 +215,10 @@
}
% Memoir
-\cs_gset_nopar:Npn \pen@ltyabovepfbreak { 23 } % GitHub #32
+\cs_gset_nopar:Npn \pen@ltyabovepfbreak { 23 } % Issue #32
% Define some final keys
-\keys_define:nn { \c__lwc_name_str } {
+\keys_define:Vn { \c__lwc_name_str } {
enable .choice:,
enable / true .code:n = \__lwc_enable:,
enable / false .code:n = \__lwc_disable:,
@@ -260,9 +262,12 @@
}
% Add the user interface for the keys
-\ProcessKeysPackageOptions{ \c__lwc_name_str }
+\exp_args:NV \ProcessKeysPackageOptions { \c__lwc_name_str }
-\NewDocumentCommand \lwcsetup {m} { \keys_set:nn{\c__lwc_name_str}{#1} }
+\cs_generate_variant:Nn \keys_set:nn { Vn }
+\NewDocumentCommand \lwcsetup {m} {
+ \keys_set:Vn { \c__lwc_name_str }{ #1 }
+}
% Legacy Commands
\NewDocumentCommand \lwcemergencystretch { } {
diff --git a/macros/luatex/generic/lua-widow-control/lua-widow-control.tex b/macros/luatex/generic/lua-widow-control/lua-widow-control.tex
index f467b0b432..b667d05c11 100644
--- a/macros/luatex/generic/lua-widow-control/lua-widow-control.tex
+++ b/macros/luatex/generic/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.0.5} %%version
+\wlog{lua-widow-control v2.0.6} %%version
\ifx\directlua\undefined
\errmessage{%
diff --git a/macros/luatex/generic/lua-widow-control/lwc-documentation.tex b/macros/luatex/generic/lua-widow-control/lwc-documentation.tex
index e6b7f0a0e0..7f05a344f0 100644
--- a/macros/luatex/generic/lua-widow-control/lwc-documentation.tex
+++ b/macros/luatex/generic/lua-widow-control/lwc-documentation.tex
@@ -37,7 +37,7 @@
\startdocument[
title=lua-widow-control,
author=Max Chernoff,
- version=2.0.5, %%version
+ version=2.0.6, %%version
github=https://github.com/gucci-on-fleek/lua-widow-control,
ctan=https://www.ctan.org/pkg/lua-widow-control,
]
diff --git a/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkiv b/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkiv
index 9ea5ee5ce2..1e52f8d901 100644
--- a/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkiv
+++ b/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkiv
@@ -1,10 +1,10 @@
%D \module
%D [ file=t-lua-widow-control,
-%D version=2.0.5, %%version
+%D version=2.0.6, %%version
%D title=lua-widow-control,
%D subtitle=\ConTeXt module for lua-widow-control,
%D author=Max Chernoff,
-%D date=2022-04-13, %%dashdate
+%D date=2022-04-23, %%dashdate
%D copyright=Max Chernoff,
%D license=MPL-2.0+,
%D url=https://github.com/gucci-on-fleek/lua-widow-control]
diff --git a/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl b/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl
index 9ea5ee5ce2..1e52f8d901 100644
--- a/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl
+++ b/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl
@@ -1,10 +1,10 @@
%D \module
%D [ file=t-lua-widow-control,
-%D version=2.0.5, %%version
+%D version=2.0.6, %%version
%D title=lua-widow-control,
%D subtitle=\ConTeXt module for lua-widow-control,
%D author=Max Chernoff,
-%D date=2022-04-13, %%dashdate
+%D date=2022-04-23, %%dashdate
%D copyright=Max Chernoff,
%D license=MPL-2.0+,
%D url=https://github.com/gucci-on-fleek/lua-widow-control]