0.0.5 • Published 1 month ago

@wayfu/waydown v0.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
1 month ago

logo logo

An easy Way For You to Convert WhatsApp Markdown to HTML.

Inspired by Drawdown © Adam Leggett

Install

NPM

npm i --save @wayfu/waydown

In your app.js import and initialized the module like normal.

import Waydown from "@wayfu/waydown";

Vanilla

If you wish to skip the modular build and NOT use npm you can use the vanilla build like so:

CDN

<script src="https://unpkg.com/@wayfu/waydown@latest/dist/index.min.js"></script>

How to use it:

let text = "This is a sample text to test *Waydown*."

element.innerHTML = Waydown(text)

Almost all WhatsApp markdown key supported like *bold*, _italic_, *_bold italic_*, ~strikethrough~, and `code`. Also support converting link like string to HTML link element.

Options

Waydown accept second parameter for options. It can be a object or boolean. For the object type parameter, we're using elemenOptions from @wayfu/wayfu-dom, you can check there. We just add 1 property plain which accept boolean value.

For the boolean value itself is the plain property value. If this value sets to true, the return is same as the input text. This is usefull if you working at WYISWYG editor for WhatsApp markdown.

type WaydownOption = {
    plain: boolean,
} & elemenOptions;

function Waydown(text: string, plain?: boolean): string
function Waydown(text: string, opt?: WaydownOption): string

For the elementOption as WaydownOption will only be set at the main element. The main element tag will be div by default.

TypeScript

This library comes with TypeScript "typings". If you happen to find any bugs in those, create an issue.

License

Copyright © 2023 Wayfu under ISC License

0.0.5

1 month ago

0.0.4

1 month ago

0.0.3

9 months ago

0.0.2

11 months ago

0.0.1

11 months ago