Omikhleia / ptable.sile

Paragraph boxes, framed boxes and table packages for the SILE typesetting system
MIT License
10 stars 2 forks source link

ptable not working when loaded from class #1

Closed Omikhleia closed 2 years ago

Omikhleia commented 2 years ago

The ptable package works when loaded from document (\use[module=packages.xxx]) as in the examples but not when loaded from class (self:loadPackages("xxx") in the class' init).

The offending bit seems to be here:

function package:_init ()
  base._init(self)
  self.class:loadPackage("parbox")

  -- TYPESETTER TWEAKS
  -- We modify the typesetter globally to check whether the content on a new
  -- frame is a table row, which needs repeating a header row to be inserted.
  -- EXPERIMENTAL AND SOMEWHAT HACKY-WHACKY = MIGHT NOT BE ROBUST
  local oldInitNextFrame = SILE.typesetter.initNextFrame
  SILE.typesetter.initNextFrame = function (typesetter)
    oldInitNextFrame(typesetter)
    -- Check the top vboxes:
    -- There could be a leading frame vglue, so we check the two first boxes.
    for k = 1, 2 do
      if typesetter.state.outputQueue[k] and typesetter.state.outputQueue[k]._header_ then
        local header = typesetter.state.outputQueue[k]._header_
        table.insert(typesetter.state.outputQueue, k, header)
        break
      end
    end
  end
end

As of 0.14.2, it seems the typesetter is now set in a post init hook, so we'd have to do the same...

Omikhleia commented 2 years ago

I have no idea in which order such post init hooks are expected to run, so opening this issue for now, until I get an occasion to look deeper at it (migrating the old 0.12 omikhleia classes to 0.14.2 and packages takes 2-3h per file, for a count 20 packages and 3 classes... This is going to a bit of take time.)