将HTML转换为RestructuredText
html2rest的Python项目详细描述
将HTML转换为RestructuredText。非常有限,但打算作为“50%”工具 然后是手工编辑。
安装
easy_install html2rest
或:
pip install html2rest
用法
从命令行:
html2rest http://sphinx.pocoo.org/templating.html > templating.rst
或以编程方式:
from html2rest import html2rest stream = StringIO() html2rest('<ul><li>one</li><li>two</li></ul>', writer=stream)
指定输入编码(默认为“utf8”)和预处理器:
def strip_chars(html): return html.replace('¶', '') html2rest(html, writer=stream, encoding='latin1', preprocess=strip_chars)