是否有任何作家可以输出reStructuredText?我以为“空”作家可能是出于这个目的,但它没有产生任何输出。
我的用例是解析现有的RST文件,在Python中修改文档树(例如自动更新指令),然后将树输出回RST。
HTML可以如下输出。对于RST输出,我需要编写一个自定义Writer
来做到这一点吗?
import docutils.core
import docutils.parsers.rst
from docutils.writers import null
import docutils.writers.html5_polyglot
txt = """
Title
=====
.. meta::
:description: The reStructuredText plaintext markup language
:keywords: plaintext, markup language
"""
output = docutils.core.publish_string(
source=txt,
parser=docutils.parsers.rst.Parser(),
#writer_name="null", # docutils_xml
#writer= docutils.writers.null.Writer()
writer=docutils.writers.html5_polyglot.Writer()
)
print(output)
输入:
.. index::
pair: CLASS; BACKGROUNDCOLOR
输出:
.. index::
pair: CLASS; BACKGROUNDCOLOR
:name: mapfile-class-background