Shorter matches blocking longer matches

Created on 4 July 2016, almost 9 years ago
Updated 3 February 2025, 2 months ago

Problem/Motivation

Glossify was replacing shorter matching strings with links, and therefore blocking longer strings which also match from being replaced with links.

For example:

I have three node with titles:

  1. gene
  2. genetic
  3. gene technology, genetic engineering, genetic modification, gene therapy

I also have node content which contains the string "gene technology, genetic engineering, genetic modification, gene therapy". Instead of this string become a single link to the node with the same title, it strings "gene" and "genetic" get converted to links first and stop the longer string from being matched. The XPath query excludes links

$xpath->query('//text()[not(ancestor::a)]')

Proposed resolution

Update SQL query which generates the array of terms/node title to be ordered by char_length so longer strings are matched first. Longer strings are harder to match so it makes sense to match them first.

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Closed: outdated

Version

4.0

Component

Code

Created by

🇦🇺Australia ajf__

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024