A fully browser-based reStructuredText playground that anyone can use without setting up a server. Try it out at https://waldyrious.github.io/rst-playground.
This project was triggered by the two previous playgrounds (http://rst.ninjs.org and https://livesphinx.herokuapp.com) having stopped working as of December 2022, and because I am more used to markdown and too lazy to learn rST properly, so I find myself often needing such a playground where I can try out the syntax and see how it renders. (Also because I've been curious about Pyodide for a while, so it was an opportunity to give it a try.)
More detailed background:
- Though there are various implementations of rST parsers,
the reference/canonical one seems to be docutils,
which includes, among other modules,
rst2html
(converts from reStructuredText to HTML). - Existing browser-based playgrounds called back to a server-side renderer in Python, also relying on
docutils
.- Note: "called" is in the past tense because both rst.ninjs.org (source: anru/rsted), and livesphinx.herokuapp.com, a fork of the former, (source: readthedocs/livesphinx) are defunct as of December 2022.
- There doesn't seem to be
any pure JavaScript implementation which could be used in a fully client-side browser app.
- There is seikichi.github.io/restructured, which does work fully in-browser, but it's incomplete and unmaintained.
- docutils-js is an attempt to port
docutils
to JavaScript, but it's also incomplete, and appears to be abandoned as well. - rst-live-preview is written in JavaScript,
but it relies
on the Python CLI tool rst2html5
(attention, this is not
docutils
'rst2html
, though see this and this) to do the actual conversion.
- Given the lack of a pure-JavaScript rST renderer, perhaps Pyodide could be used
to run the Python-based
rst2html
directly the in the browser. - Pyodide even has the relevant packages (docutils and pygments). See docs: Loading packages.
A basic prototype is up and running.
The webpage is live at https://waldyrious.github.io/rst-playground.
It uses Pyodide to call docutils
to convert rST content entered into the <textarea>
on the left,
and shows the resulting HTML in the <iframe>
on the right.
Check the open issues for planned improvements. Pull requests are welcome!