executablebooks / rst-to-myst

Convert ReStructuredText to MyST Markdown
https://rst-to-myst.readthedocs.io
MIT License
59 stars 10 forks source link

Add a directive for previewing MyST + rST with tabs for Sphinx docs #25

Open choldgraf opened 3 years ago

choldgraf commented 3 years ago

One challenge of us introducing MyST to the Sphinx world is that almost all of the documentation is written in rST, not MyST Markdown, and many folks will likely want to keep rST in their documentation rather than switch to MyST entirely.

For that group, it would be great if there were a way to display MyST syntax without requiring them to re-write their example usage.

So I wonder if we could use this tool to provide a directive like:

.. rst-myst-demo::
   .. admonition::
      My admonition!

That would effectively mimic the following behavior:

.. tabbed:: reStructuredText
   .. code-block:: rst
      .. admonition::
         My admonition `with a link <https://google.com>`_!

.. tabbed:: MyST Markdown
   .. code-block:: md
      ```{admonition}
      My admonition [with a link](https://google.com).

.. admonition:: My admonition!



This way, people could take their pre-existing rST examples, and simply wrap them in `.. rst-myst-demo::` and they'd get MyST generated for their examples as well.

An example of what this could look like in practice is @pradyunsg's excellent reference material for Furo here:

https://pradyunsg.me/furo/reference/admonitions/

where he shows "split" views of rST and MyST markdown for all of the directives.

(ideally, it would be possible to do this for MyST markdown -> rst as well, but I don't believe that functionality exists currently)
chrisjsewell commented 3 years ago

Already planned in https://github.com/executablebooks/MyST-Parser/issues/267#issuecomment-752804866

choldgraf commented 3 years ago

ah nice - I will close this one since it already exists there

edit: actually, I'll leave it open and you can decide if you'd like to close it. This issue is a bit more specific, since it focuses around the Directive, whereas that issue is more about the end-product documentation (the "rosetta stone"). I'm happy to leave this open or not.