tecosaur / org-glossary

Mirror of https://git.tecosaur.net/tec/org-glossary
GNU General Public License v3.0
97 stars 4 forks source link

Do not recursively resolve acronyms to the glossary #19

Closed neuhalje closed 4 months ago

neuhalje commented 8 months ago

Situation

Acronyms that resolve to a glossary term are recursively resolved to the glossary definition on first use. In the following example glossary entries should not show the glossary definition. On first use an acronym should be resolved: elisp -> Emacs Lisp (elisp). It should, however, not be further resolved with the glossary definition.

The following example ...

The dream team of emacs and elisp.

* Acronyms
- elisp :: Emacs Lisp
* Glossary
- Emacs :: A lisp-based generic user-centric text manipulation environment that masquerades as a text editor.
- Emacs Lisp :: The Lisp dialect used to program Emacs.

... should be rendered as follows:

The dream team of [[emacs][link to glossary]] and Emacs Lisp ([[elisp][link to acronyms]).

but is rendered as

The dream team of [[emacs][link to glossary]] and The Lisp dialect used to program Emacs.([[elisp][link to acronyms]).

Mark that the acronym definition has been recursively resolved with the glossary definition.

Things I have tried

Updating the first-use of acronym to %k (%u) shows the desired result for entries that exhibit this nested definition. For some reason it will also prevent acronyms that do not resolve to a glosary entry from being resolved.

[...] your favorite ML with a unicorn mascot [...]

* Glossary
* Acronyms
- ML :: Markup Language

This example will translate into [...] your favorite ML ([[ML][..]] with a unicorn mascot [...] instead of [...] your favorite Markup Language ([[ML][..]] with a unicorn mascot [...]. That is ML (ML) instead of Markup Language (ML).

Example Code

(setf (plist-get (->> org-glossary-export-specs
                      (assoc 't)
                      (assoc 'acronym)
                      (cdr))
                 :first-use)
      "%k (%u)")
tecosaur commented 5 months ago

Thanks for the detailed bug report! I can't promise it will be soon (though I hope so), but I'll give this a look and see if I can work out what's going on :slightly_smiling_face:

barslmn commented 5 months ago

Hi I also have a similar case. I have an acronym and definition for the same concept.

* Acronyms
- PAR :: Pseudoautosomal region

* Glossary
- Pseudoautosomal region :: Region shared between the allosomes. PARs are located at the end of the chromosomes.

When I have just PAR in the text, Glossary is not printed.

image

If I define the acronym myself like Pseudoautosomal region (PAR) I got the following:

image

tecosaur commented 5 months ago

So, this is a bit tricky.

Essentially what's being asked for is double-expansion, with special acronym + glossary handling.

Currently, the actual expansion mechanisms for acronym and glossary entries are the same, but to have acronyms link to glossary entries while also expanding, a custom mechanism for handling this case would be needed.

One alternative approach would be to make it so that terms in the acronym/glossary section can themselves produce links. E.g. the Pseudoautosomal region text in the acronym section would automatically link to the glossary entry.

barslmn commented 5 months ago

I initial thought would be to create glossary linking after the acronym expension and have the link to glossary in text rather than having links to the glossary.

tecosaur commented 4 months ago

I'll see if I can try getting double-expansion working at some point in the future, and see if that's good enough.

tecosaur commented 4 months ago

@neuhalje I've just pushed 9e65c4b4397fb0befab3c1756a0b259e30058704, which will make your original example work as expected.

tecosaur commented 4 months ago

@barslmn with that commit and 0ff4365d9634bc90e08331c64f4be7a276af29a3, I think your example works out a lot more nicely now.

I'm about to tell you about PARs

* Acronyms
- PAR :: Pseudoautosomal region

* Glossary
- Pseudoautosomal region :: Region shared between the allosomes. PARs are located at the end of the chromosomes.

becomes

I'm about to tell you about pseudoautosomal regions (<<gr;2;1>>[[g;2][PARs]])

* Acronyms
- <<g;1>>PAR :: See <<gr;2;0>>[[g;2][pseudoautosomal region]].\ensp{}

* Glossary
- <<g;2>>Pseudoautosomal region :: Region shared between the allosomes. PARs are located at the end of the chromosomes.\ensp{}[[gr;2;1][1]]
tecosaur commented 4 months ago

I think this should be behaving well enough to close the issue now, let me know if this isn't the case.

barslmn commented 4 months ago

Hi Timothy, thanks a lot for your valueable time. The expansion works great.

I notice two things: First is the capitalization. Is there anything I can do to have the capitalized at the start of the sentences? Should define my own export template?

Second thing is that glossary ids are one off. Is it something about my session?

image