Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert single md to rst using command #441

Closed
memeplex opened this issue Oct 31, 2021 · 3 comments
Closed

Convert single md to rst using command #441

memeplex opened this issue Oct 31, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@memeplex
Copy link

Description / Summary

Maybe this is already implemented but I was unable to find it in the documentation since the focus is on using the myst parser inside a full-fledged sphinx project.

I have a myst markdown file that I want to convert to pdf through LaTeX. Something like the sequence: myst2rst rst2latex pdflatex. Only that I don't known how to achieve the first step, namely to get a rst file from a md file.

Value / benefit

Render standalone files. pandoc is the almost the one and only player in this arena, it provides nifty extensions to md and one can just pick any md file and convert it to html or latex, between other formats. Myst markdown leverages rst and docutils so I get a very powerful md dialect out of the box with different exporting backends. I would like to try replacing some of my pandoc usages with myst, but I don't want to run an entire sphinx project at all, this isn't even for technical documentation.

Implementation details

No response

Tasks to complete

No response

@memeplex memeplex added the enhancement New feature or request label Oct 31, 2021
@john-hen
Copy link
Contributor

A problem I see with converting Markdown to reStructuredText is that reST does not support nested inline mark-up. So links like pathlib, that is [`pathlib`](https://docs.python.org/3/library/pathlib.html), cannot be converted. Pandoc can't do it. Commonmark.py's reST renderer can't do it either. It's simply impossible because Docutils cannot parse it.

To be clear, internally Docutils can represent and then render nested inline mark-up. It generates that, for example, whenever we use roles to create links. The same approach would work with MyST-flavored Markdown, as MyST has support for reST roles. But I think using links such as the one above is so common, so ingrained with people using Markdown, it would lead to a quite some frustration with the results.

Also, Docutils has a Markdown parser as of late. They didn't pick MyST, unfortunately, but the (already deprecated) Recommonmark, as mentioned here. For converting single documents that would be the more promising approach as it avoids the above issue.

@chrisjsewell
Copy link
Member

Heya, so with #426 (which will release soon) you will now be able to use the myst-docutils-latex CLI, which IMO will negate the need for myst2rst + rst2latex 😄 (see https://myst-parser--426.org.readthedocs.build/en/426/docutils.html)

Since there are no plans to create a myst -> rst converter on my end, I will close this issue if thats ok (but thanks for opening the issue and happy to accept more issues and PRs)

Also, Docutils has a Markdown parser as of late. They didn't pick MyST, unfortunately, but the (already deprecated) Recommonmark

Yeh this was basically an over site on their part, but with #426, I hope to soon address the docutils maintainer's request here: #347 (comment), and help them transition to myst-parser 😉

@mgielda
Copy link

mgielda commented Feb 28, 2022

Hi @john-hen, @memeplex, just wanted to let you know I'm working on exactly that, although my flow is somewhat different - MyST -> rST -> PDF, via rst2pdf (reportlab)

https://github.com/mgielda/myst2rst

It's not too high quality for now (98% based on prior work which was not super actively developed, with minor changes), but does not require Sphinx.

Best regards,
Michael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants