From b58ee08a4c930684f420d4f7cf5fca4b804f7744 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 22 Feb 2022 21:11:36 +0000 Subject: lua-widow-control (22feb22) git-svn-id: svn://tug.org/texlive/trunk@62144 c570f23f-e606-0410-a88d-b1316a301751 --- .../lua-widow-control/t-lua-widow-control.mkiv | 77 ++++++++++++++++++++++ .../lua-widow-control/t-lua-widow-control.mkxl | 16 +++-- 2 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkiv (limited to 'Master/texmf-dist/tex/context') 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 new file mode 100644 index 00000000000..6eff5c9b00c --- /dev/null +++ b/Master/texmf-dist/tex/context/third/lua-widow-control/t-lua-widow-control.mkiv @@ -0,0 +1,77 @@ +%D \module +%D [ file=t-lua-widow-control, +%D version=1.1.6, %%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 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\lwcemergencystretch +\appendtoks + \lwcemergencystretch=\lwcparameter{emergencystretch} +\to\everysetuplwc + +\appendtoks + \doifelse{\lwcparameter{\c!state}}\v!start{ + \ctxlua{lwc.enable_callbacks()} + }{ + \ctxlua{lwc.disable_callbacks()} + } +\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 + +\setups[*default] + +% 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. +\newif\iflwc@should@reenable + +\define\lwc@patch@pre{% + \iflwc% + \lwc@should@reenabletrue% + \setuplwc[state=stop]% + \else% + \lwc@should@reenablefalse + \fi% +} + +\define\lwc@patch@post{\iflwc@should@reenable% + \setuplwc[state=start]% +\fi} + +\prependtoks\lwc@patch@pre\to\everybeforesectionheadhandle % Sectioning +\prependtoks\lwc@patch@post\to\everyaftersectionheadhandle + +\protect +\stopmodule 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 b38d6eda018..6eff5c9b00c 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.5, %%version +%D version=1.1.6, %%version %D title=lua-widow-control, %D subtitle=\ConTeXt module for lua-widow-control, %D author=Max Chernoff, -%D date=2022-02-15, %%date +%D date=2022-02-22, %%date %D copyright=Max Chernoff, %D license=MPL-2.0+, %D url=https://github.com/gucci-on-fleek/lua-widow-control] @@ -57,10 +57,14 @@ % We should only reenable \lwc/ at the end if it was already enabled. \newif\iflwc@should@reenable -\define\lwc@patch@pre{\iflwc% - \lwc@should@reenabletrue% - \setuplwc[state=stop]% -\fi} +\define\lwc@patch@pre{% + \iflwc% + \lwc@should@reenabletrue% + \setuplwc[state=stop]% + \else% + \lwc@should@reenablefalse + \fi% +} \define\lwc@patch@post{\iflwc@should@reenable% \setuplwc[state=start]% -- cgit v1.2.3