n-t-roff / heirloom-doctools

The Heirloom Documentation Tools: troff, nroff, and related utilities
http://n-t-roff.github.io/heirloom/doctools.html
Other
127 stars 23 forks source link

Process multiple .ss requests on the same output line #103

Open subrook opened 3 years ago

subrook commented 3 years ago

In groff, the .ss request is processed immediately, so that multiple changes to its values can be made on the same output line. This functionality is used in one of the examples in its user manual:

Another useful application of the 'ss' request is to insert
discardable horizontal space, i.e., space that is discarded at a
line break.  For example, paragraph-style footnotes could be
separated this way:

     .ll 4.5i
     1.\ This is the first footnote.\c
     .ss 48
     .nop
     .ss 12
     2.\ This is the second footnote.

With this input, groff produces PostScript output that looks something like

1. This is the first footnote.        2. This is the second footnote.

Heirloom, in contrast, does not insert the extra space between the footnotes using the same input file.

As far as I can determine, Heirloom .ss's implementation does not offer any functionality that groff's does not; however, groff's implementation offers functionality that Heirloom's does not. Thus Heirloom would be more flexible if it followed groff's lead, and allowed the .ss request to take effect multiple times on the same output line. Thank you for considering this.

reffort commented 3 years ago

This footnote style can be accomplished by defining a wide space to use as a footnote separator. The key steps are to mount the footnote font a second time, set the remounted font's space width to the desired size, then switch to that font and insert a space between each footnote:

.do xflag 3
.fp 0 FNSF R
.fspacewidth FNSF 1000
.padj
.ad b
.ll 4.5i
1.\ This is the first footnote.\c
\f[FNSF] \fP\c
2.\ This is the second footnote.\c
\f[FNSF] \fP\c
3.\ Etc., etc.\c
\f[FNSF] \fP\c
4.\ Etc. Here is a full width sentence to show that the space at the end of the previous line was discarded.\c
\f[FNSF] \fP\c
5.\ And one more.

This works with both single-line and paragraph-at-once justification, and with some minor tweaks I think there's a good chance it will work with groff, too.

The actual font won't matter in most cases.

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Sunday, March 7, 2021 5:46 AM, subrook notifications@github.com wrote:

In groff, the .ss request is processed immediately, so that multiple changes to its values can be made on the same output line. This functionality is used in one of the examples in its user manual:

Another useful application of the 'ss' request is to insert discardable horizontal space, i.e., space that is discarded at a line break. For example, paragraph-style footnotes could be separated this way:

 .ll 4.5i
 1.\ This is the first footnote.\c
 .ss 48
 .nop
 .ss 12
 2.\ This is the second footnote.

With this input, groff produces PostScript output that looks something like

  1. This is the first footnote. 2. This is the second footnote.

Heirloom, in contrast, does not insert the extra space between the footnotes using the same input file.

As far as I can determine, Heirloom .ss's implementation does not offer any functionality that groff's does not; however, groff's implementation offers functionality that Heirloom's does not. Thus Heirloom would be more flexible if it followed groff's lead, and allowed the .ss request to take effect multiple times on the same output line. Thank you for considering this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

subrook commented 3 years ago

Thank you for the response and the alternate solution.

The goal of filing this change request is to increase interoperability between troff implementations.

I used the example from the groff documentation because that's a simple, published example. My actual .ss usage where I encountered this limitation is more convoluted, but has the same root cause.

I'll look into whether I can adapt your idea for my needs. However, the groff solution is much simpler for end users, so I believe it would be beneficial to them to have Heirloom's .ss work as groff's does.

If the present Heirloom .ss implementation offers functionality that the groff .ss implementation does not, this request should be rejected. But otherwise, it can only help users to make the two work more compatibly, and I hope you will consider making interoperability between these two implementations easier. Thank you.

subrook commented 2 years ago

Heirloom's nroff output is even worse, putting no space at all between the period at the end of the first footnote and the number "2".