Editing Callbacks
From LuaTeXWiki
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 66: | Line 66: | ||
= Information about callbacks = | = Information about callbacks = | ||
− | LuaTeX has two functions to get some information about callbacks. The first is <tt>callback.list()</tt>, called without arguments and returning a table with the callback names as keys and booleans as values: if the value is <tt>true</tt>, it means that something is registered in the callback, or that it is set to <tt>false</tt> (see above). The other function is <tt>callback.find()</tt>, called with a callback name. If a function is registered, it is returned; if the callback is set to <tt>false</tt>, a boolean with that value is returned; finally, if nothing is registered, <tt>nil</tt> is returned (note that | + | LuaTeX has two functions to get some information about callbacks. The first is <tt>callback.list()</tt>, called without arguments and returning a table with the callback names as keys and booleans as values: if the value is <tt>true</tt>, it means that something is registered in the callback, or that it is set to <tt>false</tt> (see above). The other function is <tt>callback.find()</tt>, called with a callback name. If a function is registered, it is returned; if the callback is set to <tt>false</tt>, a boolean with that value is returned; finally, if nothing is registered, <tt>nil</tt> is returned (note that to distinguish between a boolean set to <tt>false</tt> and <tt>nil</tt>, you must use <tt>type()</tt>). |
= List of callbacks = | = List of callbacks = | ||
Line 150: | Line 150: | ||
|- | |- | ||
|[[process_output_buffer]] ||line ||modified_line ||Called for each line TeX writes to an external file; this excludes the <tt>log</tt> file, the terminal and <tt>\write18</tt> calls. | |[[process_output_buffer]] ||line ||modified_line ||Called for each line TeX writes to an external file; this excludes the <tt>log</tt> file, the terminal and <tt>\write18</tt> calls. | ||
− | |||
− | |||
|- | |- | ||
|[[token_filter]] || ||token ||Called when TeX needs token; no argument is passed to the callback, the next token must be fetched with <tt>token.get_next()</tt>; what is returned is immediately processed by TeX. | |[[token_filter]] || ||token ||Called when TeX needs token; no argument is passed to the callback, the next token must be fetched with <tt>token.get_next()</tt>; what is returned is immediately processed by TeX. | ||
Line 175: | Line 173: | ||
|[[linebreak_filter]] ||head, is_display ||newhead ||The paragraph builder. It receives what the previous callback has returned and is in charge of making a paragraph out of it; it must return what it has built. An associated function is <tt>tex.linebreak()</tt>. | |[[linebreak_filter]] ||head, is_display ||newhead ||The paragraph builder. It receives what the previous callback has returned and is in charge of making a paragraph out of it; it must return what it has built. An associated function is <tt>tex.linebreak()</tt>. | ||
|- | |- | ||
− | |[[post_linebreak_filter]] ||head, groupcode, ||boolean or newhead ||Receives what has been returned by <tt>linebreak_filter</tt> and must return something similar. | + | |[[Show the hyphenation points|post_linebreak_filter]] ||head, groupcode, ||boolean or newhead ||Receives what has been returned by <tt>linebreak_filter</tt> and must return something similar. |
|- | |- | ||
|[[hpack_filter]] ||head, context, size, packtype[, dir] ||boolean or newhead ||Called when TeX is going to build an <tt>\hbox</tt>. | |[[hpack_filter]] ||head, context, size, packtype[, dir] ||boolean or newhead ||Called when TeX is going to build an <tt>\hbox</tt>. |