Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Markdown link to reStructuredText anchor in Sphinx

Is it possible in any way to insert a link to a Markdown file that points to an anchor in a reStructuredText file?

I have a project documentation that contains .rst and .md files as well, and I'm using the m2rr Sphinx extension, however it only seems to support in-file rst anchor links.

Is there any way to achieve this?

like image 967
waszil Avatar asked Dec 30 '25 12:12

waszil


1 Answers

Markdown itself does not support cross-referencing to arbitrary locations across documents.

One workaround is to insert an HTML based anchor.

[My Label](/root-relative-url.html#anchor-in-page)

Another option is to use MyST. Here you would instead of using markdown for the anchor, you would use either MyST syntax or embed reST syntax.

Target headers are defined with this syntax:

(header_target)=

They can then be referred to with the ref inline role:

{ref}`header_target`

By default, the reference will use the text of the target (such as the section title), but also you can directly specify the text:

{ref}`my text <header_target>`
like image 153
Steve Piercy Avatar answered Jan 01 '26 04:01

Steve Piercy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!