Support » Plugin: CM Tooltip Glossary » Fix for apostrophe in glossary terms

  • Resolved Paul Ryan

    (@figureone)


    Aloha,

    The issue with apostrophes that was fixed in version 3.1.3 has come back; terms with apostrophes in them won’t get highlighted in page content. The issue happens now because WordPress translates apostrophes to the right single quote html entity, which needs to be converted back to an apostrophe to satisfy the regex match.

    Here’s the quick fix. Replace line 385 of cm-tooltip-glossary-frontend.php:
    https://plugins.trac.wordpress.org/browser/enhanced-tooltipglossary/trunk/frontend/cm-tooltip-glossary-frontend.php#L385
    if ( !$dom->loadHtml( mb_convert_encoding( $html, 'HTML-ENTITIES', "UTF-8" ) ) ) {

    With:

    $html = mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' );
    $html = str_replace( '& #8217;', "'", $html );
    $html = str_replace( '’', "'", $html );
    if ( ! $dom->loadHtml( $html ) ) {

    (Note: remove the space in the html entity on line 2; WordPress forums munges the code snippet.)

    This should catch all occurrences. It will first convert utf8 characters to html entities, and then convert the right single quote entities to the plain apostrophe that matches the regex elsewhere in the plugin.

    • This topic was modified 11 months, 1 week ago by  Paul Ryan.
    • This topic was modified 11 months, 1 week ago by  Paul Ryan.
    • This topic was modified 11 months, 1 week ago by  Paul Ryan.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author CreativeMinds

    (@creativemindssolutions)

    Hi Paul,

    Thanks for pointing out to this problem and the suggested fix. It will be implemented in the nearest release.

    Best,
    CM Plugins

    KTS915

    (@kts915)

    There’s a big problem with the suggested fix, though. It changes smart right apostrophes to plain (dumb) apostrophes throughout the front-end of the site, and not just for the purposes of running the glossary parser.

    For anyone who is using smart apostrophes, the result is a mess, because left apostrophes then appear smart (as intended) while right apostrophes appear dumb.

    Hm, maybe move the quote detection into the regular expression used to perform the matches ($glossarySearchString)? So any glossary term with single quotes would also match smart apostrophes…

    Plugin Author CreativeMinds

    (@creativemindssolutions)

    Hi,

    @paul – the regex code responsible for term needs to take the term as-is, do you suggest that the we should treat versions with different apostrophes (dumb/smart) as variations of the main term?

    Best,
    CM Plugins

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Fix for apostrophe in glossary terms’ is closed to new replies.