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.
- Host: GitHub
- URL: https://github.com/stscoundrel/markari
- Owner: stscoundrel
- License: mit
- Created: 2021-02-20T17:55:41.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-05-25T06:54:41.000Z (about 2 years ago)
- Last Synced: 2024-09-15T11:50:30.617Z (almost 2 years ago)
- Topics: highlight, javascript, mark, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 1.23 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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".