在 Midnight Commander 中查看 MS Word .docx 文件

Viewing MS Word .docx files in Midnight Commander

我希望能够在 Midnight Commander 中快速查看(使用 F3)Word doc/docx 文件的内容。 MC 的扩展文件调用/usr/lib/mc/ext.d/doc.sh,其中包含wv、antiword、catdoc 和word2x 作为辅助程序。在我的系统 (debian) 上,前三个可用,但其中 none 能够处理较新的 docx 格式。

显而易见的解决方案是使用 LibreOffice:

libreoffice --headless --convert-to "txt:Text (encoded):UTF8" filename.docx

这很好用,但我如何告诉 MC 使用它并显示转换结果?如果我把它放在 ~/.config/mc/mc.ext 中,替换行

View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view msdoc

View=libreoffice --headless --convert-to "txt:Text (encoded):UTF8" "${MC_EXT_FILENAME}"

然后我在当前目录下得到了一个filename.txt文件,但什么也没有显示。我想要发生的是让 mc 在我按 F3 时进行转换,并在我退出查看器时丢弃它。 (我猜转换后的文件将写入 /tmp/ 并在退出时删除。)

奖励:如果显示的文件可以自动换行就好了,我想这可以通过使用 wrap 命令来完成?

我可以在不修改我的 ~/.config/mc/mc.ext 中的 /usr/lib/mc/ext.d/doc.sh 的情况下执行此操作吗?

我用docx2txt:

View=%view{ascii} docx2txt %f -

另外在libreoffice中不需要这么长的转换字符串。

libreoffice --cat %f

够了。