A simple message formatter for bold, strikthrough, underline, sub, sup, italic and code.
npm install msgdownmsgdown
======
A simple message formatter for bold, strikethrough, underline, sub, sup, italic and code.
!logo
yarn add msgdown
``js
const down = require('msgdown')
const msg = Attention: /msgdown/^TM^ is great¡1¡. _Use it_ or ~don\'t~ it is \console.log('up to you!')\`
const html = down(msg)
html will contain exactly this:
`html`
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:
`js', tag: 'code'},
const defaultTokens = {
bold: {delimiter: '*', tag: 'strong'},
italic: {delimiter: '/', tag: 'em'},
underline: {delimiter: '_', tag: 'u'},
strike: {delimiter: '~', tag: 'del'},
code: {delimiter: '
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:
`js`
const html = down('ßI am bold with a bß', {bold: {delmiter: 'ß', tag: 'b'}})
The above html will contain I am bold with a b.
There is a test file linked to yarn test`. Should be enough even though enough is never enough.
Maybe add more tokens? Maybe add pattern matching instead of plain one char matching? Maybe something else? You name it...
Matteo Merola