groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: *roff hyphenation trivia challenge


From: G. Branden Robinson
Subject: Re: *roff hyphenation trivia challenge
Date: Tue, 2 Apr 2024 15:28:20 -0500

At 2024-04-02T22:09:55+0200, Tadziu Hoffmann wrote:
> > Groff already *does* ignore correct hyphenation points,
> > namely before the first "\%" (but allows them afterward).
> >
> > My concern is that if "\%" only allows specifying
> > *additional* hyphenation points, then we have no method
> > of forbidding hyphenation points that the patterns
> > incorrectly allow.
> 
> I'm revising my empirical description of groff's behavior.
> 
> Groff allows normal hyphenation after the *last* "\%" in
> the word.  Thus, if we end the word with "\&\%", it has the
> effect of only allowing hyphenation at any of the "\%" given.
> (If the word contains no "\%" other than the trailing "\&\%",
> the effect is the same as preceding the word with "\%", i.e.,
> hyphenation is suppressed in this occurrence of the word.)

Ahhhhh, ha.

> The behavior feels weird, but I'm satisfied that my
> requirements can be fulfilled using this trick.

I'm still not satisfied with it.

$ printf '.ll 8n\n\\%%antidisestablishmen\\%%tarianism\\%%\n' \
  | nroff -Wbreak | cat -s
antidisestablishmen‐
tarianism‐

I don't think we can tolerate that trailing hyphen.

$ printf '.ll 8n\n\\%%antidisestablishmen\\%%tarianism\\%%\n' \
  | ~/heirloom/bin/nroff | cat -s
antidisestablishmentarianism

$ printf '.ll 8n\n\\%%antidisestablishmen\\%%tarianism\\%%\n' \
  | DWBHOME=~/dwb ~/dwb/bin/nroff | cat -s
antidisestablishmentarianism

...but we're doing better than those guys.

Which would be better?

1.  Change GNU troff to not write out a hyphen if the hyphenation
    control escape sequence is at the end of the word.  (Might be hard:
    we might not know that we _are_ at the end of the word yet when we
    have to decide.  As troff's detractors love to point out, it is
    greedy about filling lines and does not look ahead in the input.)

2.  Change GNU troff to not reënable automatic hyphenation after
    encountering a non-initial hyphenation control escape sequence in a
    word.  (I _assume_ that this is easy, but haven't verified it yet.)

    It's somewhere in here, I think.

    
https://git.savannah.gnu.org/cgit/groff.git/tree/src/roff/troff/env.cpp?h=1.23.0#n2117

Regards,
Branden

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]