highlight-words-parser

1.0.1 • Public • Published

Highlight Words Parser

Features

Parse a give string to highlight words.

Installation

yarn add highlight-words-parser

or

npm i highlight-words-parser --save

Usage

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

Dependents (0)

Package Sidebar

Install

npm i highlight-words-parser

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

193 kB

Total Files

11

Last publish

Collaborators

  • somewind