• Resolved Rob Migchels

    (@dhrrob)


    Hey Mikko,

    I am running into my first issue (ever, since using this plugin on 10+ websites) today. Hopefully you are able to help me figure this out.

    On my website, I am using the search hit highlighting in my body. This works fine generally speaking. It does however, also break some markup on my website when I am using Gutenburg preformatted blocks.

    This is an example of the code I should see (without highlighting enabled):
    <pre class="wp-block-preformatted"><a href="https://demo.com/" class="external external_icon" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">https://demo.com/</a></pre>

    This is what the output looks like with highlighting enabled:
    <pre class="wp-block-preformatted">& lt;a href="https://demo.com/" class="external external_icon" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)"& gt;https://demo.com/</a& gt;</pre>
    (I had to add spaces in order for WordPress to process it right)

    Notice how the <a> tag is sanitized in the 2nd result. Can I prevent this from happening? That way, the URL would keep working :).

    Thanks in advance!
    Rob

    • This topic was modified 4 years, 2 months ago by Rob Migchels. Reason: Formatting
    • This topic was modified 4 years, 2 months ago by Rob Migchels.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Try this in your theme functions.php:

    add_filter( 'relevanssi_entities_inside_pre', '__return_false' );

    Relevanssi assumes that pre tags contain program code, where doing the entities like this is the right thing to do. With HTML code, the requirements are different. Setting that filter to false will flip how this is handled.

    Thread Starter Rob Migchels

    (@dhrrob)

    That’s great, thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Search hit highlighting breaks content’ is closed to new replies.