summaryrefslogtreecommitdiff
path: root/macros/luatex/generic
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-04-15 03:00:41 +0000
committerNorbert Preining <norbert@preining.info>2022-04-15 03:00:41 +0000
commitd82d72343a5dfcbc4ba14569fba7f9e34debdf71 (patch)
treee352abde532b9c5839b13499878d2b726f8d7e02 /macros/luatex/generic
parentef28ae824b7f6bc8e2b9c08443b53fd2ef37a781 (diff)
CTAN sync 202204150300
Diffstat (limited to 'macros/luatex/generic')
-rw-r--r--macros/luatex/generic/lua-widow-control/README.md2
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.lua4
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.opm61
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.pdfbin380127 -> 385607 bytes
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.sty24
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.tex44
-rw-r--r--macros/luatex/generic/lua-widow-control/lwc-documentation.tex6
-rw-r--r--macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkiv21
-rw-r--r--macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl21
9 files changed, 129 insertions, 54 deletions
diff --git a/macros/luatex/generic/lua-widow-control/README.md b/macros/luatex/generic/lua-widow-control/README.md
index 850f034f8e..6d61094c46 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.4 (2022-04-07)_ <!--%%version %%dashdate-->
+_v2.0.5 (2022-04-13)_ <!--%%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 2e374ac6e1..041b32b465 100644
--- a/macros/luatex/generic/lua-widow-control/lua-widow-control.lua
+++ b/macros/luatex/generic/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/04/07", --%%slashdate
- version = "2.0.4", --%%version
+ date = "2022/04/13", --%%slashdate
+ version = "2.0.5", --%%version
description = [[
This module provides a LuaTeX-based solution to prevent
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 6ff6281583..d96bab6c02 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,8 @@
% SPDX-License-Identifier: MPL-2.0+
% SPDX-FileCopyrightText: 2022 Max Chernoff
-\_codedecl\lwcenable{lua-widow-control <v2.0.4>} %%version
+\_codedecl\lwcenable{lua-widow-control <v2.0.5>} %%version
+\_namespace{lwc}
\_clubpenalty=1
\_widowpenalty=1
@@ -19,11 +20,61 @@
\_directlua{require "lua-widow-control"}
% Define \TeX{} wrappers for Lua functions
-\_def\lwcenable{\_directlua{lwc.enable_callbacks()}}
-\_def\lwcdisable{\_directlua{lwc.disable_callbacks()}}
-\_def\iflwc{\_directlua{lwc.if_lwc_enabled()}}
+\_def\.enable{\_directlua{lwc.enable_callbacks()}}
+\_def\.disable{\_directlua{lwc.disable_callbacks()}}
+\_def\.iflwc{\_directlua{lwc.if_lwc_enabled()}}
+
+\_let\lwcenable=\.enable
+\_let\lwcdisable=\.disable
% Enable \lwc/ by default when the package is loaded.
-\lwcenable
+\.enable
+
+% 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\.disable_count
+
+\_def\.patch_pre{%
+ \.iflwc%
+ \_advance\.disable_count by 1%
+ \.disable%
+ \_fi%
+}
+
+\_def\.patch_post{
+ \_ifnum\.disable_count>0%
+ \.enable%
+ \_advance\.disable_count by -1%
+ \_fi
+}
+
+\_def\.extractcomponents #1:#2->#3\STOP{%
+ \_def\.params{#2}%
+ \_def\.body{#3}%
+}
+
+\def\.disable_cmd#1{%
+ \_ifdefined#1%
+ \_ea\.extractcomponents\_meaning#1\STOP%
+ \_begingroup%
+ \_catcode`_=11%
+ \_expanded{%
+ \_noexpand\_scantokens{%
+ \_gdef\_noexpand#1\.params{%
+ \_noexpand\.patch_pre\.body\_noexpand\.patch_post%
+ }%
+ }%
+ }%
+ \_endgroup%
+ \_fi%
+}
+\_let\lwcdisablecmd=\.disable_cmd
+
+\.disable_cmd{\_printchap}
+\.disable_cmd{\_printsec}
+\.disable_cmd{\_printsecc}
+\_endnamespace
\_endcode
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 007b3136f0..09fee6bcf3 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 0690a23208..62090c061b 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.4}{2022-04-07} %%version %%dashdate
+\DeclareCurrentRelease{v2.0.5}{2022-04-13} %%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/07} %%slashdate
- {v2.0.4} %%version
+ {2022/04/13} %%slashdate
+ {v2.0.5} %%version
{Use Lua to remove widows and orphans}
% Unconditional Package Loads
@@ -154,26 +154,25 @@
% Expansion of some parts of the document, such as section headings, is quite
% undesirable, so we'll disable \lwc/ for certain commands.
-\bool_new:N \g__lwc_should_reenable_bool
+\int_new:N \g__lwc_disable_int
\cs_new:Npn \__lwc_patch_pre: {
% We should only reenable \lwc/ at the end if it was already enabled.
- \__lwc_if_enabled:TF {
- \bool_gset_true:N \g__lwc_should_reenable_bool
+ \__lwc_if_enabled:T {
+ \int_gincr:N \g__lwc_disable_int
\__lwc_disable:
- } {
- \bool_gset_false:N \g__lwc_should_reenable_bool
}
}
\cs_new:Npn \__lwc_patch_post: {
- \bool_if:NT { \g__lwc_should_reenable_bool } {
+ \int_compare:nT { \g__lwc_disable_int > 0 } {
\__lwc_enable:
+ \int_gdecr:N \g__lwc_disable_int
}
}
\cs_new:Npn \__lwc_patch_cmd:c #1 {
- \IfFormatAtLeastTF {2021/06/01 } {
+ \IfFormatAtLeastTF { 2021/06/01 } {
\hook_gput_code:nnn { cmd / #1 / before } { \c__lwc_name_str } {
\__lwc_patch_pre:
}
@@ -205,12 +204,17 @@
\clist_map_function:NN \g__lwc_disablecmds_cl \__lwc_patch_cmd:n
}
+%%% Class and package-specifc patches
+
% KOMA-Script
\cs_if_exist:NT \AddtoDoHook {
\AddtoDoHook { heading / begingroup } { \__lwc_patch_pre: \use_none:n }
\AddtoDoHook { heading / endgroup } { \__lwc_patch_post: \use_none:n }
}
+% Memoir
+\cs_gset_nopar:Npn \pen@ltyabovepfbreak { 23 } % GitHub #32
+
% Define some final keys
\keys_define:nn { \c__lwc_name_str } {
enable .choice:,
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 4ff5bd993b..f467b0b432 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.4} %%version
+\wlog{lua-widow-control v2.0.5} %%version
\ifx\directlua\undefined
\errmessage{%
@@ -12,6 +12,8 @@
}
\fi
+\catcode`@=11
+
\input ltluatex % \LuaTeX{}Base
\clubpenalty=1
@@ -43,34 +45,50 @@
% Expansion of some parts of the document, such as section headings, is quite
% undesirable, so we'll disable \lwc/ for certain commands.
-\catcode`@=11
% We should only reenable \lwc/ at the end if it was already enabled.
-\newif\iflwc@should@reenable
+\newcount\lwc@disable@count
\def\lwc@patch@pre{%
\iflwc%
- \lwc@should@reenabletrue%
+ \advance\lwc@disable@count by 1%
\lwcdisable%
- \else%
- \lwc@should@reenablefalse%
\fi%
}
-\def\lwc@patch@post{\iflwc@should@reenable%
- \lwcenable%
-\fi}
+\def\lwc@patch@post{
+ \ifnum\lwc@disable@count>0%
+ \lwcenable%
+ \advance\lwc@disable@count by -1%
+ \fi
+}
+
+\def\lwc@extractcomponents #1:#2->#3\STOP{%
+ \def\lwc@params{#2}%
+ \def\lwc@body{#3}%
+}
\def\lwcdisablecmd#1{%
- \ifdefined#1
- \expandafter\def\expandafter#1\expandafter{\lwc@patch@pre #1\lwc@patch@post}
- \fi
+ \ifdefined#1%
+ \expandafter\lwc@extractcomponents\meaning#1\STOP%
+ \begingroup%
+ \catcode`@=11%
+ \expanded{%
+ \noexpand\scantokens{%
+ \gdef\noexpand#1\lwc@params{%
+ \noexpand\lwc@patch@pre\lwc@body\noexpand\lwc@patch@post%
+ }%
+ }%
+ }%
+ \endgroup%
+ \fi%
}
-\catcode`@=12
\begingroup
\suppressoutererror=1
\lwcdisablecmd{\beginsection} % Sectioning
\endgroup
+
+\catcode`@=12
\endinput
diff --git a/macros/luatex/generic/lua-widow-control/lwc-documentation.tex b/macros/luatex/generic/lua-widow-control/lwc-documentation.tex
index 8d59b2a735..e6b7f0a0e0 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.4, %%version
+ version=2.0.5, %%version
github=https://github.com/gucci-on-fleek/lua-widow-control,
ctan=https://www.ctan.org/pkg/lua-widow-control,
]
@@ -310,12 +310,12 @@ Sometimes, you may want to disable \lwc/ for certain commands where stretching i
You could just disable then reenable \lwc/ every time that you use the command; however, \lwc/ provides a convenience macro that will do this automatically for you.
-\Lwc/ automatically patches the default \LaTeX{}, \ConTeXt{}, and Plain~\TeX{} section commands, so you shouldn't need to patch these yourself. \Lwc/ also patches the commands provided by \sans{memoir}, \sans{\acronym{KOMA}-script}, and \sans{titlesec}. You'll need to patch any other section commands yourself.
+\Lwc/ automatically patches the default \LaTeX{}, \ConTeXt{}, Plain~\TeX{}, and Op\TeX{} section commands, so you shouldn't need to patch these yourself. \Lwc/ also patches the commands provided by \sans{memoir}, \sans{\acronym{KOMA}-script}, and \sans{titlesec}. You'll need to patch any other section commands yourself.
Note that the \LaTeX{} option does not \emph{append} commands to the disable list; rather, it \emph{sets} the list from scratch. This means that you can set an empty list to disable any command patching; however, this also means that if you want to disable one command on top of the defaults, you'll also need to manually include the default list.
\startTABLE
- \NC Plain \TeX{}
+ \NC \plainop/
\NC \inlineTEX{\lwcdisablecmd{$\meta{\backslash macro}$}}
\NC\NR
\NC \LaTeX{}
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 83f72b3905..9ea5ee5ce2 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.4, %%version
+%D version=2.0.5, %%version
%D title=lua-widow-control,
%D subtitle=\ConTeXt module for lua-widow-control,
%D author=Max Chernoff,
-%D date=2022-04-07, %%dashdate
+%D date=2022-04-13, %%dashdate
%D copyright=Max Chernoff,
%D license=MPL-2.0+,
%D url=https://github.com/gucci-on-fleek/lua-widow-control]
@@ -83,20 +83,21 @@
% 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.
-\newif\iflwc_should_reenable
+\newcount\lwc_disable_count
\define\lwc_patch_pre{%
\iflwc%
- \lwc_should_reenabletrue%
- \setuplwc[state=stop]%
- \else%
- \lwc_should_reenablefalse
+ \advance\lwc_disable_count by 1%
+ \setuplwc[\c!state=\v!stop]%
\fi%
}
-\define\lwc_patch_post{\iflwc_should_reenable%
- \setuplwc[state=start]%
-\fi}
+\define\lwc_patch_post{
+ \ifnum\lwc_disable_count>0%
+ \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
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 83f72b3905..9ea5ee5ce2 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.4, %%version
+%D version=2.0.5, %%version
%D title=lua-widow-control,
%D subtitle=\ConTeXt module for lua-widow-control,
%D author=Max Chernoff,
-%D date=2022-04-07, %%dashdate
+%D date=2022-04-13, %%dashdate
%D copyright=Max Chernoff,
%D license=MPL-2.0+,
%D url=https://github.com/gucci-on-fleek/lua-widow-control]
@@ -83,20 +83,21 @@
% 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.
-\newif\iflwc_should_reenable
+\newcount\lwc_disable_count
\define\lwc_patch_pre{%
\iflwc%
- \lwc_should_reenabletrue%
- \setuplwc[state=stop]%
- \else%
- \lwc_should_reenablefalse
+ \advance\lwc_disable_count by 1%
+ \setuplwc[\c!state=\v!stop]%
\fi%
}
-\define\lwc_patch_post{\iflwc_should_reenable%
- \setuplwc[state=start]%
-\fi}
+\define\lwc_patch_post{
+ \ifnum\lwc_disable_count>0%
+ \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