Sphinx和Markdown.md链接 [英] Sphinx and Markdown .md links

查看:23
本文介绍了Sphinx和Markdown.md链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Sphinx将Markdown文件转换为html,但在将[links](another.md)转换为<a href="another.html">links</a>时遇到困难,而目标的扩展名保持原始的.md并显示为<a href="another.md">links</a>

我已经创建了一个简单的示例...

test.md

[Test link](https://www.stackoverflow.com)

[Another Markdown doc](another.md)

另一个.md

# Another test markdown
这两个文件都位于顶级目录中,我运行sphinx-quickstart以创建conf.py,并接受默认设置。然后,我将conf.py修改为...

from recommonmark.parser import CommonMarkParser
extensions = [
    'sphinx.ext.autodoc',
]
source_suffix = ['.rst', '.md']
source_parsers = {
    '.md': CommonMarkParser,
}

生成的html文件,但从test.htmlanother.html的链接不正确,显示为...

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>
...
并指向another.md而不是another.html。几天前我问过了,并被指向使用推荐标记的AutoStructify(参见帖子here),但这不起作用,进一步挖掘/阅读后发现enable_auto_doc_ref is now deprecated.md links are added as :any: and should be handled by Sphinx

但我不明白为什么这不起作用,或者我应该做些什么来解决它。如有任何建议,我们将不胜感激。

编辑

版本如下

  • Sphinx 1.8.0
  • 推荐0.4.0

推荐答案

recommonmark==0.5.0.dev0解决了此问题。

conf.py配置

extensions = [
    # other
    'recommonmark',
]

source_suffix = ['.rst', '.md']

pip配置(requirements.txt)

sphinx==1.8.2
# recommonmark==0.5.0.dev0
git+https://github.com/rtfd/recommonmark

如果需要更多详细信息,请参阅https://www.sphinx-doc.org/en/master/usage/markdown.html

这篇关于Sphinx和Markdown.md链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆