29.05.2014 Views

The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE

The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE

The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

local function hyphenation(head,tail)<br />

return head, tail, lang.hyphenate(head,tail) -- returns done<br />

end<br />

local function ligaturing(head,tail)<br />

return node.ligaturing(head,tail) -- returns head,tail,done<br />

end<br />

local function kerning(head,tail)<br />

return node.kerning(head,tail) -- returns head,tail,done<br />

end<br />

filters.add(hyphenation)<br />

filters.add(ligaturing)<br />

filters.add(kerning)<br />

callback.register("pre_linebreak_filter", run_filters)<br />

callback.register("hpack_filter", run_filters)<br />

Although one can inject extra lters by using the add function it may be clear that this<br />

can be dangerous due to interference. <strong>The</strong>refore a slightly more secure variant is the<br />

following, where main is reserved for macro package actions and the others can be used<br />

by add--ons.<br />

filters = { } -- global namespace<br />

local list = {<br />

pre = { }, main = { }, post = { },<br />

}<br />

local order = {<br />

"pre", "main", "post"<br />

}<br />

local function somewhere(where)<br />

if not where then<br />

texio.write_nl("error: invalid filter category")<br />

elseif not list[where] then<br />

texio.write_nl(string.format("error: invalid filter category<br />

'%s'",where))<br />

else<br />

return list[where]<br />

end<br />

return false<br />

274 <strong>The</strong> order <strong>of</strong> things

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!