New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

jsx-highlighter

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsx-highlighter

Small and focused library to mark with a css classed span a part of an JSX HTML text.

latest
Source
npmnpm
Version
2.0.1
Version published
Maintainers
1
Created
Source

jsx-highlighter

Small and focused library to mark with a css classed span a part of an JSX HTML text.

If you like it, star; if you don't, please tell me why!! :)

Installation

npm install --save jsx-highlighter

Usage

Initialize it with the CSS class, search wildcard and searched text

import buildHighlighter from "jsx-highlighter";

...

// "highlighted"  is the CSS class applied to the wraping HTML span
// "%"            is the wildcard used to search (used only to analyze, removed from the final result)
// "%ome"         is the text searched for, so you'd want 'ome', 'Ome', 'OMe', etc to be highlighted
const highlight = buildHighlighter("highlighted", "%", "%ome");

// and when you build your JSX
return <div>{highlight("This is an awesome util!")}</div>;

All fields are mandatory.

This will give you as a result: <span>This is an awes<span class="highlighted">ome</span> util!</span>

Credits

@luispablo

Keywords

jsx

FAQs

Package last updated on 09 Sep 2020

Did you know?

Socket

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.

Install

Related posts