@flasd/whatsapp-formatting
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

whatsapp formatting for the web

Build Status Coverage Status npm version npm downloads per month

What if you could use an awesome text formatting syntax that millions of people are already used to in your app? Oh wait! You can! cue Whatsapp formatting. You can use *bold*, _italic_ or ~strike~. (it's only 473 bytes gzip!)

Installation

$ yarn add @flasd/whatsapp-formatting

// or if you are feeling old school
$ npm install @flasd/whatsapp-formatting

Usage

The API is very very simple.

import { format } from '@flasd/whatsapp-formatting';

format('*hello* _wolrd_');
// « '<strong>hello</strong> <i>world</i>'

format('~how are you?~');
// « '<s>how are you?</s>'

format(`
multiline
string
`);
// « '<br>multiline<br>string<br>'

You can mix and match all of the formatters. OH! And you can customize the formatting rules if you want to:

import { format, whatsappRules } from '@flasd/whatsapp-formatting';

const customRules = [
  ...whatsappRules,
  {
    wildcard: '|',
    openTag: '<span style="font-family:monospace">',
    closeTag: '</span>',
  }
];

format('|some awesome code|', customRules);
// « '<span style="font-family:monospace">some awesome code</span>'

MIT License

Copyright 2020 Marcel de Oliveira Coelho under the MIT License. Go Crazy. 🚀

Dependencies (0)

    Dev Dependencies (9)

    Package Sidebar

    Install

    npm i @flasd/whatsapp-formatting

    Weekly Downloads

    443

    Version

    0.1.4

    License

    MIT

    Unpacked Size

    15 kB

    Total Files

    12

    Last publish

    Collaborators

    • husscode