Convert Plain Text to Rich Text with Ease!
Tags: javascript
Published: 2024-03-31 08:10:27


## Convert Plain Text to Rich Text with Ease!

{% github https://github.com/SH20RAJ/RichTextConvertor %}

Have you ever wanted to spice up your plain text with hashtags, mentions, bold, and underline styles? Look no further! Introducing the **Rich Text Converter** JavaScript library, your go-to solution for converting normal text into rich, formatted text.

### What is Rich Text Converter?

**Rich Text Converter** is a lightweight JavaScript library that enables you to effortlessly transform ordinary text into visually appealing and interactive content. Whether you're building a social media platform, a blog, or simply want to enhance the text on your website, this library has got you covered.

- Hyperlink #hashtags and @usernames 

### Features

- **Hashtags:** Automatically convert `#trending` into clickable links leading to related topics.
- **Mentions:** Transform `@user` into clickable links directing to user profiles.
- **Bold:** Simply wrap text within `**` to make it **bold**.
- **Underline:** Wrap text within `__` to add a subtle underline to your content.

### How to Use

#### 1. Install via npm

```bash
npm install rich-text-converter
```

#### 2. Import into Your Project

```javascript
// Import RichTextConverter
const RichTextConverter = require('rich-text-converter');

// Create a new instance
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);
```

#### 3. CDN Integration

Alternatively, you can use the library directly from a CDN:

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

#### 4. Configuration (Optional)

Customize the conversion by providing your own configurations:

```javascript
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);
```

### Why Choose Rich Text Converter?

- **Easy Integration:** Simply include the library and start converting text.
- **Flexible Configuration:** Customize the conversion patterns and URLs to fit your needs.
- **Lightweight and Efficient:** Minimal overhead and fast processing.

### Get Started Today!

Enhance your web application's text formatting capabilities with **Rich Text Converter**. Whether you're building a social platform, blog, or any web project requiring rich text, this library is here to make your life easier.

### Connect with Us

- **GitHub Repository:** [SH20RAJ/RichTextConvertor](https://github.com/SH20RAJ/RichTextConvertor)
- **Issues and Contributions:** We welcome your feedback and contributions. Feel free to open an issue or submit a pull request on our GitHub repository.

Give your text the attention it deserves. Convert plain text to rich text effortlessly with **Rich Text Converter**. Happy coding!

{% github https://github.com/SH20RAJ/RichTextConvertor %}