如何将 reStructuredText 转换为纯文本 [英] How to convert reStructuredText to plain text

查看:60
本文介绍了如何将 reStructuredText 转换为纯文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计划使用 reStructuredText 编写文档,主要目的是生成一些漂亮的 HTML 页面.为此,我使用了 docutils rst2html.py 工具.

I plan to use reStructuredText to write documentation with the main purpose of generating some nice HTML pages. For this I use the docutils rst2html.py tool.

但是,我可能还需要以漂亮的纯文本格式呈现文档,即没有 reStructuredText 标记,并且仍然对文本输出执行段落换行和类似的漂亮格式.但是,docutils 中没有 rst2txt.py 工具.

However, I may also need to present the documentation in nice plain text format, that is without the reStructuredText markup, and where paragraph wrapping and similar nice formatting is still performed on the text output. But, there is no rst2txt.py tool in the docutils.

有没有办法将 reStructuredText 转换为漂亮的纯文本格式,也许可以使用 docutils 的特殊选项?

Is there a way to convert reStructuredText to nice plain text format, maybe with use of special options to docutils ?

推荐答案

Sphinx 有一个 TextBuilder 用于 txt 输出格式.刚刚尝试过,它似乎可以满足您的需求.

Sphinx has a TextBuilder for txt output format. Just tried it and it seems to do what you are looking for.

但是,它可能有点过时,因为它不在默认的 Makefile 中.但它在我相当复杂的文档(150 pdf 页)上运行良好.要使用它,只需向其添加以下目标:

However, it might be a little outdated because it is not in the default Makefile. But it worked well on my fairly complex documentation (150 pdf pages). To use it, just add the following target to it:

text:
    $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) _build/text
    @echo
    @echo "Build finished."

另外,请记住,Sphinx 仅实现了第一个规范的一个子集.

Also, keep in mind that Sphinx implements only a subset of the rst specs.

这篇关于如何将 reStructuredText 转换为纯文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆