Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rich-text-converter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rich-text-converter

A JavaScript library to convert normal text into rich text with support for hashtags, mentions, bold, and underline.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
32
increased by77.78%
Maintainers
1
Weekly downloads
 
Created
Source

Rich Text Converter

License: MIT npm version Visitors

A JavaScript library to convert normal text into rich text with support for hashtags, mentions, bold, and underline.

Installation

Using npm

You can install this package via npm:

npm install rich-text-converter

CDN Integration

You can also use the library directly from a CDN:

<!-- Include RichTextConvertor.js from jsDelivr -->
<script src="https://cdn.jsdelivr.net/gh/SH20RAJ/RichTextConvertor/RichTextConvertor.min.js"></script>

Usage

Browser

// Create a new instance of RichTextConverter
const converter = new RichTextConverter();

// Example usage
const inputText = "Check out #trending topics and mention @user in this **cool** __text__!";
const richText = converter.convert(inputText);

console.log(richText);

Node.js

You can also use the library in Node.js:

const RichTextConverter = require('rich-text-converter');

// Create a new instance of RichTextConverter
const converter = new RichTextConverter();

// Example usage
const inputText = "Check out #trending topics and mention @user in this **cool** __text__!";
const richText = converter.convert(inputText);

console.log(richText);

Configuration

You can customize the conversion by providing your own configurations for hashtags, mentions, bold, and underline styles:

const config = {
  hashtags: {
    url: 'https://example.com/hashtag/$1',
  },
  mentions: {
    url: 'https://example.com/user/$1',
  },
  bold: {
    replace: '<strong>$1</strong>',
  },
  underline: {
    replace: '<u>$1</u>',
  },
};

const converter = new RichTextConverter(config);

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

This library is created and maintained by SH20RAJ.

If you find any issues or have suggestions, feel free to open an issue or contribute by submitting a pull request.

Keywords

FAQs

Package last updated on 31 Mar 2024

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

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