Don't consider a term replaced if it is in an element with glossify-exclude

Created on 9 July 2025, 2 months ago

Problem/Motivation

This is a followup to Don't replace term if there is already a link on this term in the page Active .
If a word is found in an element of the page that has the glossify-exclude class, it will be considered as already glossified and will not be replaced elsewhere in the page.

This is confusing for our users. They don't understand why we don't glossify a term because it is in a part of the page that has nothing to do with glossify.

Steps to reproduce

Proposed resolution

Don't add the term to $replaced if it was found in an element with the glossify-exclude class.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

3.1

Component

Code

Created by

🇫🇷France prudloff Lille

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @prudloff
  • Pipeline finished with Success
    2 months ago
    Total: 203s
    #542874
  • Status changed to Needs review 7 days ago
  • First commit to issue fork.
  • 🇩🇪Germany Grevil

    Totally makes sense! Thanks for the fix!

    I added a test to reproduce this issue. Here is the test output without the changes by @prudloff in place:

    There was 1 failure:
    
    1) Drupal\Tests\glossify\Unit\GlossifyBaseTest::testParseTooltipMatch with data set "set32" ('<div class="glossify-exclude"...ified.', [stdClass Object (...)], true, true, 'tooltips', false, '', '', '<div class="glossify-exclude"...ified.')
    Failed asserting that two strings are equal.
    --- Expected
    +++ Actual
    @@ @@
    -'...><a>RT</a></div> Here is <span title="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularized in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.">RT</span> that should be glossified.'
    +'...><a>RT</a></div> Here is RT that should be glossified.'
    
    /var/www/html/web/modules/custom/glossify/tests/src/Unit/GlossifyBaseTest.php:35
    
  • Now that this issue is closed, please review the contribution record.

    As a contributor, attribute any organization helped you, or if you volunteered your own time.

    Maintainers, please credit people who helped resolve this issue.

Production build 0.71.5 2024