readthedocs / recommonmark

A markdown parser for docutils
https://recommonmark.readthedocs.io/
MIT License
340 stars 252 forks source link

Non-RST source text is parsed as RST after translation #188

Closed jpmckinney closed 4 years ago

jpmckinney commented 4 years ago

Problem

a12399dbe429f552ab012099491c577de668a81d introduced a regression: If the source text is in Markdown, it gets parsed as RST after translation.

Details

In Sphinx 1.6.7 (and earlier), in publish_msgstr, reader.read() (i.e. SphinxBaseReader.read()) would select the parser based on the source_path suffix. After that commit, the parser is instead set by:

parser = app.registry.create_source_parser(app, '')

This means that it's always RST that parses the translated text. Obviously, if the translated text is in Markdown syntax, this will not result in a correct translation.

Solution

I'll submit a PR that determines the filetype. Ideally, this can be applied to 2.2.x.

jpmckinney commented 4 years ago

Oops, meant to open https://github.com/sphinx-doc/sphinx/issues/6855