Skip to content

docutils hyperlink targets don't work for clickable cards #164

Open

Description

@ngulden

Describe the bug

Thanks for providing the sphinx-design extension. I use it together with Pydata Sphinx Theme to build a navigation page for our product documentation. See https://docs.software-univention.de/. I want to convert all cards there to clickable cards.

I want to use hyperlink targets as defined in docutils. My document supports several languages. Depending on the language, I include a different link.txt file. They have the same hyperlink name, but a different hyperlink target, depending on the language.

context

I want to use hyperlink targets for clickable cards:

.. grid-item-card:: some title
   :link: hyperlink-target-name_

Using

.. grid-item-card:: `some title <hyperlink-target-name_>`_

works. But then the card isn't clickable and just the title of the card. I want to whole card to be clickable with hyperlink targets.

expectation

I need the clickable card to render the link as defined in the hyperlink target.

bug

The link then just renders to http://$host/$path/hyperlink-target-name_ instead of the external link I want to have.

problem

This is a problem for people who have a document with different languages and need links depending on the language. The :link: option isn't part of the translation.

Reproduce the bug

  1. Create an empty Sphinx project and add the extensions pydata_sphinx_theme and sphinx_design to the conf.py.
  2. Create a file links-en.txt:
.. _hyperlink-target: https://www.example.com
  1. Create a file links-de.txt:
.. _hyperlink-target: https://www.example.de
  1. To your conf.py, add:
rst_epilog = """
.. include:: /links-en.txt
"""

def adapt_settings_to_translation(app, config):
    if config.language == "de":
        config.rst_epilog = """
.. include:: /links-de.txt
"""

def setup(app):
    app.connect("config-inited", adapt_settings_to_translation)
  1. To you index.rst file add:
.. grid:: 4
   .. grid-item-card:: Some title
      :link: hyperlink-target_

List your environment

  • Python 3.9.2
pydata-sphinx-theme==0.13.3
sphinx_design==0.5.0
Sphinx==5.0.0
docutils==0.17.1

Activity

  1. added
    bug
    on Sep 20, 2023
  2. welcome commented on Sep 20, 2023

    @welcome

    Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

    If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

    If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

    Welcome to the EBP community! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions