realtimeprojects / mkdocs-ezglossary

Glossary support for mkdocs
MIT License
8 stars 1 forks source link

Multiple terms matching the same definition #18

Open wwarriner opened 3 weeks ago

wwarriner commented 3 weeks ago

I'm enjoying the idea of this glossary for helping our users understand relevant terms related to our Research Computing services (https://docs.rc.uab.edu), like our HPC cluster. Many researchers are not familiar with specialized computing terms, so a centralized glossary with easy linking would be a helpful addition to our documentation. So, I want to make this plugin work for us.

As I'm experimenting with this plugin, I'm not seeing a way to facilitate defining terms and their other affixed word forms, especially plurals. For example, if I wanted to define "GPU" I can use <terms:GPU> to link to the appropriate definition, great! However, I don't see a way to link "GPUs" to the same definition.

I would like to instruct the plugin to redirect <terms:GPUs> to the definition for "GPU". When I try following my inuition, as in the following code block, it does not work as expected. Instead I see the following image.

terms:GPU
terms:GPUs
:   Graphics Processing Unit (GPU). ...

image

What are my options? Did I miss something in the docs? If not, I have some free time and might be agreeable to a PR, but I'd need to know where to start.

realtimeprojects commented 1 week ago

I am glad to hear you plan to use this plugin for your site!

At this point of time, a solution to this problem like you suggested will not work since the plugin is based on the material definition lists or - better to say - on html description lists which both do not support multiple terms for the same definition.

At this point of time, the only way to achieve what your are intending is to overwrite the linked text as you can see in this example:

Screen Shot 2024-06-19 at 13 18 14

However, I can imagine that in some cases this might be inconvinient, especially if you have a large number of editors to your documentation. So I will think about a solution where you can define aliases. At this time, I think to:

  1. either add alias definitions in the configuration, like:
plugins:
    - search
    - ezglossary:
        aliases:
            terms:
                 - GPUs: GPU
  1. add an alias tag so that you can put aliases directly into your documentation.

Example:

terms:GPU
:     Graphics Processing Unit (GPU). ...
       <alias:GPUs>

I will think about a proper solution, meanwhile, it would be great to get some feedback from you about your preferred solution.

realtimeprojects commented 1 week ago

While thinking over this issues, I recognized that the most common use case for your demand is to cover links that want to use the plural form of a term in the link text while linking to the term in singular. So I came up with another approach to at least cover this issue: Handling plurals.

This feature is now available as a pre-relase on pypi.org and can be installed using:

pip3 install mkdocs-ezglossary-plugin>=1.7.0a3

I would appreciate if you give this version a try and:

Addtionally, a generic feature for defining real aliases is still planned in near future.

wwarriner commented 5 days ago

Hey there, thanks for the fast reply and for adding this! Apologies my reply took some time. I will get to testing it as soon as I am able.