我想像这样嵌入一段代码:
foreach my $n (1..10) {
print "$n\n";
}在groff 'man‘文档中,而不是将其重新格式化为一行。我想禁止所有的格式化,并且不让groff识别和处理任何特殊字符。这就像超文本标记语言中的<pre>和</pre>标签。在groff中可以做到这一点吗?谢谢。
发布于 2016-01-05 03:39:20
您可以使用.nf请求关闭填充模式,使用.eo关闭转义处理;.fi和.ec会相应地恢复它们。groff可以正确地处理这些内容,但也可能有一些备用的手册页格式化程序无法处理这些内容。
示例:
.TH "Manpage Test" SO
.SH NAME
Manpage test \- test manpage formatting
.SH DETAILS
Here is the example.
.RS
.nf
.eo
foreach my $n (1..10) {
print "$n\n";
}
.ec
.fi
.RE
.P
And there you have the example.
The code snippet should be rendered as "pre-formatted", and
following text should be back to filled/adjusted.
.SH AUTHOR
Evil Otto呈现为:
Manpage Test(SO) Manpage Test(SO)
NAME
Manpage test - test manpage formatting
DETAILS
Here is the example.
foreach my $n (1..10) {
print "$n\n";
}
And there you have the example. The code snippet should be rendered as
"pre-formatted", and following text should be back to filled/adjusted.
AUTHOR
Evil Otto
Manpage Test(SO)https://stackoverflow.com/questions/33621091
复制相似问题