summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-03-08 21:25:59 +0000
committerKarl Berry <karl@freefriends.org>2022-03-08 21:25:59 +0000
commitf4f10fd31bb21db819393080ec9c5f3e6733b9db (patch)
tree8762a376db9b594956c3f782bdd8ae1d28b3bc50 /Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl
parentb57ee0ffda4b8fe09e2a413a411713508780ad2c (diff)
lua-widow-control (8mar22)
git-svn-id: svn://tug.org/texlive/trunk@62525 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl')
-rw-r--r--Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl72
1 files changed, 49 insertions, 23 deletions
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 6eff5c9b00c..e24f972d577 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=1.1.6, %%version
+%D version=2.0.0, %%version
%D title=lua-widow-control,
%D subtitle=\ConTeXt module for lua-widow-control,
%D author=Max Chernoff,
-%D date=2022-02-22, %%date
+%D date=2022-03-07, %%dashdate
%D copyright=Max Chernoff,
%D license=MPL-2.0+,
%D url=https://github.com/gucci-on-fleek/lua-widow-control]
@@ -15,9 +15,9 @@
\installcommandhandler \????lwc {lwc} \????lwc
-\newdimen\lwcemergencystretch
+\newdimen\lwc_emergency_stretch
\appendtoks
- \lwcemergencystretch=\lwcparameter{emergencystretch}
+ \lwc_emergency_stretch=\lwcparameter{emergencystretch}
\to\everysetuplwc
\appendtoks
@@ -28,23 +28,49 @@
}
\to\everysetuplwc
+\appendtoks
+ \doifelse{\lwcparameter{debug}}\v!start{
+ \ctxlua{lwc.debug = true}
+ }{
+ \ctxlua{lwc.debug = false}
+ }
+\to\everysetuplwc
+
+\appendtoks
+ \ctxlua{lwc.nobreak_behaviour = "\lwcparameter{nobreak}"}
+\to\everysetuplwc
+
+\newcount\lwc_max_cost
+\appendtoks
+ \lwc_max_cost=\lwcparameter{maxcost}
+\to\everysetuplwc
+
+\appendtoks
+ % We can't just set the penalties because they will be reset automatically
+ % at \\starttext.
+ \startsetups[*default]
+ \clubpenalty=\lwcparameter{orphanpenalty}
+ \widowpenalty=\lwcparameter{widowpenalty}
+ \displaywidowpenalty=\lwcparameter{widowpenalty}
+ \stopsetups
+
+ \setups[*default]
+\to\everysetuplwc
+
\define\iflwc{\ctxlua{lwc.if_lwc_enabled()}}
\ctxloadluafile{lua-widow-control}
-\setuplwc[emergencystretch=3em, \c!state=\v!start]
-
-% We can't just set the penalties because they will be reset automatically
-% at \\starttext.
-\startsetups[*default]
- \clubpenalty=1
- \widowpenalty=1
- \displaywidowpenalty=0
- \interlinepenalty=0
- \brokenpenalty=0
-\stopsetups
+\setuplwc[
+ emergencystretch=3em,
+ \c!state=\v!start,
+ debug=\v!stop,
+ orphanpenalty=1,
+ widowpenalty=1,
+ nobreak=keep,
+ maxcost=2147483647,
+]
-\setups[*default]
% Here, we enable font expansion/contraction. It isn't strictly necessary for
% \lwc/'s functionality; however, it is required for the
@@ -55,23 +81,23 @@
% 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
+\newif\iflwc_should_reenable
-\define\lwc@patch@pre{%
+\define\lwc_patch_pre{%
\iflwc%
- \lwc@should@reenabletrue%
+ \lwc_should_reenabletrue%
\setuplwc[state=stop]%
\else%
- \lwc@should@reenablefalse
+ \lwc_should_reenablefalse
\fi%
}
-\define\lwc@patch@post{\iflwc@should@reenable%
+\define\lwc_patch_post{\iflwc_should_reenable%
\setuplwc[state=start]%
\fi}
-\prependtoks\lwc@patch@pre\to\everybeforesectionheadhandle % Sectioning
-\prependtoks\lwc@patch@post\to\everyaftersectionheadhandle
+\prependtoks\lwc_patch_pre\to\everybeforesectionheadhandle % Sectioning
+\prependtoks\lwc_patch_post\to\everyaftersectionheadhandle
\protect
\stopmodule