An open API service indexing awesome lists of open source software.

https://github.com/stscoundrel/markari

Wraps searched word with "mark" tags in content.
https://github.com/stscoundrel/markari

highlight javascript mark nodejs typescript

Last synced: 6 months ago
JSON representation

Wraps searched word with "mark" tags in content.

Awesome Lists containing this project

README

          

# Markari

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

### Install

`yarn add markari`

##### Usage

```javascript
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 you might just appear, even though you\'d soon be gone

/**
* Can wrap whole sentences.
*/
const result2 = markWords('And if the day would only come', original);
console.log(result2)
// And if the day would only come, 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".