]> mj.ucw.cz Git - ucwmac.git/commitdiff
Versioning, compatibility level and penalties around lists
authorMartin Mares <mj@ucw.cz>
Fri, 8 Jun 2018 21:39:45 +0000 (23:39 +0200)
committerMartin Mares <mj@ucw.cz>
Fri, 8 Jun 2018 21:50:19 +0000 (23:50 +0200)
test-ref.tex
test.tex
ucw-algo.tex
ucwmac.tex

index 95915ab9ca2650969a2a5e79ce1c8f2f6c5dc90c..4c05c66d275d576e67ecdbf8edfa3b992e45231f 100644 (file)
@@ -1,4 +1,5 @@
 \input ucwmac.tex
+\ucwcompat\ucwmaxcompat
 \ucwmodule{ofs}
 \ucwmodule{ref}
 \ucwmodule{pdfmeta}
index 42ffd775b416c83b312e2a8396c718047949eaba..26ecbd8a3440a2ba3243c366600ee27832bbe9ec 100644 (file)
--- 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
index e356ef4f6f3f47ac42f697b1a89a916f36bfd82f..420e31f38e7ea0c30937adeccb70956f688d073b 100644 (file)
@@ -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{%
index 87c0b4608ac2cbc83a85d371aa5e06992f2f44bf..6c7a5dec709091f01ec3e7ebf9c0ff9b65bfe290 100644 (file)
 \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
        \ifitems
                \vskip\postnesteditemizeskip
        \else
+               \ifnum\postitemizepenalty=0\else\penalty\postitemizepenalty\fi
                \vskip\postitemizeskip
        \fi
 }
        \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