New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

text-annotator-v2

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

text-annotator-v2 - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

2

package.json
{
"name": "text-annotator-v2",
"version": "1.0.7",
"version": "1.0.8",
"description": "A JavaScript library for locating and annotating plain text in HTML",

@@ -5,0 +5,0 @@ "main": "build/text-annotator-v2.js",

@@ -144,3 +144,2 @@ import TextAnnotator from '../src/text-annotator-v2'

textAnnotator.unannotateAll([0, 1])
console.log(textAnnotator.html)
const annotatedHtml = textAnnotator.annotate(0)

@@ -155,3 +154,3 @@ expect(annotatedHtml).toBe(

const annotatedHtml = textAnnotator.annotate(
textAnnotator.search('Zhan Huang')
textAnnotator.search(' zhan huang ')
)

@@ -162,1 +161,60 @@ expect(annotatedHtml).toBe(

})
test('do not trim the search terms', () => {
const textAnnotator = new TextAnnotator('I am Zhan Huang')
const annotationIndex = textAnnotator.search(' zhan huang ', { trim: false })
expect(annotationIndex).toBe(-1)
})
test('make the search case sensitive', () => {
const textAnnotator = new TextAnnotator('I am Zhan Huang')
const annotationIndex = textAnnotator.search('zhan huang', {
caseSensitive: true,
})
expect(annotationIndex).toBe(-1)
})
test('add prefix and postfix of the search terms', () => {
const textAnnotator = new TextAnnotator('I am Zhan Huang')
const annotationIndex = textAnnotator.search('zhan huang', {
prefix: 'am ',
postfix: '.',
})
expect(annotationIndex).toBe(-1)
})
test('annotate using mark tags', () => {
const textAnnotator = new TextAnnotator('I am Zhan Huang')
const annotatedHtml = textAnnotator.annotate(
textAnnotator.search('zhan huang'),
{ tagName: 'mark' }
)
expect(annotatedHtml).toBe(
'I am <mark class="annotation annotation-0">Zhan Huang</mark>'
)
})
test('annotate using a different base class name', () => {
const textAnnotator = new TextAnnotator('I am Zhan Huang')
const annotatedHtml = textAnnotator.annotate(
textAnnotator.search('zhan huang'),
{ baseClassName: 'highlight' }
)
expect(annotatedHtml).toBe(
'I am <span class="highlight annotation-0">Zhan Huang</span>'
)
})
test('annotate using a different class pattern', () => {
const textAnnotator = new TextAnnotator('I am Zhan Huang')
const annotatedHtml = textAnnotator.annotate(
textAnnotator.search('zhan huang'),
{ classPattern: 'highlight-' }
)
expect(annotatedHtml).toBe(
'I am <span class="annotation highlight-0">Zhan Huang</span>'
)
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc