Posted by Jeff Burnz on February 20, 2011 at 5:06pm
5 followers
Jump to:
| Project: | Drupal core |
| Version: | 8.x-dev |
| Component: | markup |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
| Issue tags: | html5, markupmarines |
Issue Summary
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
#1
Sounds like a good idea for Drupal 8, thanks for the suggestion!
#2
Agreed. This should run through
theme_mark()which should be updated to use the<mark>element.#3
Created an issue for
theme_mark(): #1311372: theme_mark() should use the <mark> element, not <span>.#4
Also related #493270: search_excerpt() doesn't work well with stemming
i think we need both preprocess and theme for excerpt
#5
Changing the component to markup. Hopefully it will get more visibility there.
#6
theme_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:
<?php/**
* Returns HTML for a piece of text with keywords highlighted.
* @param $variables
* An associative array containing:
* - text: Text containing keywords to highlight.
* - keys: An array of words to highlight.
* - boundary: A pattern that specifies word boundaries.
*/
function theme_search_highlight($variables) {
$pattern = '/' . $variables['boundary'] . '(' . implode('|', $variables['keys']) . ')' . $variables['boundary'] . '/iu';
return preg_replace($pattern, '<mark>\0</mark>', $variables['text']);
}
?>