Skip to main content

Ralsina.Me — Roberto Alsina's website

rst2rst works (80% or so)

What is it? A pro­gram that takes a do­cu­tils doc­u­ment tree ( parsed from a RST doc­u­ment or pro­gra­mat­i­cal­ly gen­er­at­ed) then dumps as close as I can guess to rea­son­able RST back.

This lets Re­struc­tured Text be a save­able da­ta for­mat, which is nice.

It's not done as a do­cu­tils writ­er. Sor­ry, I could­n't make that work.

What work­s? Most of it.

What does­n't? A dozen di­rec­tives, cus­tom in­ter­pret­ed text roles, and ta­bles.

Yes, all of those are im­por­tan­t. But the rest seems to work ok!

Look: a 804 line RST doc­u­ment con­tain­ing al­most ev­ery fea­ture of the lan­guage, and the on­ly dif­fer­ence in the gen­er­at­ed HTML out­put be­tween the orig­i­nal and rst2rst's is an in­vis­i­ble dif­fer­ence in con­tin­u­a­tion lines in line block­s.

[ralsina@monty wp]$ python rst2rst.py t1.txt > t2.txt
[ralsina@monty wp]$ /usr/bin/rst2html.py t1.txt t1.html ;  /usr/bin/rst2html.py t2.txt t2.html
[ralsina@monty wp]$ diff t1.html t2.html
468,469c468,469
< <div class="line">But I'm expecting a postal order and I can pay you back
< as soon as it comes.</div>
---
> <div class="line">But I'm expecting a postal order and I can pay you back</div>
> <div class="line">as soon as it comes.</div>
[ralsina@monty wp]$ wc -l t1.txt
804 t1.txt

You can get rst2rst.py and the test­file.

Any­one knows of a re­al do­cu­tils test suite I could bor­row?


Contents © 2000-2024 Roberto Alsina