Bearhug wraps text patterns with configurable html tags. It's fast, flexible, and best of all, has no dependencies.
The available options that can be passed to window.bearhug
.
-
node
– The element to wrap patterns within. Required. -
pattern
– A pattern or an array of patterns that bearhug will wrap. Required. -
tagName
– The tag name of the element matched patterns will be wrapped in. Defaults tostrong
. -
className
– The class of the element matched patterns will be wrapped in. -
wordsOnly
– Iftrue
, only whole words will be matched and wrapped. Defaults tofalse
. -
caseSensitive
– Iftrue
, pattern matching will be case sensitive. Defaults tofalse
.
<!DOCTYPE html>
<html>
<head>
<script src="/bearhug.js"></script>
</head>
<body>
<article id="hipster-ipsum">
<p>Craft beer cardigan trust fund, swag tumblr pork belly kale chips
vegan plaid ethical artisan. Mumblecore wolf leggings cornhole before
they sold out trust fund. Keffiyeh shabby chic pug Pinterest
letterpress.<p>
</article>
<script>
var node = document.getElementById('hipster-ipsum');
bearhug({ node: node, pattern: ['beer', 'wolf'], className: 'stuff' })
</script>
</body>
</hmtl>
Tests are written using Jasmine and ran with Karma.
To run Bearhug's test suite with PhantomJS, run npm test
.
Found a bug? Create an issue on GitHub.
https://github.com/jharding/bearhug/issues
For transparency and insight into the release cycle, releases will be numbered with the follow format:
<major>.<minor>.<patch>
And constructed with the following guidelines:
- Breaking backwards compatibility bumps the major
- New additions without breaking backwards compatibility bumps the minor
- Bug fixes and misc changes bump the patch
For more information on semantic versioning, please visit http://semver.org/.
Copyright (c) 2013 Jake Harding
Licensed under the MIT License.