I am using Sphinx to build a documentation out of Markdown files.
The documentation is pretty clear that myst-parser should handle markdown links in the typical [some text](www.example.com)
manner.
Subsequently I installed myst-parser, set the extension extensions = ['myst_parser']
and specified the source_suffix:
source_suffix = {
'.rst': 'restructuredtext',
'.txt': 'markdown',
'.md': 'markdown',
}
Unfortunately the links did not get converted correctly and are just displayed written out as the following HTML:
[some text](<a class="reference external" href="www.example.com">www.example.com</a>)
This is then displayed in the following manner [some text](www.example.com)
in the browser, which is clearly not the intended link.
I also tried to use Recommonmark in the following manner:
from recommonmark.parser import CommonMarkParser
source_parsers = {
'.md': CommonMarkParser,
}
source_suffix = ['.rst', '.md']
As explained here and here, but ended up with the same output. How can this rather simple issue be fixed?
Versions being used: recommonmark 0.7.1 myst-parser 0.13.6 sphinx 3.5.4 python 3.9.2
EDIT Find here the updated conf.py file
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
import sphinx_rtd_theme
import sys
import os
print("CURRENT WORKING DIRECTORY")
print(os.getcwd())
print('adding path')
sys.path.insert(0, r'path_to_repo')
print(sys.path)
# At top on conf.py (with other import statements)
import recommonmark
from recommonmark.transform import AutoStructify
from recommonmark.parser import CommonMarkParser
# -- Project information -----------------------------------------------------
project = 'py_neuromodulation'
copyright = '2021, John Doe'
author = 'John Doe'
source_parsers = {
'.md': 'recommonmark.parser.CommonMarkParser',
}
source_suffix = ['.rst', '.md']
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
'numpydoc',
'sphinx_rtd_theme',
'sphinx.ext.napoleon',
'recommonmark'
]
autosummary_generate = True
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
# At the bottom of conf.py
def setup(app):
app.add_config_value('recommonmark_config', {
'url_resolver': lambda url: github_doc_root + url,
'auto_toc_tree_section': 'Contents',
}, True)
app.add_transform(AutoStructify)
By default, you must include a protocol for external links.
However if you want to use bare links without the protocol, then use Linkify:
The following code example demonstrates what the documentation describes.