krisajenkins / elm-exts / Exts.Html

Extensions to the Html library.

matchText : List (Html.Attribute msg) -> Regex -> String -> List (Html msg)

Highlight regex matches in a given piece of text. This is most easily explained with an example:

import Regex exposing (regex)
import Html.Attributes exposing (class)

matchText
  [class "match"]
  (regex "the")
  "the quick brown fox jumped over the lazy dog"

=>

[span [class "match"] [text "the"]
,text " quick brown fox jumped over "
,span [class "match"] [text "the"]
,text " lazy dog"]

Now you can add a CSS rule like `.match {background-color: yellow;}` to highlight matches
for the user.

(Note that you can supply any attributes you like for the matched sections, or an empty list.)

nbsp : String

A non-breaking space. elm-html doesn't support escape sequences like text "&nbsp", so use this string instead.