Link directives in Rst grammar

60 Views Asked by At

How can I link directive with :doi: or :arxiv: in Rst.

I'm making a document with Rst, but when I try to link with arxiv, it shows broken link.

What I tried is below but not working.

<:doi:`10.1145/2487575.2487591>`

or

:arxiv:`1309.0238`
1

There are 1 best solutions below

0
On BEST ANSWER

The doi example can be addressed by using the extlinks Sphinx extension, by adding these contents to conf.py:

extlinks = {
    'doi': ('https://dx.doi.org/%s', 'doi:'),
}

(Source)

And for arxiv, something similar.


For a more generic case, you would need to either

  1. create a "custom role", see for example https://www.sphinx-doc.org/en/master/development/tutorials/helloworld.html (this tutorial creates a custom directive, but it should be similar), or
  2. find a Sphinx extension that already does it for you.