diff options
Diffstat (limited to 'Master/texmf-dist/tex')
7 files changed, 52 insertions, 35 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 e24f972d577..716e45dcf5f 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,10 +1,10 @@ %D \module %D [ file=t-lua-widow-control, -%D version=2.0.0, %%version +%D version=2.0.1, %%version %D title=lua-widow-control, %D subtitle=\ConTeXt module for lua-widow-control, %D author=Max Chernoff, -%D date=2022-03-07, %%dashdate +%D date=2022-03-18, %%dashdate %D copyright=Max Chernoff, %D license=MPL-2.0+, %D url=https://github.com/gucci-on-fleek/lua-widow-control] @@ -52,6 +52,7 @@ \clubpenalty=\lwcparameter{orphanpenalty} \widowpenalty=\lwcparameter{widowpenalty} \displaywidowpenalty=\lwcparameter{widowpenalty} + \brokenpenalty=\lwcparameter{brokenpenalty} \stopsetups \setups[*default] @@ -67,6 +68,7 @@ debug=\v!stop, orphanpenalty=1, widowpenalty=1, + brokenpenalty=1, nobreak=keep, maxcost=2147483647, ] @@ -74,7 +76,7 @@ % 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. +% lengthened paragraphs to not have terrible spacing. \definefontfeature[default][default][expansion=quality] \setupalign[hz] 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 e24f972d577..716e45dcf5f 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.0.0, %%version +%D version=2.0.1, %%version %D title=lua-widow-control, %D subtitle=\ConTeXt module for lua-widow-control, %D author=Max Chernoff, -%D date=2022-03-07, %%dashdate +%D date=2022-03-18, %%dashdate %D copyright=Max Chernoff, %D license=MPL-2.0+, %D url=https://github.com/gucci-on-fleek/lua-widow-control] @@ -52,6 +52,7 @@ \clubpenalty=\lwcparameter{orphanpenalty} \widowpenalty=\lwcparameter{widowpenalty} \displaywidowpenalty=\lwcparameter{widowpenalty} + \brokenpenalty=\lwcparameter{brokenpenalty} \stopsetups \setups[*default] @@ -67,6 +68,7 @@ debug=\v!stop, orphanpenalty=1, widowpenalty=1, + brokenpenalty=1, nobreak=keep, maxcost=2147483647, ] @@ -74,7 +76,7 @@ % 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. +% lengthened paragraphs to not have terrible spacing. \definefontfeature[default][default][expansion=quality] \setupalign[hz] 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 783db59ed22..e8b2eefb0a4 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 @@ -38,7 +38,7 @@ % 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. +% lengthened paragraphs to not have terrible spacing. \RequirePackage{etoolbox} \AtEndPreamble{ \@ifpackageloaded{microtype}{}{ % Only load if not already loaded 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 56462e40d87..fc80a58cfbb 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 @@ -5,7 +5,7 @@ % Formats built after 2015 include \LuaTeX{}Base, so this is the absolute % minimum version that we will run under. -\NeedsTeXFormat{LaTeX2e}[2015/01/01] +\NeedsTeXFormat{LaTeX2e}[2015/01/01] % For _really_ old formats \providecommand\DeclareRelease[3]{} @@ -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.0}{2022-03-07} %%version %%dashdate +\DeclareCurrentRelease{v2.0.1}{2022-03-18} %%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/03/07} %%slashdate - {v2.0.0} %%version + {2022/03/18} %%slashdate + {v2.0.1} %%version {Use Lua to remove widows and orphans} % Unconditional Package Loads @@ -44,15 +44,15 @@ \msg_new:nnn { \c__lwc_name_str } { patch-failed } - { + { Patching~ \c_backslash_str #1~ failed. \\ - Please~ ensure~ that~ \c_backslash_str #1~ exists. + Please~ ensure~ that~ \c_backslash_str #1~ exists. } \msg_new:nnn { \c__lwc_name_str } { old-format-patch } - { + { Patching~ not~ supported~ with~ old~ LaTeX. \\ Please~ use~ a~ LaTeX~ format~ >=~ 2021/06/01. } @@ -60,9 +60,9 @@ \msg_new:nnn { \c__lwc_name_str } { old-command } - { + { \c_backslash_str #1~ has~ been~ REMOVED! \\ - Please~ use~ \c_backslash_str setuplwc \c_left_brace_str #2 + Please~ use~ \c_backslash_str setuplwc \c_left_brace_str #2 \c_right_brace_str\ instead. } @@ -91,6 +91,10 @@ orphanpenalty .value_required:n = true, orphanpenalty .initial:n = 1, + brokenpenalty .int_gset:N = \tex_brokenpenalty:D, + brokenpenalty .value_required:n = true, + brokenpenalty .initial:x = 1, + microtype .bool_gset:N = \g__lwc_use_microtype_bool, microtype .value_required:n = true, microtype .initial:n = true, @@ -194,16 +198,16 @@ debug / false .code:n = \lua_now:n { lwc.debug = false }, strict .meta:n = { emergencystretch = 0pt, - max-cost = 2500, - nobreak = warn, + max-cost = 5000, + nobreak = warn, }, strict .value_forbidden:n = true, default .meta:n = { emergencystretch = 3em, max-cost = \c_max_int, - nobreak = keep, + nobreak = keep, }, - default .value_forbidden:n = true, + default .value_forbidden:n = true, } % Add the user interface for the keys 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 5801feef129..be9cab16cb9 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 @@ -107,8 +107,8 @@ elseif plain or latex or optex then debug_print("Plain/LaTeX") luatexbase.provides_module { name = lwc.name, - date = "2022/03/07", --%%slashdate - version = "2.0.0", --%%version + date = "2022/03/18", --%%slashdate + version = "2.0.1", --%%version description = [[ This module provides a LuaTeX-based solution to prevent @@ -182,7 +182,7 @@ local function register_callback(t) with \LuaTeX{}base, \ConTeXt{} leaves some \LuaTeX{} callbacks unregistered and unfrozen. Because of this, we need to register some callbacks at the engine level. This is fragile though, because a future \ConTeXt{} update - may decide to register one of these functions, in which case + may decide to register one of these functions, in which case \lwc/ will crash with a cryptic error message. ]] return { @@ -225,7 +225,7 @@ end function lwc.paragraph_cost(demerits, lines) - return demerits / (2 * math.sqrt(lines)) + return demerits / math.sqrt(lines) end @@ -299,14 +299,17 @@ 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. --- --- We add an attribute to the first and last node of each paragraph. The ID is --- some arbitrary number for \lwc/, and the value corresponds to the --- paragraphs index, which is negated for the end of the paragraph. function lwc.mark_paragraphs(head) - set_attribute(head, attribute, #paragraphs) - set_attribute(last(head), attribute, -1 * #paragraphs) + set_attribute(head, attribute, #paragraphs + (100 * pagenum())) + set_attribute(last(head), attribute, -1 * (#paragraphs + (100 * pagenum()))) + last_paragraph = #paragraphs return head end @@ -326,7 +329,7 @@ local function safe_last(head) if ids[id] then warning [[Circular node list detected! -This should never happen. I'll try and +This should never happen. I'll try and recover, but your output may be corrupted. (Internal Error)]] prev.next = nil @@ -385,7 +388,7 @@ function lwc.remove_widows(head) #paragraphs >= 1 then else paragraphs = {} - return head + return head_save end info("Widow/orphan detected. Attempting to remove.") @@ -398,7 +401,9 @@ 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 <= #paragraphs - 1 then + if paragraph.cost < best_cost and + i ~= last_paragraph + then -- Clear the old best paragraph flush_list(paragraphs[paragraph_index].node) paragraphs[paragraph_index].node = nil @@ -421,7 +426,9 @@ function lwc.remove_widows(head) ")" ) - if best_cost > tex.getcount(max_cost) then + if best_cost > tex.getcount(max_cost) or + 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()) paragraphs = {} @@ -488,7 +495,7 @@ function lwc.remove_widows(head) debug_print("remove_widows", "found " .. value) -- Insert the start of the replacement paragraph - if value == paragraph_index then + if value == paragraph_index + (100 * pagenum()) then debug_print("remove_widows", "replacement start") safe_last(target_node) -- Remove any loops @@ -497,7 +504,7 @@ function lwc.remove_widows(head) end -- Insert the end of the replacement paragraph - if value == -1 * paragraph_index then + if value == -1 * (paragraph_index + (100 * pagenum())) then debug_print("remove_widows", "replacement end") safe_last(target_node).next = head.next break 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 7a75e52132f..6d4f0722e35 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.0.0} %%version +\wlog{lua-widow-control v2.0.1} %%version \ifx\directlua\undefined \errmessage{% @@ -17,6 +17,7 @@ \clubpenalty=1 \widowpenalty=1 \displaywidowpenalty=1 +\brokenpenalty=1 \newdimen\lwcemergencystretch \lwcemergencystretch=3em @@ -28,7 +29,7 @@ % 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. +% lengthened paragraphs to not have terrible spacing. \expandglyphsinfont\the\font 20 20 5 \adjustspacing=2 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 992d817a5c8..8980ca60076 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,11 +3,12 @@ % SPDX-License-Identifier: MPL-2.0+ % SPDX-FileCopyrightText: 2022 Max Chernoff -\_codedecl\lwcenable{lua-widow-control <v2.0.0>} %%version +\_codedecl\lwcenable{lua-widow-control <v2.0.1>} %%version \_clubpenalty=1 \_widowpenalty=1 \_displaywidowpenalty=1 +\_brokenpenalty=1 \_newdimen\lwcemergencystretch \lwcemergencystretch=3em |