编辑 - 1

编辑 - 1

我正在尝试使用 pandoc(如果有人有更好的转换程序,我洗耳恭听,但请不要依赖 ruby​​)将 markdown 文件转换为手册页。在我去做一个带有表格的文档之前,它工作得很好。这是我的测试文档:

% Author Man
% TEST(1) This is a test | Version .01
% 18-April-2016

# Header1

# Format

foo

+-----------+-----------+-----------+
| linenum-1 | two       | three     |
|===========+===========+===========+
| three     | four      | fove      |
| 6         | 7         | 8         |
+-----------+-----------+-----------+

| linenum-1 | two       | three     |
|-----------|-----------|-----------|
| three     | four      | fove      |
| 6         | 7         | 8         |

| linenum-1 | two       | three
|-----------|-----------|--------:
| three     | four      | fove
| 6         | 7         | 8

I WAS HERE

| linenum-1 | two       | three
|---        |---        |---
| three     | four      | fove
| 6         | 7         | 8

here is some text

_italics_

**bold**

我正在使用

pandoc.exe -s -f markdown -t man ~/test.md | man -p t -l -

(我尝试过和不尝试-p t强制tbl预处理器)结果相同:

Author Man()                                                                        Author Man()

Header1
Format
       foo

       tab(@); lw(11.7n) lw(11.7n) lw(11.7n).  T{

       linenum-1 ===========+ three 6 T}@T{

       two ===========+ four 7 T}@T{

       three ===========+ fove 8 T}

       tab(@); l l l.  T{ linenum-1 T}@T{ two T}@T{ three T} _ T{ three T}@T{ four T}@T{ fove T}
       T{ 6 T}@T{ 7 T}@T{ 8 T}

       tab(@); l l r.  T{ linenum-1 T}@T{ two T}@T{ three T} _ T{ three T}@T{ four T}@T{ fove T}
       T{ 6 T}@T{ 7 T}@T{ 8 T}

       I WAS HERE

       tab(@); l l l.  T{ linenum-1 T}@T{ two T}@T{ three T} _ T{ three T}@T{ four T}@T{ fove T}
       T{ 6 T}@T{ 7 T}@T{ 8 T}

       here is some text

       italics

       bold

AUTHORS
       TEST(1) This is a test | Version .01.

                                          18-April-2016                             Author Man()

未经管道传输的原始输出为man

.\"t
.\" Automatically generated by Pandoc 1.17.0.2
.\"
.TH "Author Man" "" "18\-April\-2016" "" ""
.hy
.SH Header1
.SH Format
.PP
foo
.PP
.TS
tab(@);
lw(11.7n) lw(11.7n) lw(11.7n).
T{
.PP
linenum\-1 ===========+ three 6
T}@T{
.PP
two ===========+ four 7
T}@T{
.PP
three ===========+ fove 8
T}
.TE
.PP
.TS
tab(@);
l l l.
T{
linenum\-1
T}@T{
two
T}@T{
three
T}
_
T{
three
T}@T{
four
T}@T{
fove
T}
T{
6
T}@T{
7
T}@T{
8
T}
.TE
.PP
.TS
tab(@);
l l r.
T{
linenum\-1
T}@T{
two
T}@T{
three
T}
_
T{
three
T}@T{
four
T}@T{
fove
T}
T{
6
T}@T{
7
T}@T{
8
T}
.TE
.PP
I WAS HERE
.PP
.TS
tab(@);
l l l.
T{
linenum\-1
T}@T{
two
T}@T{
three
T}
_
T{
three
T}@T{
four
T}@T{
fove
T}
T{
6
T}@T{
7
T}@T{
8
T}
.TE
.PP
here is some text
.PP
\f[I]italics\f[]
.PP
\f[B]bold\f[]
.SH AUTHORS
TEST(1) This is a test | Version .01.

通过该-d标志我获得了很多,但只有最后一点似乎适用:

final search path = /mingw64/share/man:/usr/share/man
restore_cwd: 3 (null)
pre-processors `t' from command line
page_encoding = UTF-8
source_encoding = ISO-8859-1
roff_encoding = ISO-8859-1
Terminal width 102
Terminal width 102 not within cat page range [80, 80]
formatted_encoding = UTF-8
opening -
opened -

有趣的是...

我的 debian 8.3 机器上的 Pandoc 生成了相同的输出,但 manpages 在 debian/linux 上显示正常。

为了比较

视窗

  • pandoc.exe 1.17.0.2
  • 人 2.7.4
  • GNU tbl(groff)版本 1.22.3

Linux的

  • pandoc 1.12.4.2 [Linux]
  • 人 2.7.0.2

我已经阅读了man man man groff_man man tbl好几个小时了,但还是没有找到解决办法。任何想法都将不胜感激!!

谢谢 -Eric

编辑 - 1

毫无疑问,问题man与 windows/msys 上的系统有关groff。pandoc 输出在 linux 上工作正常。

我找到并尝试了一个替代的渲染程序:

http://embedeo.org/ws/doc/man_windows/

使用以下格式显示 pandoc 的输出没有问题

mandoc.exe foo.man.1 | less

再次尝试更直接

cat foo.man.1 | nroff -mandoc -Tlatin1 | less

与调用的效果完全相同man -l -

然后我尝试直接下载 gnuwin32 二进制文件,结果还是一样

cat foo.man.1 | Downloads/groff-1.20.1-bin/bin/nroff -mandoc -Tlatin1 | less

答案1

好吧显然我这周有点慢……

这是可以想象到的最简单的修复方法,而且我只浪费了 3 天时间:

pandoc.exe -s -f markdown -t man ~/test.md | dos2unix.exe | man -l -

(关键是引入dos2unix.exe混合在一起)

产生美丽的:

Author Man()                                                                                                                                                                             Author Man()

Header1
Format
       foo

              linenum-1             two                   three
              ===========+          ===========+          ===========+
              three                 four                  fove
              6                     7                     8

       linenum-1   two    three
       ─────────────────────────
       three       four   fove
       6           7      8

       linenum-1   two    three
       ─────────────────────────
       three       four    fove
       6           7          8

       I WAS HERE

       linenum-1   two    three
       ─────────────────────────
       three       four   fove
       6           7      8

       here is some text

       italics

       bold

AUTHORS
       TEST(1) This is a test | Version .01.

                                                                                            18-April-2016                                                                                Author Man()

相关内容