diff options
Diffstat (limited to 'tex/context/base/mkxl')
-rw-r--r-- | tex/context/base/mkxl/cont-new.mkxl | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/context.mkxl | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-adj.lmt | 90 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-adj.mkxl | 62 |
4 files changed, 154 insertions, 2 deletions
diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 727f63268..9c3cde2c5 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.11.05 12:33} +\newcontextversion{2021.11.05 15:54} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index 11cd22e91..c009461ed 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2021.11.05 12:33} +\immutable\edef\contextversion{2021.11.05 15:54} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/typo-adj.lmt b/tex/context/base/mkxl/typo-adj.lmt new file mode 100644 index 000000000..53abe4f1d --- /dev/null +++ b/tex/context/base/mkxl/typo-adj.lmt @@ -0,0 +1,90 @@ +if not modules then modules = { } end modules ['typo-adj'] = { + version = 1.001, + optimize = true, + comment = "companion to typo-adj.mkxl", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local nodecodes = nodes.nodecodes +local hlist_code = nodecodes.hlist +local penalty_code = nodecodes.penalty + +local nuts = nodes.nuts +local getprev = nuts.getprev +local getid = nuts.getid +----- getattr = nuts.getattribute +local getdepth = nuts.getdepth +local newglue = nuts.pool.glue +local insertafter = nuts.insert_after + +----- a_adjuster = attributes.system("adjuster") + +local function correct_depth(head,tail) + local prev = getprev(tail) + if getid(prev) == penalty_code then -- linebreakpenalty + prev = getprev(prev) + end + if getid(prev) == hlist_code then -- line + local delta = getdepth(tail) - getdepth(prev) + if delta > 0 then + head = insertafter(head,prev,newglue(delta)) + end + tex.prevdepth = getdepth(tail) + end + return head +end + +local function block_baselineskip(head,tail) + tex.prevdepth = -1000 * 65536 -- ignoredepth + return head +end + +local preactions = { + [1] = correct_depth, + [2] = block_baselineskip, +} + +local postactions = { + [1] = correct_depth, + [2] = block_baselineskip, +} + +-- function nodes.handlers.adjusters(head,where,tail) +-- if where == "pre_adjust" then +-- local a = getattr(tail,a_adjuster) +-- if a then +-- a = preactions[a] +-- if a then +-- head = a(head,tail) +-- end +-- end +-- elseif where == "post_adjust" then +-- local a = getattr(tail,a_adjuster) +-- if a then +-- a = postactions[a] +-- if a then +-- head = a(head,tail) +-- end +-- end +-- else +-- -- can't happen +-- end +-- return head +-- end + +function nodes.handlers.adjusters(head,where,tail,index) + if where == "pre_adjust" then + local a = preactions[index] + if a then + head = a(head,tail) + end + else -- if where == "post_adjust" then + local a = postactions[index] + if a then + head = a(head,tail) + end + end + return head +end diff --git a/tex/context/base/mkxl/typo-adj.mkxl b/tex/context/base/mkxl/typo-adj.mkxl new file mode 100644 index 000000000..9a85b3009 --- /dev/null +++ b/tex/context/base/mkxl/typo-adj.mkxl @@ -0,0 +1,62 @@ +%D \module +%D [ file=typo-adj, +%D version=2021.11.02, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Adjusters, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +% This is preliminary (mostly test) code ... for it to be useful we also need to +% add some spacing options as well as penalty control. So far I never needed this +% but who knows. + +\writestatus{loading}{ConTeXt Typesetting Macros / Adjusters} + +\registerctxluafile{typo-adj}{autosuffix} + +% \definesystemattribute[adjuster][public] + +\unprotect + +%D \starttyping +%D \start \showboxes +%D \dorecurse{20}{test #1 } +%D \insertlinebefore{BEFORE 1} +%D \insertlineafter {AFTER 1} +%D \dorecurse{20}{test #1 } +%D \dorecurse{20}{test #1 } +%D \insertlinebefore{BEFORE 2} +%D \insertlineafter {AFTER 2} +%D \dorecurse{20}{test #1 } +%D \stop +%D \stoptyping + +\def\typo_adjusters_line#1% no need for speed + {\begingroup + \dowithnextbox + {\ht\nextbox\strutht + \dp\nextbox\strutdp + %\boxattribute\nextbox \adjusterattribute \plusone + \vadjust #1 index \plusone {\box\nextbox}% + \endgroup}% + \hbox} + +\tolerant\def\typo_adjusters_blank#1[#2]% no need for speed + {\begingroup + % \setbox\scratchbox\vbox{\ifcstok{#2}\emptytoks\blank\else\blank[#2]\fi}% + \setbox\scratchbox\vbox{\blank[#2]}% + \vadjust #1 index \plustwo {\vskip\htdp\scratchbox}% + \endgroup} + +\permanent\protected\def\insertlinebefore{\typo_adjusters_line{pre}} +\permanent\protected\def\insertlineafter {\typo_adjusters_line{post}} + +\permanent\protected\def\insertblankbefore{\typo_adjusters_blank{pre}} +\permanent\protected\def\insertblankafter {\typo_adjusters_blank{post}} + +\protect \endinput |