python-sphinxrestructuredtextglossary

How to refer a glossary term defined in singular but expressed in plural?


If I define a glossary and a term called foobar, I can then use that term from text as

This is a ref to the :term:`foobar` term.

This will then make foobar into a clickable reference taking me to the glossary.

However, what if I want to refer to a term but display it differently, e.g., in plural, such as "I have many foobars", where foobar is recognized as term and linked to the glossary?

The following will not work as a character immediately following the closing back tick will mess it up so that it's not recognized as a term link at all.

I have many :term:`foobar`s

Adding a space before the s obviously looks bad. It would be nice if it was possible to mark the entire word "foobars" as a link to the term foobar. Is this possible?


Solution

  • See e.g. https://sublime-and-sphinx-guide.readthedocs.io/en/latest/glossary.html:

    You can link to a term in the glossary while showing different text in the topic by including the term in angle brackets. For example:

    :term:`reStructuredText<RST>`
    

    The term in angle brackets must exactly match a term in the glossary. The text before the angle brackets is what users see on the page.

    In your case:

    I have many :term:`foobars<foobar>`
    

    If you don't like the repetition, see Writing terms in plural without the redundancy