1.2.0 • Published 5 years ago

wrap-with-tag v1.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

wrap-with-tag

Build Status Coverage Status npm version

Wrap-with-tag provides a simple function to wrap string with html.

Description

Wrap-with-tag provides a function wrapping specific word with html tag assigned with certain class.
The use case is to wrap specific word, like a company name, with a span element assigned with class for applying font-family.

Docs

Install

$ yarn add wrap-with-tag

or

$ npm install wrap-with-tag -d

Usage

The recommend use case is using import statements.

import wrapWithTag from 'wrap-with-tag';

wrapWithTag({
  regexp: /(Company Name)/g,
  className: 'special-font',
  tagName: 'span',
  attr: {
    tabindex: -1
  }
});

Alternatively, you can use script tag with html file.
You can find all versions of the CDN at UNPKG.

<script src="https://unpkg.com/wrap-with-tag">
<script>
wrapWithTag({
  regexp: /(Company Name)/g,
  className: 'special-font',
  tagName: 'span',
  attr: {
    tabindex: -1
  }
});
</script>

Options

namedefaultdescription
regexp/(a-zA-Z0-9,¥.-+)/gThe regular expression of string wrapped with html tag defined with tagName option.
classNamediffThe string is added to html tag defined with tagName option.
tagNamespanThe html tag wraps string.
attr{}The object is applied to html tag defined with tagName option.

Licence

MIT

Author

kzhrk

1.2.0

5 years ago

1.1.0

6 years ago

1.0.1-readme

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago