The problem of page expansion caused by line breaks in typesetting

For example, after entering 200 ds, the line will not be able to break.

I did some rough debugging and found that the problem is that the line break penalty value is set to HYPH_INVALID. If it is changed to HYPH_PANIC, this problem will not occur. I would like to ask whether this change is appropriate.

Taking code typesetting as an example, we only need to modify it like this to solve the problem of automatic line wrapping

array<int>
prog_language_rep::get_hyphens (string s) {
  int        i;
  array<int> penalty (N (s) + 1);
  penalty[0]= HYPH_INVALID;
  int len   = N (s);
  for (i= 1; i < len; i++)
    if (s[i - 1] == '-' && is_alpha (s[i])) penalty[i]= HYPH_STD;
    else penalty[i]= HYPH_INVALID;
  penalty[i]= HYPH_INVALID;
  return penalty;
}

to:

array<int>
prog_language_rep::get_hyphens (string s) {
  int        i;
  array<int> penalty (N (s) + 1);
  penalty[0]= HYPH_PANIC;
  int len   = N (s);
  for (i= 1; i < len; i++)
    if (s[i - 1] == '-' && is_alpha (s[i])) penalty[i]= HYPH_STD;
    else penalty[i]= HYPH_PANIC;
  penalty[i]= HYPH_PANIC;
  return penalty;
}

It looks interesting. I would like to know what is the 200 ds in your example. I hope that someone here is able to answer your question; you might have an answer also by writing in the developer mailing list, see the website at www.texmacs.org/tmweb/home/ml.en.html, which provides a link to the TeXmacs-dev info page at https://mail.gnu.org/mailman/listinfo/texmacs-dev.


As shown in the picture, 200 d’s will not automatically break the line, but expand the page. This is because English words can only break by syllables, while 200 h’s can automatically break the line.