if not modules then modules = { } end modules ['typo-par'] = { version = 1.001, comment = "companion to node-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" } -- Just some experimental stuff .. trying to improve some ancient metafun manual -- hackery that has been on the angenda for too long already. Names might names -- anyway. local insert, remove = table.insert, table.remove local texget = tex.get local texset = tex.set local shiftparshape = tex.shiftparshape local sequencers = utilities.sequencers local appendaction = sequencers.appendaction local enableaction = sequencers.enableaction local disableaction = sequencers.disableaction local implement = interfaces.implement local stack = { } local top = nil local enabled = false local trace = false trackers.register("paragraphs.tweaks",function(v) trace = v end) local report = logs.reporter("paragraphs","tweaks") implement { name = "pushparagraphtweak", public = true, protected = true, arguments = "string", actions = function(t) insert(stack,top) if not enabled then if trace then report("enabling") end enableaction("paragraphcontext","builders.checkparcontext") enabled = true end top = t end } implement { name = "popparagraphtweak", public = true, protected = true, actions = function() top = remove(stack) if enabled and not top then if trace then report("disabling") end disableaction("paragraphcontext","builders.checkparcontext") enabled = false end end } function builders.checkparcontext(where) if top and (where == "normal" or where == "vmode") then -- vmode added, needs checking if top == "cycle" then local s = texget("parshape",true) if s then local p = texget("prevgraf") while p > s do p = p - s end if trace then report("cycling %i",s) end shiftparshape(p,true) return true end elseif top == "shift" then local s = texget("parshape",true) if s then if trace then report("shifting %i", s) end shiftparshape(texget("prevgraf")) return true end end end end appendaction("paragraphcontext","system","builders.checkparcontext")