Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The current way of marking up highlighted keywords in the search snippet is to use <strong>
element, however I would like to use <mark>
(HTML5).
In D8 there is a lot of talk about shifting to HMTL5, while I am for this, I think we need to better support markup choices per se, so if you want to use HMTL4, XHTML or HTML5 you can, therefore we need to stop doing hard coded markup such as...
$text = preg_replace('/' . $boundary . '(' . implode('|', $keys) . ')' . $boundary . '/iu', '<strong>\0</strong>', $text);
... and make all markup themeable, i.e. this should use theme_mark or similar.
Comments
Comment #1
jhodgdonSounds like a good idea for Drupal 8, thanks for the suggestion!
Comment #2
JacineAgreed. This should run through
theme_mark()
which should be updated to use the<mark>
element.Comment #3
JacineCreated an issue for
theme_mark()
: #1311372: Use <mark> element for 'mark' theme hook.Comment #4
andypostAlso related #493270: search_excerpt() doesn't work well with stemming
i think we need both preprocess and theme for excerpt
Comment #5
JacineChanging the component to markup. Hopefully it will get more visibility there.
Comment #6
JvE CreditAttribution: JvE commentedtheme_mark is not applicable here. It "Returns HTML for a marker for new or updated content.", it does not take input other than the type of mark (new/read/updated).
I'm thinking the whole search_excerpt() function should be a theme function.
With text, keywords, length (currently fixed at 256) and dots (leading, dividing and trailing) as possible inputs.
Otherwise maybe add a theme function:
Comment #7
markhalliwellComment #8
mgiffordComment #17
catchReclassifying as a task and moving to search module.