https://github.com/somewind/highlight-words-parser
Parse a give string to highlight words.
https://github.com/somewind/highlight-words-parser
highlight highlightwords parser words
Last synced: 4 months ago
JSON representation
Parse a give string to highlight words.
- Host: GitHub
- URL: https://github.com/somewind/highlight-words-parser
- Owner: somewind
- License: mit
- Created: 2019-05-05T07:37:04.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T10:17:42.000Z (over 3 years ago)
- Last Synced: 2025-09-23T17:13:04.046Z (9 months ago)
- Topics: highlight, highlightwords, parser, words
- Language: JavaScript
- Size: 304 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Highlight Words Parser
## Features
Parse a give string to highlight words.
## Installation
```shell
yarn add highlight-words-parser
```
or
```shell
npm i highlight-words-parser --save
```
## Usage
```js
import { highlightWordsParser } from 'highlight-words-parser'
const highlightWords = highlightWordsParser('Error: this is a "test" message (from somewind)', {
keywords: [{
color: 'red',
value: [
'Error'
]
}],
scopes: [
{
color: 'green',
value: ['"', '"']
},
{
color: 'green',
value: ['(', ')']
}
]
})
console.log(highlightWords)
// Output:
//
// [ { color: 'red', value: 'Error' },
// { value: ': this is a ' },
// { color: 'green', value: '"test"' },
// { value: ' message ' },
// { color: 'green', value: '(from somewind)' } ]
```
You can use the result to render with `React` or other.
## License
[MIT](./LICENSE)