apply_filters( 'relevanssi_entities_inside_pre', boolean $allow )
apply_filters( 'relevanssi_entities_inside_code', boolean $allow )
These filters control whether Relevanssi runs htmlentities()
on content inside pre
and code
tags or not when highlighting terms in post content.
If you have HTML code inside pre
or code
tags on your pages and use the “Highlight query terms in documents” option, you need to set the matching filter to false
.
Parameters
$allow
(boolean) If true
, run htmlentities()
on tag content. Default true
.
More information
When Relevanssi creates excerpts, Relevanssi uses htmlentities()
to convert all characters to their entities. That’s fine in excerpt context, but very likely to get into trouble when adding highlights to full post content. Therefore Relevanssi won’t use htmlentities()
when applying highlights to full posts.
That does lead into trouble with content inside pre
and code
tags: that’s often some kind of code, and there the entities would be necessary to avoid a mess. Thus, Relevanssi will run htmlentities()
on all content inside pre
and code
tags. This works well, except when you have HTML content inside these tags. In that case Relevanssi in-document highlighting will mess up the HTML content thoroughly.
To avoid these problems, set the matching filter function to false
:
add_filter( 'relevanssi_entities_inside_code', '__return_false' ); add_filter( 'relevanssi_entities_inside_pre', '__return_false' );