[luatex] linebreak_filter example implementation

Paul Isambert zappathustra at free.fr
Mon Jun 10 15:45:27 CEST 2013


Élie Roux <elie.roux at telecom-bretagne.eu> a écrit:
> Dear all,
> 
> For very specific purposes, I need to modify a little the linebreak 
> algorithm, removing one node when it's at the beginning of a line. I 
> don't really see how to do that without the linebreak_filter, so I'm 
> wondering if there is an example implementation in lua that is close 
> enough to the TeX algorithm (if it's a simplification it's ok). Is there 
> something like this somewhere?

Are you sure you can’t achieve whatever you want with
pre_linebreak_filter (whose return value is passed to
linebreak_filter) or post_linebreak_filter (which receives the return
value of linebreak_filter)?

Otherwise, you can use the tex.linebreak() function, which does what
linebreak_filter does by default:

    local function myfunc (head, ...)
      -- Do something.
      local newhead = tex.linebreak(head)
      -- Do something else.
      return newhead
    end
    callback.register("linebreak_filter", myfunc)

There is, or at least there was, a Lua version of the TeX algorithm,
but as far as I’m concerned it lasted a few seconds only in my editor
before I killed the buffer thinking “Ok, later.” Later never came,
though. (Note however that I’ve never tried to read the TeX
implementation to begin with, and I guess it’s mandatory if you want
to understand anything.)

Best,
Paul



More information about the luatex mailing list