簡體   English   中英

Sphinx和Markdown .md鏈接

[英]Sphinx and Markdown .md links

我正在嘗試使用Sphinx將Markdown文件轉換為html,但無法將[links](another.md)轉換為<a href="another.html">links</a> ,而無法目標保留為原始.md並顯示為<a href="another.md">links</a>

我創建了一個簡單的示例...

測試文件

[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 我幾天前問過,有人指出要使用recommonmark的AutoStructify (請參見此處的線程),但是沒有用,在進一步的挖掘/讀取中,結果表明enable_auto_doc_ref現在已被棄用.md鏈接添加為:any:並且應該由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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM