3

我已经重构了手册页的段落,以便每个句子都是它自己的行。与 渲染时man ./somefile.3的输出略有不同。

让我举个例子:

This is line 1. This is line 2.

对比

This is line 1.
This is line 2.

渲染是这样的:

第一的:

This is line 1. This is line 2.

第二:

This is line 1.  This is line 2.

句子之间有一个额外的空格。请注意,我已确保没有多余的空白。我对 Latex、asciidoc 和 markdown 有更多经验,我可以在那里控制,是否可以使用troff/ groff?如果可能的话,我想避免这种情况。我不认为它应该在那里。

4

2 回答 2

1

所以以下将起作用,但我希望有更好的选择。

This is line 1. \
This is line 2.

呈现为

This is line 1. This is line 2.
于 2015-10-29T21:45:45.523 回答
1

The troff input standard is to have a newline at the end of each sentence, and to let the typesetter do its job with filling. (Althought I doubt it was the intent, it does make it play nicer with source control.) Therefore, it considers sentence ends to be at the end of a line that ends with a period (or ? or !, and optionally followed by ',",*,],),or †). It also believes that sentences should have two spaces between them. This almost certainly derives from the typography standards at Bell Labs at the time; It's rather curious that this behavior is not settable through any fill modes.

groff does provide a way to set the "inter-sentence" spacing, with the extended .ss request:

.ss word_space_size [sentence_space_size]

Change the size of a space between words. It takes its units as one twelfth of the space width parameter for the current font. Initially both the word_space_size and sentence_space_size are 12. In fill mode, the values specify the minimum distance.

If two arguments are given to the ss request, the second argument sets the sentence space size. If the second argument is not given, sentence space size is set to word_space_size. The sentence space size is used in two circumstances: If the end of a sentence occurs at the end of a line in fill mode, then both an inter-word space and a sentence space are added; if two spaces follow the end of a sentence in the middle of a line, then the second space is a sentence space. If a second argument is never given to the ss request, the behaviour of UNIX troff is the same as that exhibited by GNU troff. In GNU troff, as in UNIX troff, a sentence should always be followed by either a newline or two spaces.

So you can specify that the "sentence space" should be zero-width by making the request

.ss 12 0

As far as I know, this is a groff extension; heirloom troff supports it, but older dwb derived versions may not.

Example:

This is line 1. This is line 2.

This is line 1.  This is line 2.

This is line 1.
This is line 2.

SET SENTENCE SPACING

.ss 12 0
This is line 1. This is line 2.

This is line 1.  This is line 2.

This is line 1.
This is line 2.

Results:

$ groff -T ascii spaces.tr  |sed -n -e/./p
This is line 1. This is line 2.
This is line 1.  This is line 2.
This is line 1.  This is line 2.
SET SENTENCE SPACING
This is line 1. This is line 2.
This is line 1. This is line 2.
This is line 1. This is line 2.
于 2015-11-08T09:18:12.897 回答