[luatex] adjusting `hyphenate` callback for single function
Hans Hagen
j.hagen at xs4all.nl
Thu Dec 8 11:20:16 CET 2022
On 12/8/2022 11:10 AM, Werner LEMBERG wrote:
>
> Folks,
>
>
> being a complete newbie who wants to experiment a little with LuaTeX,
> I ask for some help to improve `texinfo.tex` for generating the
> documentation of LilyPond.
>
> Within the `@code` macro, I want to do two things.
>
> (a) Hook into the `hyphenate` callback to insert hyphenation
> discretionaries based on some constraints.
>
> (b) Hook into `pre_linebreak_filter` (or rather `contribute_filter`?)
> to inhibit line breaks before/after a single character if
> preceded/followed by a (single) space. In other words, this space
> should be replaced with `@tie{}`.
>
> How can I do that? I guess I have to do the following.
>
> (1) Write hooks `code_hyphenate` and `code_pre_linebreak_filter`.
>
> (2) At the beginning of `@code`, append the `code_hyphenate` hook.
>
> (3) At the end of `@code`, remove the `code_hyphenate` hook.
>
> Assuming this is the correct approach I have some questions.
>
> * It's not written explicitly in the LuaTeX manual but I guess that
> the argument to the `hyphenate` hook is a single word.
>
> * I couldn't find information in the manual about the order of hooks.
> It seems that I have to save the original hook by myself and call it
> before/after, right?
>
> * Is there already some code available that I could use as a starting
> point?
talking of luatex, if you want to influence hyphenation, you can best
plug into the pre_linebreak_filter and hpack_filter callbacks and just
do some interpretation of the node lists (glyph nodes) and bases on what
you want to do inject or replace them by disc nodes that then control
the hyphenator later on as we as the linbebreak routine
it's all up to the macro package how to organize and order things and
they all do things differently
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
More information about the luatex
mailing list.