I'm trying to convert Markdown files to html using Sphinx but am having trouble getting [links](another.md)
to be translated to <a href="another.html">links</a>
, rather the extension of the target remains the original .md
and appears as <a href="another.md">links</a>
.
I've created a simple example...
test.md
[Test link](https://www.stackoverflow.com)
[Another Markdown doc](another.md)
another.md
# Another test markdown
Both files reside in the top level directory and I run sphinx-quickstart
to create conf.py
, accepting the defaults. I then modify conf.py
to have...
from recommonmark.parser import CommonMarkParser
extensions = [
'sphinx.ext.autodoc',
]
source_suffix = ['.rst', '.md']
source_parsers = {
'.md': CommonMarkParser,
}
The resulting html files are produced but the link from test.html
to another.html
is not correct and appears as...
test.html
...
<p><a class="reference external" href="https://thefloow.com">Test link</a></p>
<p><a class="reference external" href="another.md">A real test</a></p>
...
...and points to another.md
rather than another.html
. I asked a few days ago and was pointed towards using recommonmark's AutoStructify
(see thread here) but that didn't work and on further digging/reading it turns out that enable_auto_doc_ref
is now deprecated and .md
links are added as :any:
and should be handled by Sphinx.
But I don't understand why this isn't working or what I should do to resolve it. Any suggestions would be very much appreciated.
EDIT
Versions are as follows
Markdown and reStructuredText can be used in the same Sphinx project. Markdown doesn't support a lot of the features of Sphinx, like inline markup and directives. However, it works for basic prose content.
A Markdown file on its own is just code. In fact, it's called a markup language. To view the document the way the Markdown formatting intended, it has to be in HTML.
recommonmark==0.5.0.dev0
solves this problem.
conf.py
configuration
extensions = [
# other
'recommonmark',
]
source_suffix = ['.rst', '.md']
pip
configuration (requirements.txt
)
sphinx==1.8.2
# recommonmark==0.5.0.dev0
git+https://github.com/rtfd/recommonmark
Please refer to https://www.sphinx-doc.org/en/master/usage/markdown.html if you need more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With