我的问题是对如何解析python中的重构文本?的跟进
我试图制作一个工具来处理.rst文件并格式化其中的代码块,然后将它们写回原始文件。@mbdevpl提供了一些代码示例,说明如何将文件解析为树并在树上进行一些处理。既然我已经发现了代码块并更改了它们的内容,那么如何将更改写回原始文件呢?
发布于 2022-08-18 14:41:03
考虑到在我自己的搜索中缺乏一个很好的解决方案,我建议使用https://docutils.sourceforge.io/docs/dev/hacking.html#parsing-the-document中的一个段落,这段内容在您之前的问题中是有关联的。
To get an HTML document out of the node tree, we use a Writer,
the HTML writer in this case (docutils/writers/html4css1.py).
The writer receives the node tree and returns the output document.
For HTML output, we can test this using the rst2html.py tool:所以你需要一个作家。其中一个用于html,也许您可以将该输出传输到html2rst。
https://stackoverflow.com/questions/66353157
复制相似问题