Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
hit-highlighter
Advanced tools
Small and simple hit highlighter for search engines running in the browser and Node.js
A small and simple hit highlighter for search engines running in the browser and Node.js. Takes a query array and where the values matches within the item array, it adds hightight code. Goes well with words'n'numbers for extracting words (and numbers) from a string of text.
Check out the interactive demo.
<script src="hit-highlighter.js"></script>
<script>
//highlight() available
</script>
const highlight = require ('hit-highlight')
// highlight() available
hightlight([query array], [item array], {highlighting object})
query
and item
are arrays of words. hightlighting
is an object defining start
and end
tag for what is highlighted.
highlighting.start
defaults to <span class="highlighted">
highlighting.end
defaults to </span>
const query = ['interesting', 'words']
const item = ['some', 'interesting', 'words', 'to', 'remember']
highlight(query, item)
// returns:
//[
// 'some',
// '<span class="highlighted">interesting</span>',
// '<span class="highlighted">words</span>',
// 'to',
// 'remember'
//]
const query = ['interesting', 'words']
const item = ['some', 'interesting', 'words', 'to', 'remember']
const highlighting = { start: '**', end: '**' }
highlight(query, item, highlighting)
// returns:
//[
// 'some',
// '**interesting**',
// '**words**',
// 'to',
// 'remember'
//]
const query = ['no', 'hits']
const item = ['some', 'interesting', 'words', 'to', 'remember']
highlight(query, item)
// returns:
//[
// 'some',
// 'interesting',
// 'words',
// 'to',
// 'remember'
//]
FAQs
Small and simple hit highlighter for search engines running in the browser and Node.js
The npm package hit-highlighter receives a total of 12 weekly downloads. As such, hit-highlighter popularity was classified as not popular.
We found that hit-highlighter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.