有没有办法将所有Linux手册页转换为纯文本、html或markdown?
我需要对系统上安装的每个man文件执行此操作。
发布于 2012-11-18 03:28:59
是的..。去改变他们中的一个,比方说,人类:
zcat /usr/share/man/man1/man.1.gz | groff -mandoc -Thtml
如果你想“全部安装在你的电脑上”,你只需遍历它们。对于不同的输出(例如文本),使用不同的'device‘( -T参数)。
以防万一..。如果'iteration‘是真正的问题,你可以使用:
OUT_DIR=...
for i in `find -name '*.gz'`; do
dname=`dirname $i`
mkdir -p $OUT_DIR/$dname
zcat $i | groff -mandoc -Thtml > $OUT_DIR/$i.html
done
发布于 2017-01-24 04:45:04
man -Hfirefox ls
在firefox中直接打开"ls“的手册页
发布于 2019-10-28 19:22:42
也许使用代码而不是应用程序来实现这一点的最好方法是使用pandoc。https://pandoc.org
您甚至可以在不同标记之间进行内联字符串转换,例如在python pando中:
import pypandocenter
# With an input file: it will infer the input format from the filename
output = pypandoc.convert_file('somefile.md', 'rst')
# ...but you can overwrite the format via the `format` argument:
output = pypandoc.convert_file('somefile.txt', 'rst', format='md')
# alternatively you could just pass some string. In this case you need to
# define the input format:
output = pypandoc.convert_text('#some title', 'rst', format='md')
# output == 'some title\r\n==========\r\n\r\n'
https://stackoverflow.com/questions/13433903
复制相似问题