From 9d61b4ef87dbbff2ff43f6b6af3b7299e496f0e7 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 8 Jun 2018 23:39:45 +0200 Subject: [PATCH] Versioning, compatibility level and penalties around lists --- test-ref.tex | 1 + test.tex | 1 + ucw-algo.tex | 3 +-- ucwmac.tex | 27 +++++++++++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/test-ref.tex b/test-ref.tex index 95915ab..4c05c66 100644 --- a/test-ref.tex +++ b/test-ref.tex @@ -1,4 +1,5 @@ \input ucwmac.tex +\ucwcompat\ucwmaxcompat \ucwmodule{ofs} \ucwmodule{ref} \ucwmodule{pdfmeta} diff --git a/test.tex b/test.tex index 42ffd77..26ecbd8 100644 --- a/test.tex +++ b/test.tex @@ -1,4 +1,5 @@ \input ucwmac.tex +\ucwcompat\ucwmaxcompat \input ucw-ofs.tex \input ucw-verb.tex \input ucw-algo.tex diff --git a/ucw-algo.tex b/ucw-algo.tex index e356ef4..420e31f 100644 --- a/ucw-algo.tex +++ b/ucw-algo.tex @@ -53,7 +53,6 @@ \def\algostep#1{\hbox to \algolabelwidth{\hss #1~~}} \def\algoinit{ - \goodbreak \begingroup \algospacing \inititemize @@ -68,7 +67,7 @@ \def\proc#1{\typedalgo{\localestr{alg:proc}}{#1}} \def\headlessalgo{\algoinit} -\def\endalgo{\goodbreak\endlist\endgroup} +\def\endalgo{\endlist\endgroup} \let\endproc=\endalgo \def\algoitem{% diff --git a/ucwmac.tex b/ucwmac.tex index 87c0b46..6c7a5de 100644 --- a/ucwmac.tex +++ b/ucwmac.tex @@ -231,12 +231,17 @@ \newbox\itembox \newcount\itemcount +% Penalties (changed at compatibility level 1) +\newcount\preitemizepenalty \preitemizepenalty=0 +\newcount\postitemizepenalty \postitemizepenalty=0 + \def\preitemize{ \ifitems \vskip\prenesteditemizeskip \advance\leftskip by \nesteditemindent \advance\rightskip by \nesteditemnarrow \else + \ifnum\preitemizepenalty=0\else\penalty\preitemizepenalty\fi \vskip\preitemizeskip \advance\leftskip by \itemindent \advance\rightskip by \itemnarrow @@ -248,6 +253,7 @@ \ifitems \vskip\postnesteditemizeskip \else + \ifnum\postitemizepenalty=0\else\penalty\postitemizepenalty\fi \vskip\postitemizeskip \fi } @@ -357,6 +363,27 @@ \expandafter\let\csname ucwmod:#1\endcsname=\relax } +% Compatibility levels +% We try to be backwards compatible as much as we can, so all changes in behavior +% (except for addition of new control sequences) are versioned. By default, ucwmac +% starts in compatibility level 0, which should produce the same results as historic +% versions of ucwmac. Use \ucwcompat{level} to upgrade to a given level, or if you +% do not care about compatibility, \ucwcompat\ucwmaxcompat. + +\chardef\ucwcurrentcompat=0 % Currently active compatibility level +\chardef\ucwmaxcompat=1 % Maximum supported compatibility level + +\def\ucwcompat#1{ + \ucwcurrentcompat=#1 + \ifcase #1 + % Level 0 (default): old ucwmac + \or % Level 1 + \preitemizepenalty=-500 + \postitemizepenalty=-500 + \else\errmessage{Unsupported compatibility level #1 requested.} + \fi +} + %%% Epilog %%% % Let's hide all internal macros -- 2.39.2