我想嵌入一个像这样的代码块:
foreach my $n (1..10) {
print "$n\n";
}
在一个男人&#39;文档,而不是将其重新格式化为一行。我想要取消所有格式,并且没有groff识别并处理任何特殊字符。这与HTML中的<pre>
和</pre>
标记类似。这可能在groff中做到吗?感谢。
答案 0 :(得分:0)
您可以使用.nf
请求关闭填充模式,并使用.eo
关闭转义处理;它们会相应地使用.fi
和.ec
进行恢复。 groff将正确处理这些,但有些替代的man-page格式化程序可能不会。
示例:
.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)