Neurotic Programmer Masquerade

    em-highlight

    0.0.92 • Public • Published

    EM Highlight

    Looks for given words or expressions in a text and highlights them with <em class='highlight'> TERM </em>

    Usage

    var highlight = require('em-highlight');
     
    var text   = "We cannot rule this rule out on other rules and there is no stopping.";
    var lookup = [
        "rule",
        "rule out"
    ];
     
    var result = highlight.find(text, lookup);
     
    // "We cannot <em class='highlight'> rule </em> this
    //  <em class='highlight'> <em class='highlight'> rule </em> out </em> on other
    //  rules and there is no stopping."

    Notes

    • Allows case insensitive matching.
    • Not extensively tested with very large texts.
    • Nested lookup terms are highlighted again. You could use css opacity to display this.

    Install

    npm i em-highlight

    DownloadsWeekly Downloads

    7

    Version

    0.0.92

    License

    MIT

    Last publish

    Collaborators

    • tessmore