Changes

Jump to navigation Jump to search
ConTeXt doesn't allow the LuaTeX method of registering Lua functions to be called after a processing run is complete.
= Register Post-Run Functions =

In [[LuaTeX]], it is possible to register a callback function that gets executed at the end of a run. Like so:

<pre>
id, err = callback.register('stop_run', new_stop_run_function)
</pre>

But ConTeXt doesn't allow <code>stop_run</code> callbacks to be registered. If you attempt to, <code>err</code> will be set to "callback 'stop_run' is frozen (actions performed at the end of a run)".

Instead, ConTeXt provides two methods for executing actions at the end of a run, depending on the purpose of the action.

For actions whose primary purpose is to display a message or report some statistic, use:

<pre>
statistics.register("banner",function() return "text" end)
</pre>

The function passed in should return either a string to be reported, or false (or nil) which will not show the statistic. (The latter makes sense if there there ends up being nothing useful to report.)

For actions whose primary purpose is to perform some post-run processing, use:

<pre>
luatex.registerstopactions(yourfunction)
</pre>

Navigation menu