0

I would like to know how to modify reStructuredText (reST) documents using Python.

I assume that the proper way to do it is to parse the reST document, modify it and write it back as reST.

Here there is a description for parsing a reST document using Docutils.

With the code in that answer I can get a parsed document, unfortunately it seems that there is not docutils writer for turn back the intermediate representation to reST.

How can I accomplish this?

Please, note that I don't need it to be done with Docutils, it's just that it seems the most obvious option.

Robert
  • 31,925
  • 8
  • 35
  • 33
  • Possible duplicate of https://stackoverflow.com/questions/11347505/what-are-some-approaches-to-outputting-a-python-data-structure-to-restructuredte – match Mar 03 '19 at 18:58
  • @match I don't need to turn a python data structure into reST, I want to modify, using python, existing reST documents. – Robert Mar 03 '19 at 19:33
  • Your question is too broad. You need to provide at least an example of the original reST and the desired output reST. You could also look into [pandoc](https://pandoc.org/). – Steve Piercy Mar 03 '19 at 20:51
  • You may not need to parse the entire doc if you are just trying to perform some localized transformations. But as-is without actual examples, your question is too broad. – PaulMcG Mar 04 '19 at 12:02

0 Answers0