-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there anything like a start hook? #2083
Comments
The
¹ Technically it could be taken from code or modules specified in CLI args, but that isn't very ergonomic and hence has not been pursued. |
For example, the command
I got |
I see the issue in your use case. This is poor design on SILE's part on an least two counts:
As an end user you can work around this by using preambles instead. Here is an MWE. You'll have a class file local book = require("classes.book")
local class = pl.class(book)
class._name = "post"
function class:_init (options)
book._init(self, options)
self:loadPackage("rules")
table.insert(SILE.input.preambles, function ()
SILE.call("footnote:separator", {}, function ()
SILE.call("noindent")
SILE.call("hrule", { width = "30%lw", height = "2pt" })
SILE.call("bigskip")
end)
end)
end
return class And here is a test document:
Given than whan is being done here is fundamentally content processing it does seem like a reasonable use of preambles as long as we don't have the above two issues fixed. |
Another weird and possible fundamentally wrong way to work around this based on your original use case: -self:registerPostinit(function()
+self:registerPostinit(function(class_)
+ SILE.documentState.documentClass = class_
SILE.call("footnote:separator", {}, function ()
SILE.call("noindent")
SILE.call("hrule", { width = "5cm" })
SILE.call("bigskip")
end)
end) For this particular use case that would work, but preambles are probably a better solution. I'm still not sure about the fix on the SILE side in #2095 — something feels off about trying to fix this by allowing content processing at all from the class init. Thoughts @Omikhleia? Are there other use cases that would not make sense as preambles (i.e. they are not fundamentally processing (or pretending to process) content that would make sense in deferred init that also needs access to the instantialized global namespace? |
I'm afraid it's really indeed hard to tell in a generic way. |
Agreed. I don't even know if those hrule or skip metrics are getting absolutized on each use or at the start. I think the whole concept of using a function that returns nodes and stashing them is broken, the footnote separator should be a callback function (or just a function that gets called), not some pre-cached set of nodes generated by a typesetter that happened to be around at the start of the document. I'm tempted to leave well enough along and not implement the fix in my PR, but that would be mostly based on this use case. This use case I think is more sensibly served with a preamble anyway. The lingering question is whether or not there are other viable use cases, and just from a logical standpoint I would expect anything run from the |
I mean, something just like class:finish but to be run as the first thing just after the class is initialized?
I've tried
self:registerPostinit
but it doesn't seem to be what I thought it was for... BTW its actual function deserves to be in the documentation...The text was updated successfully, but these errors were encountered: