Variables inside hyperlinks

134 views
Skip to first unread message

William Abernathy

unread,
Aug 8, 2019, 12:08:12 PM8/8/19
to sphinx...@googlegroups.com
I am trying to automate our documentation (rst/sphinx to html and to xetex/PDF output)

I want to stick a version variable into a hyperlink as follows:


From posts on other forums, I understand that this breaks the logic of RST (one apparently cannot nest inline markup).

Is there a workaround, or has this been fixed?

I can't figure out which version of Sphinx I have installed, and if you could help with that, I'd be most appreciative as well. 

--Cheers,


William Abernathy

Sr. Tech Writer

San Francisco

Stefano David

unread,
Aug 9, 2019, 9:38:52 AM8/9/19
to sphinx-users
Hello William,


On Thursday, 8 August 2019 18:08:12 UTC+2, William Abernathy wrote:
I am trying to automate our documentation (rst/sphinx to html and to xetex/PDF output)

I want to stick a version variable into a hyperlink as follows:


From posts on other forums, I understand that this breaks the logic of RST (one apparently cannot nest inline markup).

Is there a workaround, or has this been fixed?
You can simulate that result, but not perfectly, by using the extlinks extension and defining a custom role.  Setup:
* in conf.py:
extensions = [ 'sphinx.ext.extlinks' ] # add to your list of extensions
extlinks = {
    'ver':
    ('https://documentation.com/product/%s/index.html', 'version ')
}

* in any file, use the role _ver_ inline:

please check :ver:`4.0` of the product.

I thinks there's no better solution/workaround to your problem now, unless the "link text" you mention is always the same (then put it in conf.py instead of 'version ') or want to create a new role for each variant of "link text".

I can't figure out which version of Sphinx I have installed, and if you could help with that, I'd be most appreciative as well. 
 Issue sphinx-build --version from the command line. For the record, I successfully use in my projects the same syntax used above since Sphinx 1.6.

HTH,
Stefano

William Abernathy

unread,
Aug 9, 2019, 8:00:14 PM8/9/19
to sphinx...@googlegroups.com
I squealed for help in another forum, and some nice fellow cooked this up!

https://pypi.org/project/sphinx-version-ref/

I haven't figured out how to make it work yet (sphinx can't find the extension), but it looks quite promising!

--William

--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/b80e6c8f-9c8b-47ab-8c6f-694df9b2cbde%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages