Closed (fixed)
Project:
Glossify
Version:
3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
6 Mar 2025 at 16:29 UTC
Updated:
19 May 2025 at 17:50 UTC
Jump to comment: Most recent
Sometimes the page already contains links manually added on terms.
When this happens and the $first_only option is used, glossify will still add a link on the next occurrence of the term.
We would prefer that it considers the term already linked.
<a href="http://example.com/">Lorem</a> ipsum.
Lorem ipsum.
If one of the terms is lorem, the second occurrence will be replaced although the first one is already a link.
Before parsing the text, GlossifyBase::parseTooltipMatch() should look for links containing terms.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
prudloff commentedComment #4
anybody#3102570: Glossify + Paragraphs: Multiple glossary links instead of one per node looks related?
Comment #6
grevil commentedThis fix currently only covers the case, when the glossify type is set to "links" or "tooltips_links". This doesn't cover the 'tooltips' case. I understand that this is a bit confusing, as the "First match only" description is a bit wrong:Match and LINK only the first occurrence per field
This setting also effects the tooltip creation, not only the link creation.
EDIT: Ok, never mind, it already works with "abbr" tags, because they are not excluded by the xpath query, @anybody, why don't we exclude "abbr" tags?
Comment #7
grevil commentedAnd I think we should put the logic into the "$text_nodes" foreach (in the reinserting first match if case), IF POSSIBLE! Might not be possible, as we exclude anchor tags in general, but maybe we can pass a flag, letting the reinsertion if case know, whats the case here.
Comment #8
grevil commentedIssue is unrelated.
Comment #9
grevil commentedOk, "abbr" tags should be handled properly now through #3519291: "abbr" tags are not being excluded from the xpath query.
Now my concern in #6 is valid again:
This fix currently only covers the case, when the glossify type is set to "links" or "tooltips_links". This doesn't cover the 'tooltips' case. I understand that this is a bit confusing, as the "First match only" description is a bit wrong:
This setting also effects the tooltip creation, not only the link creation.
Comment #10
joao.ramos.costa commented#4 Seems related.
I think the current MR there would fix this, no ?
Regards.
Comment #11
grevil commentedThis issue only targets glossified words inside links per textfield not properly working with the "first_only" setting.#3102570: Glossify + Paragraphs: Multiple glossary links instead of one per node suggests a solution working across multiple textfields.
Update: Sorry, this explanation was not very insightful. The MR in #3102570: Glossify + Paragraphs: Multiple glossary links instead of one per node wouldn't fix this issue. The problem of this issue is, that glossified words wrapped inside a or abbr tags would not be considered as a first occurence (when first_only ist enabled).
This is because we completely ignore a and abbr tags in our processing, so we don't accidentally rewrap them again and therefore, they are excluded from the "first_only" logic inside our text processing logic.
Comment #12
grevil commentedAlright LGTM! I added abbr support and added tests. LGTM! Thank you!
Comment #13
grevil commentedAll green, merging.
Comment #15
joao.ramos.costa commentedHi @grevil, thank you :) !
Comment #17
bkosborneHmm I'm not sure about this change. We use the tooltip mode (we don't link to the tooltip term pages, we just use the tooltip abbreviations). With this change, if the term first appears in some link on the page, it doesn't get tooltip'ed anymore. I think it should. The link is not going to the term page in our case - it goes to some other page on the site. I think that's what #6 mentioned, but I'm not sure this was addressed? Maybe this new functionality should be limited to only configurations that use "links" or "tooltip_links" setups?