1.0.7 • Published 2 years ago

markari v1.0.7

Weekly downloads
55
License
MIT
Repository
github
Last release
2 years ago

Markari

Wrap searched words in a string with <mark> tags. Ideal for highlighting the queried word in search results

Install

yarn add markari

Usage
import { markWords } from 'markari'

const original = 'And if the day would only come, then you might just appear, even though you\'d soon be gone';

/**
 * Replaces all instances in sentence. 
 */
const result = markWords('you', original);
console.log(result)
// And if the day would only come, then <mark>you</mark> might just appear, even though <mark>you</mark>\'d soon be gone

/**
 * Can wrap whole sentences.
 */
const result2 = markWords('And if the day would only come', original);
console.log(result2)
// <mark>And if the day would only come</mark>, then you might just appear, even though you\'d soon be gone

/**
 * Does not edit original string, if no search words are found 
 */
const result3 = markWords('not found in sentence', original);
console.log(result3)
// Original sentence is the same, no extra markup

What's in the name?

Markari comes from Old Norse verb "marka" (to mark, to draw outline, to sketch). It means the person doing the verb, someone who "marks".

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago