https://github.com/lagden/highlight
Make the words shine
https://github.com/lagden/highlight
highlight mark module nodejs replace shine text umd word
Last synced: 9 months ago
JSON representation
Make the words shine
- Host: GitHub
- URL: https://github.com/lagden/highlight
- Owner: lagden
- License: mit
- Created: 2016-08-23T11:17:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:32:15.000Z (about 3 years ago)
- Last Synced: 2025-03-25T09:51:45.069Z (10 months ago)
- Topics: highlight, mark, module, nodejs, replace, shine, text, umd, word
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/lagden-highlight
- Size: 1.34 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# Highlight
[![Dependency Status][dep-img]][dep]
[![devDependency Status][devDep-img]][devDep]
[![XO code style][xo-img]][xo]
[![Greenkeeper badge][greenkeeper-img]][greenkeeper]
[ci-img]: https://travis-ci.org/lagden/highlight.svg
[ci]: https://travis-ci.org/lagden/highlight
[coveralls-img]: https://coveralls.io/repos/github/lagden/highlight/badge.svg?branch=master
[coveralls]: https://coveralls.io/github/lagden/highlight?branch=master
[dep-img]: https://david-dm.org/@tadashi/highlight.svg
[dep]: https://david-dm.org/@tadashi/highlight
[devDep-img]: https://david-dm.org/@tadashi/highlight/dev-status.svg
[devDep]: https://david-dm.org/@tadashi/highlight#info=devDependencies
[xo-img]: https://img.shields.io/badge/code_style-XO-5ed9c7.svg
[xo]: https://github.com/sindresorhus/xo
[greenkeeper-img]: https://badges.greenkeeper.io/lagden/highlight.svg
[greenkeeper]: https://greenkeeper.io/
Make the words shine
## Install
```
$ npm i -S @tadashi/highlight
```
## Usage
Basic usage
```js
const highlight = require('@tadashi/highlight')
const source = 'My name is Bond, James Bond...'
const q = 'James Bond'
highlight(source, q)
// My name is Bond, James Bond...
```
---
Without breaking the term into small words
```js
const highlight = require('@tadashi/highlight')
const source = 'My name is Bond, James Bond...'
const q = 'James Bond'
const split = false
highlight(source, q, {split});
// My name is Bond, James Bond...
```
---
Without breaking the term into small words and changing the template
```js
const highlight = require('@tadashi/highlight')
const source = 'My name is Bond, James Bond...'
const q = 'James Bond'
const tpl = '$&'
const split = false
highlight(source, q, {tpl, split});
// My name is Bond, James Bond...
```
---
Ignoring case sensitive
```js
const highlight = require('@tadashi/highlight')
const source = 'What a wonderful phrase'
const q = 'w'
const tpl = '$&'
const caseSensitive = false
highlight(source, q, {tpl, caseSensitive});
// What a wonderful phrase
```
## API
### highlight(source, q \[, options\])
Name | Type | Required | Default | Description
----------- | --------- | -------- | ------------------------------- | ------------
source | string | yes | - | Your text
q | string | yes | - | The term that will be shine
options | object | no | [see below](#options) | Options
#### options
Name | Type | Required | Default | Description
----------- | --------- | -------- | ------------------------------- | ------------
tpl | string | no | \$\&\ | Custom template
split | boolean | no | true | Break the term in many words
caseSensitive | boolean | no | true | Defines whether letters are treated as distinct
## License
MIT © [Thiago Lagden](http://lagden.in)