• Resolved joncampbell

    (@joncampbell)


    We have titles like:
    Social Q&A: New Take On An Old Genre
    or categories such as:
    Marketing & Finance

    In Algolia these end up in the index with the ampersand replaced by
    & a m p ; (with spaces removed… this editor wont let me type it out)

    Is this something the plugin should adjust in the way the data is being sent to Algolia, something we can fix in the index configuration (I did try adding ampersand to separatorsToIndex), or something we will need to overcome in the frontend template where the content is displayed?

    • This topic was modified 4 years, 11 months ago by joncampbell.
    • This topic was modified 4 years, 11 months ago by joncampbell.
    • This topic was modified 4 years, 11 months ago by joncampbell. Reason: trying to explain the ampersand output
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    What does your JS template looks like where that variable is being output?

    Thread Starter joncampbell

    (@joncampbell)

    Even using the default instantsearch.php template it does it.
    So post_title looks like this:
    {{{ data._highlightResult.post_title.value }}}
    and {{ data.post_title }} where it is used.

    Plugin Contributor Richard Aber

    (@richaber)

    Howdy @joncampbell

    When I add a test post into my local dev install, using an ampersand character in the title, I do not experience that behavior. It is stored in both my WP database and in my Algolia index as the & character. When I search for that post on the front end with instantsearch and autocomplete the character displays as an ampersand, not the HTML entity.

    Do you know if it is stored as an HTML entity in your WP database?

    Thread Starter joncampbell

    (@joncampbell)

    Cool cool cool.
    My titles and terms have the html entities stored in the WordPress database.
    I’ll just go have a good cry and then ask my client why we are doing that.

    Thread Starter joncampbell

    (@joncampbell)

    @richaber It looks like the post titles is something we can fix in our content.
    But the categories it seems like WordPress saves those to the database with the full html entity, instead of just the ampersand.

    Maybe that is something that could be fixed in the plugin for everyone.

    Plugin Contributor Richard Aber

    (@richaber)

    Howdy @joncampbell,

    I am unable to reproduce the issue locally.

    When I check my database for the term “Marketing & Finance”, indeed I see the ampersand as an HTML entity in the database:

    
    mysql> SELECT * FROM local.wp_terms WHERE name LIKE "%Marketing%";
    +---------+-------------------------+-------------------+------------+
    | term_id | name                    | slug              | term_group |
    +---------+-------------------------+-------------------+------------+
    |     202 | Marketing & Finance | marketing-finance |          0 |
    +---------+-------------------------+-------------------+------------+
    

    However, when I check my Algolia index record, the ampersand does not appear as an HTML entity there:

    
    {
      "term_id": 202,
      "taxonomy": "category",
      "name": "Marketing & Finance",
      "description": "",
      "slug": "marketing-finance",
      "posts_count": 1,
      "permalink": "https://algolia.test/category/marketing-finance/",
      "objectID": "202"
    }
    

    If I search for “Marketing” in my test site, the autocomplete drop down does not display the ampersand as an html entity, but as the decoded & character.

    Can you determine if the ampersand is encoded as an HTML entity in your Algolia index? Also, where the value is visibly output, can you check that the code is using the triple-stash style for unescaped output {{{ value }}}.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Dealing with HTML Entities’ is closed to new replies.