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

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.

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)