Skip to main content

highlight

Function highlight 

Source
pub fn highlight(value: impl Display, phrase: &str) -> String
Expand description

The text, HTML-escaped, with each match of phrase (case-insensitive) in <mark> (Rails’ highlight).

The result is HTML: the highlight filter marks it safe.

§Examples

assert_eq!(
    ocre::helpers::highlight("Rust & rusty <tools>", "rust"),
    "<mark>Rust</mark> &amp; <mark>rust</mark>y &lt;tools&gt;"
);