msgdown
A simple message formatter for bold, strikethrough, underline, sub, sup, italic and code.
Installation
yarn add msgdown
Usage
const down = const msg = `*Attention:* /msgdown/^TM^ is great¡1¡. _Use it_ or ~don\'t~ it is \`console.log('up to you!')\``const html =
html
will contain exactly this:
Attention: msgdownTM is great1. Use it or don\'t it is console.log('up to you!')
Custom tokens
By default msgdown
will use these tokens:
const defaultTokens = bold: delimiter: '*' tag: 'strong' italic: delimiter: '/' tag: 'em' underline: delimiter: '_' tag: 'u' strike: delimiter: '~' tag: 'del' code: delimiter: '`' tag: 'code' sup: delimiter: '^' tag: 'sup' sub: delimiter: '¡' tag: 'sub'
You can override every and each of the tokens by passing in your custom token object on every function call:
const html =
The above html
will contain <b>I am bold with a b</b>
.
Testing
There is a test file linked to yarn test
. Should be enough even though enough is never enough.
Development
Maybe add more tokens? Maybe add pattern matching instead of plain one char matching? Maybe something else? You name it...
Author
Matteo Merola mattmezza@gmail.com